kb-memory
rag-kb — 本地 Agent 记忆服务 + 多 Agent 协作系统
English | 中文
本地优先、完全离线可用的 Agent 记忆与知识服务——REST + MCP 双协议,混合检索(向量 + BM25 归一化加权融合),文档/网页入库与 RAG 问答;无 LLM 时存取与检索完整可用。
本仓库含两个子系统(ROADMAP):
子系统 | 一句话定位 | 状态 |
kb | 本地优先、完全免费的 Agent 记忆与知识服务(核心产品,开发主线,当前测试开发阶段) | 测试开发中 |
agent-orchestra | 基于 kb 共享任务板的跨任务多 Agent 协作系统(❄️ 维护模式,自用脚手架) | B1-B3 收口冻结 |
开源协议:Apache-2.0(含专利授权,可商用)。
kb — 本地优先的 Agent 记忆与知识服务
Windows 单进程常驻(python -m kb serve),REST + MCP 双协议,向 Claude Code /
Cursor / TraeWork / 自建 Agent 提供记忆写入、文档与网页入库、混合检索
(向量 + BM25 归一化加权融合)与 RAG 问答。
无 LLM 时存取与检索完整可用——记忆写入、文档入库、混合检索不依赖任何大模型;
配置本地 Ollama 或云端 API 后,/ask 问答能力自动启用。
Related MCP server: mnemostack
核心特性
单进程常驻:一个
python -m kb serve同时提供 REST API 与 MCP 端点,无需额外组件混合检索:BGE-M3 向量检索 + BM25 关键词检索,归一化加权融合排序(每路 min-max 归一化后按生效路数均权,N32/N33),中文分词友好
可选精排:
KB_RERANK_ENABLED=true启用 bge-reranker-v2-m3 交叉重排(默认关)可选三路:
KB_SPARSE_ENABLED=true启用 BGE-M3 稀疏向量第三路(默认关,失败自动降级双路)
记忆管理:写入 / 更新 / 删除 / 列表,支持 namespace、tags、type 过滤
记忆全共享(v3):所有记忆/知识与任何客户端、任务、AI 全共享——本地单用户定位,跨 agent、跨任务读到同一份用户记忆;client/project 仅用于审计归类与元数据(不再隔离读写);主键服务端生成
存取审计:每次写/读/改/删/检索/问答记 JSON 到
logs/agent-audit/<客户端>__<项目>.log(按 client+project 分文件);用户可查:RESTGET /api/v1/audit?client=<客户端>[&project=<项目>]或 CLIkb audit --client <客户端>知识入库:本地文档(txt/md/pdf/docx 等)上传或路径导入,网页正文抓取入库
目录监听:指定目录内新增/删除文件自动入库/清理(
KB_WATCH_DIR)CLI 工具:
kb add/search/stats/ask/eval/forget/dedup——终端直接完成写入、检索、统计与 RAG 问答隐私护栏:敏感 namespace 强制本地回答不出网;
/ask智能路由(本地优先,难题可选云端)断网可用:模型与数据全部落本地,无网络时存取与检索功能完整
快速开始(Windows / Linux / macOS)
Windows PowerShell:
# 1. 创建并激活虚拟环境
python -m venv venv
.\venv\Scripts\Activate.ps1
# 2. 安装依赖
pip install -r requirements.txt
# 3. 启动服务(默认监听 http://127.0.0.1:8000)
python -m kb serveLinux / macOS:
# 1. 创建并激活虚拟环境
python3 -m venv venv
source venv/bin/activate
# 2. 安装依赖
pip install -r requirements.txt
# 3. 启动服务
python -m kb serve重要:
kb命令只装在虚拟环境内。每个新终端都要先激活虚拟环境 (Windows.\venv\Scripts\Activate.ps1,Linux/macOSsource venv/bin/activate), 否则会提示kb:未找到命令。改用python -m kb <子命令>可绕过激活。快速安装备选(免虚拟环境,Python 3.10+):
pip install --user -r requirements.txt后 用python -m kb serve运行,但建议优先使用 venv 隔离依赖。
启动后健康检查:
curl http://127.0.0.1:8000/api/v1/healthz首次启动会加载本地嵌入模型(默认 BAAI/bge-m3,约 2GB,需提前下载缓存); 未配置 LLM 时服务照常启动,
/ask返回 503 与配置指引。LLM 默认关闭(
KB_LLM_MODE=off):服务启动不会探测/加载/调用任何大模型, 零显存、零成本、纯离线;记忆写入、文档入库、混合检索完整可用。 需要 RAG 问答(/ask)时再按下面方式配置本地或云端 LLM。
配置 LLM(可选,/ask 问答需要)
KB_LLM_MODE 默认 off(不加载不调用);四个档位:
档位 | 行为 |
| 完全不加载/不调用 LLM;记忆存取与检索完整可用 |
| 仅本地 Ollama(完全离线,隐私零出网) |
| 本地优先,云端降级:本地 Ollama 可用走本地,无本地但有云端 Key 走云端 |
| 全部走云端(本地仅做压缩与隐私隔离) |
本地 LLM(Ollama):
# 1. 安装并启动 Ollama(Windows 从开始菜单/托盘启动,不要从 AI 沙箱终端拉起)
# 2. 拉取一个适合你电脑的模型(按显存/内存选择,如 qwen3:4b 约 3.2GB、
# qwen3:1.7b 约 1.8GB;国内可用魔搭加速,拉完 ollama cp 改成短名)
ollama pull <你的模型名>
# 3. 在 .env 配置后重启服务:
# KB_LLM_MODE=local # 仅本地
# KB_LLM_MODEL=<你的模型名> # 以 `ollama list` 输出的名称为准
# KB_OLLAMA_BASE_URL=http://localhost:11434云端 LLM(任意 OpenAI 兼容服务商,不绑定 DeepSeek): DeepSeek / OpenAI / 通义千问 / 硅基流动 / Moonshot 等均可,通用三键:
# .env
KB_LLM_MODE=auto # 本地优先、云端降级;或 cloud 全云端
KB_LLM_API_KEY=sk-xxx # 服务商 API Key
KB_LLM_BASE_URL=https://api.deepseek.com # 换成你所用服务商的 OpenAI 兼容端点
KB_LLM_CLOUD_MODEL=deepseek-v4-flash # 云端模型名验证:GET /api/v1/healthz 的 llm 字段——local/cloud 表示 LLM 已就绪,disabled 表示未启用。
常见问题:嵌入模型下载失败
中国大陆直连
huggingface.co会超时。设置 HF 镜像后重启即可:export HF_ENDPOINT=https://hf-mirror.com # 或写入 ~/.bashrc 永久生效 python -m kb serve模型会自动从镜像下载并缓存到
~/.cache/huggingface/hub/,之后断网也能离线加载。模型已在本机缓存,但无外网:
kb采用离线优先(先命中本地缓存,失败才联网), 只要缓存目录完整即可完全离线运行。
让 Agent 接入 kb(客户端无关)
把 kb 的接入规约交给 AI 客户端(TraeWork / Claude Code / Cursor / 自建 Agent), 让它们知道怎么读写记忆、按什么身份规约、怎么查审计。两种方式,任选其一:
skill(推荐,能自动触发)——可选的独立步骤:仓库内
skills/kb-memory/SKILL.md是客户端无关的 Anthropic 开格式 skill。把它安装到你所用客户端的用户级 skills 目录后, 该客户端的任何项目会话都会在读写记忆/RAG 问答/审计查询时自动识别并触发。 安装 = 把skills/kb-memory目录复制过去即可(有脚本,也可手动复制,无需任何依赖); 更新(重新覆盖)、卸载、以及装好后的使用说明见scripts/README.md。不装也不影响 kb 服务:skill 只是给 AI 客户端的「提示词包装」,与服务的安装、 启动无关——跳过这一步,服务照常运行,你随时可用方法 2 的纯文本提示词接入; skill 安装是一次性、按需、独立执行的,不会随
kb serve自动触发, 也不会写入你的任何客户端目录以外的文件。纯文本提示词(兜底,任何客户端通用):整段复制
docs/AGENT_PROMPT.md粘贴给 Agent 即可,不依赖 skill 机制。
.trae-cn/skills/.claude/skills/.cursor/skills是任何客户端都认的「标准」吗?——不是。 这些只是各家客户端各自的用户级约定目录:SKILL.md本身是统一的 Anthropic 开格式, 但「装到哪个目录、能否自动触发」由各客户端自行决定,支持程度不一:
客户端 | 用户级 skills 目录 | 自动加载 |
TraeWork |
| 自动发现 |
Claude Code |
| 高版本支持 |
Cursor |
| 逐步跟进 |
其他 / 自建 Agent | 无统一约定 | 需手动加载或不支持 |
不存在「所有客户端都遵循」的统一目录;你的客户端若不支持 skill,永远有方法 2 兜底 (粘贴
AGENT_PROMPT.md,纯文本任何客户端可用)。安装方法、各客户端目录差异与加载机制、 相互引用关系:详细见scripts/README.md(此处不重复)。
MCP 挂载
MCP 端点(streamable HTTP):http://127.0.0.1:8000/mcp/
Claude Code:本仓库已内置项目级 .mcp.json,在本目录启动 Claude Code 即自动挂载;
也可全局添加:
claude mcp add --transport http kb http://127.0.0.1:8000/mcp/Cursor / TraeWork 及其他支持 MCP 的客户端:在 MCP 配置中加入以下 JSON
(Cursor 放 ~/.cursor/mcp.json 或项目 .cursor/mcp.json;TraeWork 在设置中添加 MCP 服务器):
{
"mcpServers": {
"kb": {
"type": "http",
"url": "http://127.0.0.1:8000/mcp/"
}
}
}挂载后可用的 MCP 工具:write_memory / search_memory / read_memory /
update_memory / delete_memory / add_document / add_webpage / ask_kb。
启用
KB_API_KEY鉴权后,MCP 客户端需在连接配置加headers(Authorization: Bearer <key>); 仓库内.mcp.json模板不含真实 key(JSON 不支持注释),配法见 USER_GUIDE §5.2。
REST 端点速查
方法 | 路径 | 说明 |
POST |
| 写入记忆 |
GET |
| 记忆列表,支持 |
GET |
| 读取单条记忆 |
PATCH |
| 更新内容或标签 |
DELETE |
| 删除单条记忆 |
POST |
| 混合检索 |
POST |
| 文档入库:multipart |
GET |
| 已入库文档列表(按 source 聚合) |
DELETE |
| 按 source 删除该文档全部记录 |
POST |
| 网页入库 |
POST |
| RAG 问答 |
GET |
| 健康检查与服务统计 |
GET |
| 记忆治理统计: |
GET |
| 治理配置:衰减+新鲜度开关与参数(只读) |
POST |
| 启用语义去重( |
记忆治理(去重/衰减/新鲜度)均默认关闭、零行为变化;用法见 USER_GUIDE §3.5。
示例:
# 写入一条记忆
curl -X POST http://127.0.0.1:8000/api/v1/memories `
-H "Content-Type: application/json" `
-d '{"content": "用户偏好深色主题", "tags": ["偏好"]}'
# 混合检索
curl -X POST http://127.0.0.1:8000/api/v1/search `
-H "Content-Type: application/json" `
-d '{"query": "用户界面偏好", "top_k": 5}'
# RAG 问答(需配置 LLM)
curl -X POST http://127.0.0.1:8000/api/v1/ask `
-H "Content-Type: application/json" `
-d '{"question": "用户喜欢什么主题?"}'配置项简表
全部配置以 KB_ 前缀的环境变量或 .env 文件提供;完整键名见 .env.example
(复制为 .env 后填写,.env 已被 gitignore,真实密钥只放本机,严禁入库)。
配置项 | 默认值 | 说明 |
|
| LLM 模式: |
| 空 | 嵌入模型设备:空=自动检测,可显式设 |
|
| serve 模式监听目录,文件变动自动入库;空串或 |
|
| 运行数据根目录(ChromaDB、运行时状态等) |
|
| REST 与 MCP 监听地址 |
|
| 嵌入模型 |
| 空 | 本地 Ollama 模型名(默认空=不配;配 |
|
| Ollama 端点 |
| 空 | 云端 LLM(可选):任意 OpenAI 兼容服务商(DeepSeek / OpenAI / 通义 / 硅基流动等),仅填在本机 |
|
| 文档切分参数 |
| 空 | 逗号分隔的敏感 namespace,命中强制本地回答不出网 |
| 空 | 空=不鉴权(本地回环零摩擦);非空=启用 Bearer/X-API-Key 鉴权;orchestra 客户端自动带 |
|
| 检索精排(A3.5):融合候选送 CrossEncoder 重排,默认关 |
|
| 稀疏第三路(A3.5):BGE-M3 稀疏向量 + 倒排索引参与归一化加权融合,默认关 |
CLI 速查(无需启动服务)
python -m kb add "记忆内容" --tags 偏好 --client TraeWork # 写入(project 缺省自动取当前目录名)
python -m kb search "查询词" --client TraeWork # 混合检索(v3:全共享,不分客户端/项目)
python -m kb stats # 统计:类型分布 / 访问热度 / 陈旧分布
python -m kb ask "问题" --client TraeWork # 终端 RAG 问答(LLM 不可用时输出检索命中)
python -m kb audit --client TraeWork --days 7 # 查某客户端/项目存过/读过什么
python -m kb eval --file tests/eval_zh_50.jsonl # 检索质量评测(Recall@1/@5 + MRR)
python -m kb forget --stale --days 90 # 清理超期未命中记忆
python -m kb dedup --threshold 0.92 # 语义去重
kb ask直连本地服务逻辑(不经 HTTP);建议serve停止时使用,避免双进程写库竞争。
agent-orchestra — 多 Agent 协作系统(实验)
让多个 AI 助手(不同 TraeWork 任务 / Claude Code 会话,模型可不同)通过 kb 共享任务板 协作开发:协调者 AI 拆卡分发,worker AI 领卡执行、单卡单轮、回写结果,协调者核验流转。
# 前置:kb serve 已运行。开一个新 TraeWork 任务,粘贴以下引导语即可唤醒一个 worker:
venv\Scripts\python.exe orchestra\board.py new-worker worker-1完整使用方法(协调者怎么拆卡、多个 worker 怎么并行、协作纪律与已知限制) 见 用户使用手册 第 4 节。
目录结构
kb/ kb 服务源码(config / models / embedder / storage / bm25 / retriever /
service / llm / ingest / watcher / api / mcp / cli + reranker / sparse / eval)
tests/ kb 验收测试(375 项,含 eval_zh_50.jsonl 检索评测数据集)
orchestra/ 多 Agent 协作系统(board.py CLI + 协议三件套 + skill + 245 项测试)
docs/ 设计文档、节点计划、用户使用手册
kb_data/ kb 运行数据(gitignore)
_archive/ 旧学习项目归档(仅保留历史,禁止参考)更多文档
用户使用手册(人类用户入口):docs/USER_GUIDE.md
AI 接力文档(AI 助手入口):PROJECT.md(项目状态 / 进度看板 / 接手指南)
设计文档(需求、架构、API、里程碑):
docs/superpowers/specs/2026-08-23-kb-memory-service-design.mdP2 日志设计:
docs/superpowers/specs/2026-08-24-logging-design.mdP2 路线图:
docs/superpowers/plans/2026-08-24-p2-roadmap.md节点开发计划:
docs/superpowers/plans/2026-08-23-kb-dev-nodes.mdAI 协作规范:
AGENTS.md
Available Tools
8 toolsadd_documentA
导入本地文档(PDF/DOCX/MD/TXT 及 Office 格式)切分入库; 返回 {"source": 文件名, "chunks": 块数};文件不存在或格式不支持时 返回 {"error": "FILE_NOT_FOUND" | "UNSUPPORTED_FORMAT", "message": 原因}。 project/client:仅用于审计归类;文档 chunk 为共享知识,所有客户端可检索。 client:来源客户端(可选,缺省从 clientInfo 自动识别)。 English: Import a local document (PDF/DOCX/MD/TXT and Office formats), split and ingest it; returns {"source": filename, "chunks": count}; when the file is missing or the format is unsupported returns {"error": "FILE_NOT_FOUND" | "UNSUPPORTED_FORMAT", "message": reason}. project/client: audit bucketing only; document chunks are shared knowledge, searchable by all clients.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| client | No | ||
| project | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden and largely meets it: it discloses the split-and-ingest side effect, the two error modes with exact error codes, and the shared-knowledge behavior. It does not mention permissions or idempotency, but it is still substantially transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the verb, formats, and return contract, and the bilingual duplication is structured rather than rambling. It is longer than necessary because of the translation, but every section carries useful information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given there is no output schema, the description supplies the return shape and error contract. Given there are no annotations, it also discloses the shared-knowledge side effect. A small gap remains around path qualification and prerequisites, but the agent has enough context to call the tool and interpret results.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description does add useful meaning for project/client: audit bucketing only and optional client auto-detection from clientInfo. However, the required path parameter is never explicitly described, and its format is only implied by 'local document' and FILE_NOT_FOUND.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific action: import and ingest a local document. It names supported formats, states the exact return shape, and contrasts naturally with the sibling add_webpage by requiring a local path.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description tells the agent this is for local files, that project/client are audit-only, and that ingested chunks become shared knowledge searchable by all clients. It does not explicitly name alternatives or state when not to use it, but the local-file requirement and the presence of add_webpage imply the boundary.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
add_webpageA
抓取网页正文并切分入库;返回 {"source": url, "chunks": 块数}; 抓取/正文提取失败时返回 {"error": "WEB_FETCH_FAILED", "message": 原因}。 project/client:仅用于审计归类;web chunk 为共享知识,所有客户端可检索。 client:来源客户端(可选,缺省从 clientInfo 自动识别)。 English: Fetch a webpage body and ingest it after splitting; returns {"source": url, "chunks": count}; on fetch/body-extraction failure returns {"error": "WEB_FETCH_FAILED", "message": reason}. project/client: audit bucketing only; web chunks are shared knowledge, searchable by all clients.
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | ||
| client | No | ||
| project | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full behavioral disclosure burden. It clearly specifies success return shape, failure error code, project/client's audit-only role, and that web chunks are shared knowledge searchable by all clients, while also noting client auto-detection.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The main action and return behavior are front-loaded and the structure is logical, but the content is duplicated across Chinese and English sections, making it longer than strictly necessary. Each sentence does not fully earn its place because of the near-verbatim repetition.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with no annotations and no output schema, the description provides crucial invocation details: success/error returns, parameter roles, and sharing semantics. Minor gaps remain around url parameter documentation and any size/format constraints, but the core usage context is sufficiently complete for an agent to call it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has 0% description coverage, so the description must compensate. It explains that client is optional and defaults from clientInfo, and that project/client are audit-only, but it does not describe the url format or project individually beyond the grouped statement.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific action ('抓取网页正文并切分入库' / 'Fetch a webpage body and ingest it after splitting') with a clear resource: a webpage. This distinguishes it from siblings like add_document and write_memory, which handle documents and memory respectively.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies the tool is for ingesting web pages into shared knowledge, and clarifies that project/client are only for audit bucketing. However, it does not explicitly compare against alternatives like add_document, nor state when one should choose this tool over them.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
ask_kbA
基于知识库的 RAG 问答(检索 → 上下文拼装 → 护栏生成),返回 answer 与 sources; v2:检索按当前 (client, project) 隔离 memory(doc/web 共享),并写 ask 存取审计; client:来源客户端(可选,缺省从 clientInfo 自动识别); LLM 不可用时返回 {"error": "LLM_DISABLED", "message": 配置指引}。 English: Knowledge-base RAG Q&A (retrieve → build context → guarded generation), returning answer and sources; v2: retrieval isolates memory by the current (client, project) (doc/web shared); an ask access-audit is emitted; client: source client (optional; auto-detected from clientInfo when omitted); returns {"error": "LLM_DISABLED", "message": setup guidance} when the LLM is unavailable.
| Name | Required | Description | Default |
|---|---|---|---|
| client | No | ||
| project | No | ||
| question | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden, and it is notably forthcoming: it discloses the retrieve-to-generation pipeline, retrieval scoping by (client, project) with doc/web memory shared, an emitted ask access-audit, client auto-detection from clientInfo, and the exact shape of the LLM-unavailable error response. These are concrete behavioral traits beyond a basic read, especially the audit side effect and error contract.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The core purpose is front-loaded and the content is logically segmented into pipeline, v2 behavior, client semantics, and error handling. However, the entire description is duplicated in Chinese and English, which roughly doubles the length without adding information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema and sparse input schema, the description covers the important operational details: return shape (answer and sources), memory scoping, the audit side effect, and LLM-unavailable error handling. It does not specify the exact structure of sources or how the current (client, project) is fully resolved, but these are minor relative to what is disclosed.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must add parameter meaning, and it does so only partially. It clearly explains client (optional, auto-detected from clientInfo) and indirectly ties project to memory isolation, but it does not define project's role directly nor describe the expected form/content of the required question parameter.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a concrete action and resource: 'Knowledge-base RAG Q&A' / '基于知识库的 RAG 问答', with a described pipeline and return values (answer and sources). It is far from a tautology, but it does not explicitly contrast itself with sibling tools such as search_memory or read_memory.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'Knowledge-base RAG Q&A' and the memory-isolation note imply use for natural-language questions grounded in the KB rather than for memory CRUD or document ingestion. However, the description offers no explicit when-to-use, when-not-to-use, or alternative-tool guidance, so an agent must infer the decision.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
delete_memoryA
按 ID 删除一条记忆;成功返回 {"ok": true},记录不存在返回 {"error": "NOT_FOUND"}; 非 (client, project) 归属返回 {"error": "FORBIDDEN"}。 client:来源客户端(可选,缺省从 clientInfo 自动识别)。 English: Delete a memory by ID; returns {"ok": true} on success and {"error": "NOT_FOUND"} when it does not exist; non-(client, project) owners get {"error": "FORBIDDEN"}.
| Name | Required | Description | Default |
|---|---|---|---|
| client | No | ||
| project | No | ||
| record_id | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It does well by specifying success and error return shapes, including NOT_FOUND and FORBIDDEN ownership restrictions. It could further disclose that the deletion is permanent and irreversible, but the core behavioral surface is covered.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact and front-loaded with the core operation and return values. The bilingual repetition adds some length but is acceptable given multilingual context. No filler or irrelevant details are present.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple delete tool with no output schema and no annotations, the description covers the main operation, the three return states, the ownership restriction, and the optional client parameter. Minor gaps remain around project semantics and explicit irreversibility, but overall an agent has enough to call it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It adds useful meaning for client by saying it is the source client and optional, defaulting from clientInfo. It does not explain project beyond its role in ownership, and record_id is only implicitly described as 'by ID'. Partial compensation but not full.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action: deleting a memory by ID. It uses a specific verb and resource, and the tool name itself distinguishes it from siblings like write_memory and read_memory. However, it does not explicitly contrast itself with sibling tools, so it stops short of a 5.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage: use this tool to delete a memory by ID. It does not provide explicit when-to-use versus when-not-to-use guidance, nor does it mention alternatives such as update_memory for modifying existing memories. The context is clear but implicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
read_memoryA
按 ID 读取单条记忆完整内容;记录不存在返回 {"error": "NOT_FOUND"}; 非 (client, project) 归属的 memory 返回 {"error": "FORBIDDEN"};共享知识可读。 client:来源客户端(可选,缺省从 clientInfo 自动识别)。 project:项目归属(可选,缺省=该客户端默认桶)。 English: Read the full content of a single memory by ID; returns {"error": "NOT_FOUND"} when absent; a memory not owned by the (client, project) returns {"error": "FORBIDDEN"}; shared knowledge is readable.
| Name | Required | Description | Default |
|---|---|---|---|
| client | No | ||
| project | No | ||
| record_id | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It transparently discloses NOT_FOUND and FORBIDDEN error responses, ownership rules, that shared knowledge is readable, and the default behavior for optional client/project parameters. This gives the agent a strong behavioral model without needing to invoke the tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact and front-loaded with the core action and error semantics. It includes bilingual text that duplicates the same information, adding minor redundancy, but the content remains well-organized and scannable.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple read-by-ID tool with no output schema, the description adequately covers error scenarios, ownership, and optional parameter defaults. It doesn't detail the success response shape, but 'full content of memory' conveys the expected return. Overall, enough for an agent to call it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It explains that client is optional and auto-detected from clientInfo, and project defaults to the client's default bucket. record_id is self-explanatory as the ID. This adds meaningful semantics beyond the bare schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description states a specific action: read the full content of a single memory by ID. It distinguishes itself from search_memory (which searches rather than reads a single record) and other sibling write/update/delete tools. The error cases further clarify the scope.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly implies when to use: when you have a memory ID and want its full content. It explains optional client/project defaults and ownership constraints. However, it doesn't explicitly name alternatives or state when not to use this tool versus search_memory.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_memoryA
混合检索记忆与知识(向量语义 + BM25 关键词,RRF 融合); 返回命中列表,每项含 id/content/score/type/source。 v2:个人记忆(memory)只返回归属当前 (client, project) 的; 共享知识(doc/web chunk)所有客户端可见。top_k 小于 1 时返回 {"error": "INVALID_ARGUMENT", "message": 原因}。 client:来源客户端(可选,缺省从 clientInfo 自动识别)。 English: Hybrid retrieval over memories and knowledge (vector semantics + BM25 keywords, RRF-fused); returns a hit list, each item having id/content/score/type/source. v2: memory records only return those owned by the current (client, project); shared knowledge (doc/web chunks) is visible to all clients. Returns {"error": "INVALID_ARGUMENT", "message": reason} when top_k is less than 1. client: source client (optional; auto-detected from clientInfo when omitted).
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| top_k | No | ||
| client | No | ||
| project | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With zero annotations, the description carries the full burden and delivers substantially: hybrid retrieval mechanism, RRF fusion, response item fields, ownership scoping, the INVALID_ARGUMENT error contract for top_k < 1, and client auto-detection from clientInfo. It does not cover every possible trait (auth, rate limits), but the core behavioral contract an agent needs before calling is well disclosed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the core function and every sentence conveys a distinct fact, but the full bilingual duplication doubles the length for any single-language reader. The top_k error contract and client parameter note are appended after the main body rather than integrated with a parameter section, making the structure slightly scattered.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 4-parameter hybrid-retrieval tool with a bare schema and no annotations, the description covers nearly everything an agent needs: retrieval method, return fields, scope behavior, error contract, and the client shortcut. The remaining gaps — a semantic definition of top_k and a dedicated project explanation — are minor because the parameter names are reasonably self-descriptive and the default of 5 is present in the schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It does well for client (optional, auto-detected from clientInfo), partially for top_k (only the error condition is stated; no explicit 'maximum number of results' definition), and not at all for project, which appears only inside the ownership scoping rule rather than as a parameter definition. This is meaningful but incomplete compensation for a fully undocumented schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb+resource pair — '混合检索记忆与知识' / 'Hybrid retrieval over memories and knowledge' — and specifies the mechanism (vector + BM25 keywords, RRF-fused) and result shape (hits with id/content/score/type/source). This clearly distinguishes it from the CRUD memory siblings (write/read/update/delete_memory) by positioning it as cross-source retrieval, and the v2 scope rule further differentiates personal memory from shared knowledge.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage through the v2 scoping rule (personal memory only for current client/project, shared knowledge visible to all) and the error contract, but it never explicitly states when to choose search_memory over read_memory or ask_kb. There are no 'use X instead' statements or exclusions. An agent can infer this is the retrieval/search tool among its siblings, but the guidance remains implicit rather than explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
update_memoryA
按 ID 更新记忆内容(变更后自动重新嵌入);记录不存在返回 {"error": "NOT_FOUND"}; 非 (client, project) 归属返回 {"error": "FORBIDDEN"}; 内容为空串或纯空白时返回 {"error": "INVALID_ARGUMENT", "message": 原因}。 client:来源客户端(可选,缺省从 clientInfo 自动识别)。 English: Update a memory's content by ID (auto re-embed on change); returns {"error": "NOT_FOUND"} when absent; non-(client, project) owners get {"error": "FORBIDDEN"}; empty content returns {"error": "INVALID_ARGUMENT", "message": reason}.
| Name | Required | Description | Default |
|---|---|---|---|
| client | No | ||
| content | Yes | ||
| project | No | ||
| record_id | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are present, so the description carries the burden of behavioral disclosure. It usefully reveals that content is auto-re-embedded on change, and it documents the main error responses (NOT_FOUND, FORBIDDEN, INVALID_ARGUMENT) and the optional client defaulting from clientInfo. Some detail around ownership determination and success return is missing, but the core behavior is well covered.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the primary purpose and includes important error behavior. However, it duplicates the same content in Chinese and English, which adds length without adding new information; the English section is mostly a redundant translation.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that there is no output schema, the description does not specify what a successful response looks like, and the project parameter remains ambiguous. It covers primary errors and behavior well, but for a mutation tool with no structured annotations or output schema, a bit more detail would be needed for full completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It adds meaningful semantics for the client parameter by explaining it is optional and auto-detected from clientInfo, and content/record_id are reasonably inferable from the main action. However, the project parameter is essentially unexplained beyond the ownership error mention.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool updates a memory's content by ID, which is a specific verb+resource action. It inherently distinguishes itself from siblings like write_memory, read_memory, and delete_memory by referencing an existing record via ID.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The update-by-ID behavior implies when to use it, and the error conditions provide some context for expected failures. However, there is no explicit statement about when to prefer this tool over write_memory or other alternatives, so usage guidance is only implied.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
write_memoryA
写入一条记忆短文本(事实/笔记/摘要),可选标签与归属项目;返回 {"id": 记录ID}。 内容为空串或纯空白时返回 {"error": "INVALID_ARGUMENT", "message": 原因}。 v2(2026-08-30):身份由环境承载——client 自动从 MCP 握手 clientInfo 识别 (TraeWork / Claude Code / Cursor),project 为项目/任务归属(连接配置声明, 可空=该客户端默认桶);记录主键由服务端生成。共享知识(add_document/add_webpage) 所有客户端可见。 English: Write a memory short text (fact/note/summary) with optional tags and project; returns {"id": record_id}. Returns {"error": "INVALID_ARGUMENT", "message": reason} when content is empty or blank. v2: identity comes from the environment — client is auto-detected from the MCP clientInfo handshake (TraeWork / Claude Code / Cursor), project is the project/task bucket (declared in the connection config; empty = this client's default bucket). The record primary key is generated server-side. Shared knowledge (add_document/add_webpage) is visible to all clients.
| Name | Required | Description | Default |
|---|---|---|---|
| tags | No | ||
| client | No | ||
| content | Yes | ||
| project | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden and does it well: it discloses the success return format ({"id": ...}), the error case for empty/blank content, how identity is derived from the MCP handshake, that the primary key is server-generated, and that shared knowledge is separately namespaced. This is far more transparent than typical tool descriptions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The key purpose and return format are front-loaded, and the v2 notes are useful. However, the description duplicates nearly all information in Chinese and English, roughly doubling the length. The structure is organized but not optimally concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a write tool with no output schema and no annotations, the description is quite complete: it covers return values, validation errors, identity/resolution, key generation, and boundary with shared knowledge tools. Minor missing pieces are explicit guidance on when to prefer read/update/delete siblings and any permission requirements.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It explains content as the memory text, tags as optional, project as the project/task bucket with empty meaning default, and client as auto-detected from MCP clientInfo. This adds real meaning beyond the bare schema, though it does not specify tag element constraints or content length limits.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a clear verb and resource: '写入一条记忆短文本' (write a memory short text) with optional tags and project, and specifies the return shape. It also distinguishes itself from add_document/add_webpage by noting that shared knowledge is visible to all clients, which implies this tool is for non-shared memory.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides context on when the tool is appropriate by explaining the client/project identity model and contrasting shared knowledge tools (add_document/add_webpage) as visible to all clients. It does not explicitly state 'when not to use' or name alternatives for read/update/delete, but the context is clear enough for an agent to choose correctly.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
Each tool targets a distinct resource and action: CRUD operations for memories are clearly separated from hybrid retrieval, and the two ingestion tools are differentiated by source type (local file vs URL). search_memory and ask_kb are distinguishable by their outputs—raw hits versus a generated answer with sources.
All tools follow a consistent verb_noun snake_case pattern (write_memory, read_memory, update_memory, delete_memory, search_memory, add_document, add_webpage, ask_kb). The only slight deviation is ask_kb's abbreviated noun, but it still fits the verb_noun structure and is readable.
8 tools is well-scoped for a memory/knowledge server: full CRUD for memories, two ingestion tools for shared knowledge, hybrid search, and RAG Q&A each earn their place. The count is neither sparse nor bloated.
The memory lifecycle is fully covered (write/read/update/delete), and knowledge ingestion plus retrieval and Q&A are present. Minor gaps exist—there is no list/delete operation for shared documents or webpages—but agents can work around these since shared knowledge is append-only.
Maintenance
Related MCP Connectors
Persistent memory for AI agents. Semantic search, memory graph, W3C DID identity.
Long-term memory for AI assistants. Hybrid retrieval, query expansion, auto-topics.
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
Shared, governed long-term memory for AI agents across tools and sessions via MCP and REST.
Related MCP Servers
- AlicenseAqualityAmaintenancePersistent memory MCP server for AI coding agents (Claude Code, Codex, Gemini CLI). Hybrid retrieval (vector + BM25), cross-encoder reranking, knowledge graph, session checkpoint/resume, and multi-scope isolation. Local-first with LanceDB.3027615MIT
- AlicenseAqualityAmaintenanceDurable hybrid memory for AI agents. Combines vector search, BM25, temporal retrieval, and optional Memgraph knowledge graph via reciprocal rank fusion. 6 MCP tools: health, search, answer, feedback, graph_query, graph_add_triple. Self-hosted with Qdrant backend.77Apache 2.0
- FlicenseNot gradedqualityBmaintenancePersistent semantic memory MCP server for AI agents with hybrid search, LLM scoring, and decay engine, fully local.2
- AlicenseNot gradedqualityCmaintenanceMCP server that enables persistent, hybrid, local memory for LLM agents, with vector + BM25 search, knowledge graph, and policy-driven retention, providing token-budgeted context injection for AI assistants.MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/fish827-08/rag-kb'
If you have feedback or need assistance with the MCP directory API, please join our Discord server