Memory Bridge
Memory Bridge is an MCP server that provides a local-first, auditable long-term memory and knowledge layer for AI clients.
Store memories: Save stable facts, preferences, project decisions, events, instructions, knowledge, relationships, and document chunks with metadata like tags, scope, source, validity dates, confidence, importance, and idempotency keys.
Recall memories: Retrieve relevant memories by query, tags, kinds, namespace, time, and score threshold; optionally include recent turns for disambiguation and archived items.
Build context: Generate compact memory context text for insertion into model conversations, with a token budget.
Correct memories: Update existing memories, append versions, or mark statuses.
Forget memories: Soft-delete memories with a reason while preserving audit records.
Inspect memories: List/filter memories and view stats on counts, types, and namespace distribution.
Compute deterministically: Use built-in arithmetic calculator, date difference, and date shift tools instead of mental math.
Govern access and integrity: Enforce user/namespace/scope isolation, version chains via supersede, audit all operations, and support local Ollama by default.
Integrates with Ollama as the default local model provider for text generation and embeddings, enabling fully offline operation with configurable model endpoints for remote services.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Memory Bridge remember the refund window is 30 days from receipt per policy.pdf"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Memory Bridge(忆桥)
Local-first, evidence-backed knowledge & memory layer for MCP.
内网 AI 知识库引擎 —— 企业文档问答 / 制度与合同检索 / 私有化部署,每个答案带逐句出处与可回放 traceId;同时是不绑定任何客户端的 MCP 长记忆中间件。
30 秒跑起来(无需本机 Node,无需构建):
docker run -i --rm -v memory-bridge-data:/data ghcr.io/yanglinfeng/memory-bridge:latest已发布到官方 MCP Registry(io.github.yanglinfeng/mcp-memory-bridge),多架构镜像见
GHCR。
EN — Memory Bridge answers three questions most RAG / memory stacks skip: where did this sentence come from, is the source still valid, and who can see it. Every answer carries source bindings and a retrieval
traceId; every change is audited; every namespace is isolated. By default, model requests go to local Ollama. If you configure a remote model endpoint, the relevant prompts and context are sent there.
AI 知识库最大的风险不是答不出,是编造和引用已废止的文件。忆桥给回答配出处、给变更留审计、给部门数据上隔离。默认配置使用本机 Ollama;如果将模型地址配置为远程服务,相关提示词和上下文会发送到该服务。
什么时候该用忆桥
你在搭企业内部知识库,并且满足下面任意一条:
你的场景 | 忆桥对应的能力 |
员工问的是制度、流程、合同、售后记录这类有版本、有归属的文档 | 文档级版本链,内容变更自动轮替,旧版本退出默认检索但仍可审计 |
你被要求回答「这条结论出自哪份文件哪一段」 | 逐句来源绑定 + 可回放的 |
不同部门不能看到彼此的资料 | 用户 / 命名空间 / 作用域三层隔离 + 可信会话签发 |
数据不能出内网 | 本地优先,默认本机 Ollama,无外部依赖 |
也就是说:企业知识库 / 内网文档问答 / 制度与合同检索 / 私有化部署,以及在这些场景下的长记忆层——忆桥同时是不绑定任何客户端的 MCP 记忆中间件,可直接接进 Claude Desktop、Cline、Cursor 等客户端。
反过来,如果你只是想让 AI 记住你的代码风格偏好,或者想要一个托管在云上的记忆服务,忆桥不是最优选择——它的强项是可审计,代价是要你自己部署。
Related MCP server: mindpalace
为什么是忆桥
企业落地绕不开的问题 | 忆桥的机制 |
这句话的出处是哪份文件的哪一段? | 非破坏式巩固逐句绑定来源,每次召回带 |
文件改版了,旧答案还会被引用吗? | 文档级版本链:内容变更自动走 |
谁能看见、谁改过? | 用户 / 命名空间 / 作用域三层隔离 + 可信会话签发与授权矩阵 + 全操作审计日志 |
已实现
检索与问答
FTS5 + Dense ANN + 概念倒排 + 严格重排的全库混合检索,不按「最近 N 条」预截断
Cross-encoder 重排:
bge-reranker-v2-m3Python sidecar,按语料域(policy / open)分档相关性门槛相关性不足时按粗排分填充(filler),保留多跳证据链
弃答策略:语料里没有就明确说没有,不硬编
答案工具:
calculator/date_diff/date_shift——算术与日期交给代码算,不让模型口算bi-temporal 召回:检索窗口同时受
valid_from/valid_to约束
接入面
10 个 MCP 工具:记忆读写 7 个 ——
memory_remember·memory_recall·memory_get_context·memory_update·memory_forget·memory_list·memory_stats;确定性求解 3 个 ——answer_calculator·answer_date_diff·answer_date_shiftHTTP API + OpenAI 兼容接口 + React 管理台(候选审核、版本证据、召回解释、索引水位、系统健康)
知识库 / RAG 应用层直写通道,字段级契约见 API 接口文档
记忆治理
自然语言记住 / 纠正 / 遗忘的同步快车道;纠正保持稳定 UUID 并追加版本,遗忘先写 tombstone
跨多轮推断固定进入待确认,支持确认 / 拒绝 / 阻止未来等价 claim——没有 inference 自动提交开关
非破坏式巩固:来源变化或遗忘后摘要自动失效并可重建
默认保留用户数据:无自动衰减、无证据脱敏
工程底座
SQLite(
node:sqlite)+ outbox / jobs:租约、重试、dead letter、崩溃重放、幂等执行全操作审计 + 检索 JSONL 日志(元数据 / 诊断分级、脱敏、轮转、保留清理)
Memory Doctor 只读体检:重复、冲突、孤儿、失效摘要、超大记忆、零结果热点
模型全可配置:默认生成
qwen2.5:14b、embeddingbge-m3:latest(Ollama),无需云服务
Quick Start
前置:Node.js ≥ 24,Ollama 已运行(Docker 方式不需要本机 Node)。
ollama pull qwen2.5:14b
ollama pull bge-m3:latest方式 A —— 官方镜像(推荐,零构建)
docker run -i --rm -v memory-bridge-data:/data ghcr.io/yanglinfeng/memory-bridge:latest镜像同时提供 linux/amd64 与 linux/arm64(Apple Silicon 原生运行,不走模拟)。
方式 B —— npx(只接 MCP 客户端)
注:npm 包
mcp-memory-bridge尚在发布准备中。若此命令报 404,请改用方式 A 或 C。
MEMORY_BRIDGE_USER_ID=default npx -y mcp-memory-bridge方式 C —— 从源码运行(管理台 / 开发)
git clone https://github.com/yanglinfeng/memory-bridge.git
cd memory-bridge
npm install
npm run build
npm start # HTTP 服务 + 管理台:http://127.0.0.1:3789首次启动为空记忆库——没有演示数据,管理台只展示真实写入的内容。
容器里跑 HTTP 模式要注意:忆桥只监听回环地址(
127.0.0.1/::1),这是有意的安全 契约——服务信任 loopback 上的无令牌请求。所以容器里不能用-p 3789:3789做端口映射 (映射到的是容器自己的回环,宿主机连不上),请改用--network host(Docker Desktop 需先 在设置里启用 host networking)。完整说明见 Dockerfile 头部注释。
接入任意 MCP 客户端(Claude Desktop / Cline / …),用官方镜像最省事:
{
"mcpServers": {
"memory-bridge": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-v", "memory-bridge-data:/data",
"ghcr.io/yanglinfeng/memory-bridge:latest"
]
}
}
}从源码运行时改用绝对路径:
{
"mcpServers": {
"memory-bridge": {
"command": "node",
"args": ["/absolute/path/to/memory-bridge/dist/server/mcp-stdio.js"],
"env": {
"MEMORY_BRIDGE_USER_ID": "default"
}
}
}
}MEMORY_BRIDGE_USER_ID(或改用 MEMORY_BRIDGE_MCP_TOKEN)是必填项——两者都缺时服务会拒绝
启动。镜像里已内置 MEMORY_BRIDGE_USER_ID=default,所以 Docker 方式无需再配。
npm 包发布后,也可改用 "command": "npx" 与 "args": ["-y", "mcp-memory-bridge"]。
接入示例
三个零构建、可直接运行的最小示例(curl / Node / Java),覆盖写入(含 corpusDomain /
classification)、幂等重放、召回、supersede 改版与时序对照查询:
export MB_TOKEN=你的令牌 # 见 examples/README.md §1
bash examples/curl/quickstart.sh
node examples/node/quickstart.mjs
java examples/java/QuickStart.java # JDK 17+,零依赖文档一致性
文档里声明的 schema 版本、环境变量、npm 脚本、HTTP 路由与配置默认值,可以和代码事实一键对撞:
npm run check:docs它会把「文档说的」与「代码里的」逐项比对并在不一致时以非零退出码失败,适合在发布前与每次 大改后重跑。见 CONTRIBUTING.md。
完整安装、运维、接口与排障文档从 docs/README.md 进入; 基准评测的条件与一键复现见 BENCHMARKS.md。
评测
忆桥自带评测与压测链路(scripts/ 下 40+ 个可执行脚本,覆盖检索、重排、巩固、命名空间隔离、上下文反思、规模、可靠性与崩溃恢复),并在 docs/acceptance-report-*.md 中保留带日期与环境的证据快照。
公开基准(英文知识库问答、中文自建集)的条件与一键复现脚本已列在 BENCHMARKS.md。 其中包含数据准备与运行限制;大规模延迟压测仍是项目内部评测,不作为公开基准。在数字可复现之前,README 不主张任何分数——这是本项目「可信层」定位的一部分。
和主流方案的区别(按维度,不按体量)
维度 | 忆桥 | mem0 | Zep / Graphiti | RAGFlow | AnythingLLM |
引用可验证(来源绑定 + | ✅ | — | — | ✅ | 部分 |
时序有效性(版本替代退出检索) | ✅ 文档级 | — | ✅ 事实级 | — | — |
全操作审计日志 | ✅ | 企业版 | ✅ | — | — |
命名空间 / 部门隔离 | ✅ 可信会话 + 授权矩阵 | 企业版 | ✅ | 团队级 | Workspace |
遗忘与纠正(tombstone / 版本追加) | ✅ | ✅ | ✅ | — | — |
可配置为全离线(模型端点也在本机) | ✅ | 部分 | — | ✅ | ✅ |
MCP 原生 | ✅ 7 工具 | ✅ | 社区封装 | ✅ | — |
本表只列架构上有无,不评分数高低。各项目迭代都很快,请以各自仓库为准。
Roadmap
BENCHMARKS.md:公开基准的完整条件与一键复现(npm run bench:cn/bench:cmrc/bench:hotpotqa)社区四件套:
CONTRIBUTING.md/SECURITY.md/CHANGELOG.md/CODE_OF_CONDUCT.md,附.env.example与examples/(curl / Node / Java)文档 ↔ 代码一致性门禁
npm run check:docs(发布前与每次大改后重跑)supersede时补写valid_to,并补 as-of 查询的回归测试清掉 3 例预存在的失败用例:迁移备份与写锁顺序那 1 例已修(改为取锁后复检文件家族);
test:lifecycle的 2 例 doctor 经查是 Node 版本低于engines >= 24所致,非代码缺陷英文入口
README.en.md(核心指南英文版仍待补)pretest加 Node 版本守卫:engines在 npm 里只是警告、不阻断执行, Node < 24 跑npm test会稳定看到 2 例假红灯文档解析深度:推荐接入 RAGFlow / Docling 等上游,忆桥专注其上的可信层
关于开源边界的说明。 忆桥的定位是「可信层」,而可信必须可被验证——所以证据绑定、版本链、 审计日志、命名空间隔离这些构成可信层的能力,全部在本仓库、全部 Apache-2.0、且不会改为闭源。 只有两类东西不在本仓库内:企业内网的文档摄取与权限落地(解析、章节切分、ACL 裁剪、审核流、 图像链路),以及交付与运维工程(离线交付包、升级回滚、合规审计导出、带 SLA 的支持)。 它们作为独立模块提供商业支持,不影响本仓库的完整可用性——独立部署本仓库就是完整可用的内核。
联系与支持
事项 | 走哪个通道 |
缺陷报告 | |
功能建议 | |
私有化部署实施 / 商业支持与 SLA / 定制开发 | Issues · 商业合作模板 或 Discussions 的 Commercial 分类 |
用法讨论、部署求助、调优经验 | |
安全漏洞 | Security Advisories —— 请勿为安全问题开公开 Issue,处理流程见 SECURITY.md |
维护者是个人开发者(@yanglinfeng),不开空头 SLA;缺陷会按「是否影响 出处可验证 / 版本可追溯 / 权限可隔离」排序,商务类咨询优先回复。
本项目以 Apache-2.0 授权。公司内部自用、二次开发、集成进内部系统,乃至打包进你们对外销售的产品,都不需要向我们申请授权——这是 Apache-2.0 已经给到你的权利,我们不会事后收回。
既然如此,什么情况下才需要联系?答案是需要责任,而不是许可:
你需要的是 | 怎么走 |
私有化部署实施、模型选型与调优、历史数据迁移 | 商业合作表单 |
带明确响应时间的 SLA、年度维护与升级保障 | 商业合作表单 |
企业内网场景的文档摄取、章节切分与权限落地 | 商业合作表单 |
只是想用起来 | 不必联系, |
「忆桥 / Memory Bridge」名称与标识不在 Apache-2.0 的授权范围内(见许可证第 6 条)。二次分发请使用你自己的产品名,不要让人误以为出自本项目官方。
License
Available Tools
10 toolsanswer_calculator算术计算器ARead-onlyIdempotent
对算术表达式做确定性求值,支持 + - * / % ^ 与括号。召回结果中的数值需要加减乘除(金额合计、单价×数量等)时调用,不要心算。
Inputs: expression (required), _memoryRequestKey.
answer_date_diff日期差计算ARead-onlyIdempotent
计算两个日期相差的天数与年/月/日拆分。日期支持 ISO、YYYY/MM/DD、中文(2024年3月5日)。涉及"间隔多少天/多久"的问题时调用。
Inputs: to (required), from (required), _memoryRequestKey.
answer_date_shift日期平移ARead-onlyIdempotent
把日期平移指定天数(可为负),返回结果日期与星期。"X 天后是几号""提前 N 天"类问题调用。
Inputs: date (required), days (required), _memoryRequestKey.
memory_forget遗忘长期记忆ADestructiveIdempotent
根据用户明确要求删除一条记忆。采用可恢复的软删除,并保留审计记录。
Inputs: id (required), reason, _memoryRequestKey.
memory_get_context生成对话记忆上下文BRead-onlyIdempotent
在回答用户前检索相关长期记忆,并返回可直接加入模型上下文的紧凑文本。适合每轮对话前调用。
Inputs: query (required), tags, kinds, limit, +5 more.
memory_list列出长期记忆BRead-onlyIdempotent
按条件查看记忆,适合管理、核对或让用户确认系统记住了什么。
Inputs: tag, kind, limit, query, +4 more.
memory_recall召回相关记忆ARead-onlyIdempotent
回答涉及用户偏好、过去事件、项目状态或既有决定的问题前调用。只返回与当前查询相关的少量长期记忆,并解释命中原因。
Inputs: query (required), tags, kinds, limit, +6 more.
memory_remember保存长期记忆AIdempotent
保存值得跨会话保留的稳定事实、偏好、项目决定、重要事件或指令。不要保存闲聊、临时状态、密码、令牌或未经用户同意的敏感信息。重复内容会自动合并。
Inputs: kind (required), content (required), tags, scope, +13 more.
memory_stats查看记忆库状态ARead-onlyIdempotent
查看长期记忆数量、类型和命名空间分布。
Inputs: _memoryRequestKey.
memory_update修正长期记忆AIdempotent
修改已经存在但不准确、过期或需要补充的记忆。仅提交需要更改的字段;修改 content 时必须写成修正后的完整、独立事实,不要写“用户修正了”之类的过程描述。
Inputs: id (required), kind, tags, title, +12 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Most tools are clearly distinct: memory_remember/forget/update cover the write lifecycle, while answer_calculator/date_diff/date_shift are unambiguous utility functions. The one real overlap is memory_recall vs memory_get_context, which both retrieve relevant long-term memories and differ mainly in output format, so an agent could occasionally pick the wrong one.
Two clear prefix groups (memory_* for 7 tools, answer_* for 3) give a predictable pattern, and snake_case is used throughout. Minor deviations exist: some names are verb-led (memory_forget, memory_update) while others are noun-led (memory_stats, answer_calculator), and memory_get_context is a longer compound, but all remain readable.
Ten tools is well-scoped: seven cover the memory lifecycle and three provide computation helpers that support answering questions from recalled data. Each tool earns its place with no redundant entries.
The memory surface covers full CRUD plus listing and stats (remember, recall/get_context, update, forget, list, stats), which is a complete lifecycle. Minor gaps exist around namespace/bulk management and export, and the added calculator/date tools are helpful but arguably outside the core memory domain.
Maintenance
Related MCP Connectors
Persistent, inspectable memory for AI agents with lineage, correction, and a hosted MCP endpoint.
Hosted agent memory: store, search, and recall facts across sessions from any MCP client.
The knowledge base your AI reads and writes, under your rules — over MCP, EU-hosted.
Append-only decisions with provenance, supersession, retrieval, and audited MCP actions.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables multiple MCP-compatible AI clients to share persistent, versioned project knowledge across sessions with conflict-safe updates, provenance, hybrid retrieval, stale-memory handling, and context-budgeted recall.MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to ingest documents and notes, retain facts with their validity periods, and answer questions as of any point in time using bitemporal queries.MIT
- AlicenseNot gradedqualityBmaintenanceEnables humans and AI agents to share canonical, versioned knowledge through MCP, with auditable provenance, review workflows, and reconciliation.1Apache 2.0
- AlicenseNot gradedqualityBmaintenanceProvides MCP clients with persistent storage, hybrid search, evidence checking, and automatic context compression, including fact slots, typed links, and lossless archival.MIT