Agent 记忆库 MCP
通过 Model Context Protocol(Streamable HTTP)在 Cursor、Claude Desktop 等 MCP 客户端中调用记忆库。REST 说明见记忆库 API 文档。
MCP 端点
单一 URL,支持 POST / GET / DELETE(无状态 JSON 模式)。客户端向该地址发送 JSON-RPC 消息。
https://ai-sass-7pymefszf-keyskulls-projects.vercel.app/api/v1/memory/mcp
鉴权
MCP 与 REST 共用同一套控制台 API Key(前缀 inf_)。必须使用租户级密钥;本地 .env 占位 Key 不能用于生产 MCP。
创建 API Key
- 打开控制台 → API 密钥(/dashboard/keys)
- 在「权限(多选)」中勾选所需 Scope(Gateway / Memory 两组)
- 快捷预设:MCP 只读、MCP 读写、Gateway 默认
- 只读 Agent:仅勾选 memory:read
- 需要 memory_save_atom:同时勾选 memory:write
- Memory MCP 通常无需绑定 Gateway;Gateway 场景可选绑定
- 生成后立即复制 inf_… 密钥,并粘贴到 MCP 客户端 Authorization 头
Scope 对照
- memory:read — memory_list_libraries / search / recall / wake-up / list_atoms
- memory:write — memory_save_atom、POST /atoms
请求头
- Authorization: Bearer inf_xxxxxxxx(推荐)
- X-API-Key: inf_xxxxxxxx
- 勿使用上游 Gemini/OpenAI Key — 那是 Gateway 上游配置,不是平台 API Key
传输
- 协议:MCP Streamable HTTP(2025-11-25)
- 模式:无状态 + enableJsonResponse(单次 POST 返回 JSON,无需 SSE 长连接)
- 除 tools/call 外,initialize、tools/list 等标准 MCP 方法均支持
推荐工作流
- 先调用 memory_list_libraries 获取 memoryLibraryId
- 检索类任务使用 memory_search / memory_recall / memory_wake_up
- 写入使用 memory_save_atom(同步落盘)
- 除 list_libraries 外,其余工具均需在参数中传入 memoryLibraryId
工具一览
| Tool | Scope | Description |
|---|---|---|
| memory_list_libraries | memory:read | 列出当前团队可用的记忆库(id、name、slug、persona) |
| memory_search | memory:read | L3 深度语义搜索 |
| memory_recall | memory:read | L2 按需召回 |
| memory_wake_up | memory:read | L0+L1 会话唤醒上下文 |
| memory_save_atom | memory:write | 同步写入 Atom(?sync=1 等价) |
| memory_list_atoms | memory:read | 分页列出 Atom |
Cursor 配置示例
{
"mcpServers": {
"engra-memory": {
"url": "https://ai-sass-7pymefszf-keyskulls-projects.vercel.app/api/v1/memory/mcp",
"headers": {
"Authorization": "Bearer inf_xxxxxxxx"
}
}
}
}HTTP 集成
若自建 MCP 客户端,请遵循 MCP Streamable HTTP 规范:POST 时 Accept 需包含 application/json 与 text/event-stream;本服务端点以 application/json 响应为主。