Cloudflare Memory MCP
Cloudflare Memory MCP
一个面向 opencode 的按项目隔离记忆的 MCP 服务器,完全托管在 Cloudflare 的免费套餐上:
Notes — 带标签和类型的简单键控记忆
Vector — 通过 Vectorize 进行语义召回(嵌入来自 Workers AI 的
@cf/baai/bge-m3,1024 维,多语言)Graph — 在 D1(SQLite)中存储实体与关系,支持递归遍历
Web dashboard — 在浏览器中打开
/即可看到每个有记忆的项目。每个项目卡片都会打开一个详情视图,其中包含该实体和关系的交互式力导向图(滚轮 = 缩放,拖拽 = 平移,双击或按钮 = 重置,悬停 = 高亮邻居),以及一个 删除项目 按钮,可删除该项目及其笔记、图谱、FTS 行、缓存和向量嵌入
opencode ── MCP (streamable HTTP + Bearer auth) ──> Worker
├─ Vectorize memory-vectors (namespace per project)
├─ D1 projects / notes / nodes / edges / FTS5
├─ Workers AI bge-m3 embeddings
└─ KV recent-memories cache截图
项目列表
仪表盘会列出该账号下的所有已知项目,包括记忆、实体、关系和最近活跃的计数。
知识图谱
打开任意项目,即可查看其记忆和图谱。图谱支持带箭头的弯曲有向边、悬停高亮、滚轮缩放、拖拽平移和重置控件。
Related MCP server: MCP Memory
文件夹隔离的工作原理
服务器在一个 Durable Object(免费套餐,SQLite 后端)中运行 MCP 会话,它会将会话中的每一条消息固定到同一个 isolate 上。项目身份按以下顺序解析:
project_root工具参数(推荐)—— 将你的工作文件夹传给任意工具,例如remember({ project_root: "D:/Projects/foo", content: ... })。服务器会先对路径做规范化再哈希,生成一个稳定的项目 id,并在本次会话中记住它,所以之后的调用可以省略该参数。identify_project工具可用于显式锁定项目身份。project_id工具参数 —— 一个显式的项目 id(同样会在会话内缓存)。x-project-root/x-project-id请求头 —— 供配置了这些请求头的客户端使用。MCP roots —— 当客户端支持时,自动识别文件夹。
由于项目身份只是规范化路径的哈希,同一个文件夹即使通过不同的绝对路径打开,也依然会解析到同一个项目。所有读写都以该 id 为作用域——Vectorize 查询使用按项目划分的命名空间,每条 D1 查询也按 project_id 过滤,因此两个文件夹永远无法看到彼此的记忆。
在 opencode 中使用
opencode 知道自己的工作目录(也就是你的 bash cwd)。智能体在每次会话中传一次即可。本仓库附带一份可直接复制的模板 AGENTS.md —— 将它复制到任何需要记忆的项目中,把 PROJECT_ROOT 设置为该项目的目录,智能体就会自动处理项目身份:
When using the memory MCP tools, pass project_root (your bash cwd) on the first
memory call of the session.设置
前置条件:Node 18+、一个 Cloudflare 账号,并已执行过一次 npx wrangler login。
npm install
npm run setup # creates D1 db, KV namespace, Vectorize index; patches wrangler.toml
npm run db:migrate:remote
npx wrangler secret put MEMORY_AUTH_TOKEN # optional but strongly recommended
npm run deploy你的端点:
MCP:
https://cloudflare-memory-mcp.<your-subdomain>.workers.dev/mcp仪表盘:
https://cloudflare-memory-mcp.<your-subdomain>.workers.dev/
本地开发:
npm run dev # wrangler dev --local (AI + Vectorize are remote-only)
npm run db:migrate:local接入 opencode
一个入口即可——同一份配置在每个项目中都适用,无需按项目设置不同的值:
// ~/.config/opencode/opencode.jsonc
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"memory": {
"type": "remote",
"url": "https://cloudflare-memory-mcp.<your-subdomain>.workers.dev/mcp",
"oauth": false,
"headers": {
"Authorization": "Bearer {env:MEMORY_AUTH_TOKEN}"
}
}
}
}项目身份随后由智能体自行驱动:它会在每次会话的第一次记忆调用中,把工作文件夹作为 project_root 传入(见上面 AGENTS.md 的提示),此后服务器就会把所有内容都限定在该文件夹范围内。
仪表盘(/)会要求输入一次相同的 MEMORY_AUTH_TOKEN,并把它存入 localStorage。如果你把 MEMORY_AUTH_TOKEN 留空,所有内容都将公开——只应在个人实验或一次性实验时这样做。
MCP 工具
工具 | 用途 |
| 借助 |
| 保存一条笔记(会对它进行嵌入,以便语义召回);可一键将 |
| 语义/向量搜索——按含义找回记忆。注意:Vectorize 的写入是异步的,因此一条笔记要在 |
| 精确关键词搜索(D1 FTS5) |
| 获取项目最近的笔记 |
| 一次性汇总统计信息 + 最近记忆 + 高频实体 + 最近关系(需显式调用) |
| 有意识地构建知识图谱 |
| 某个实体的邻居(深度 1–3)或连接最多的实体 |
| 删除一条笔记及其嵌入向量 |
所有工具都接受可选的 project_root(文件夹路径或 file:// URI)和 project_id;在会话中只要提供了其中一个,就会被记住。
免费套餐额度
资源 | 免费额度 | 说明 |
Durable Object | 10 万次请求/天,约 28 小时/天活跃算力 | 承载 MCP 会话;每条 MCP 消息约消耗 1 次请求 |
Vectorize | 账号级 存储 500 万维度 | 约可存 4,800 条嵌入笔记(1024 维);可用 |
Workers AI | 1 万神经元/天 | 对 1k-token 的笔记做 bge-m3 嵌入 ≈ 1 个神经元 → 每天可处理数千条 |
D1 | 每数据库 5 GB / 500 MB | 笔记 + 图谱 + FTS 对个人使用来说基本无限 |
KV / Worker | 1 GB 存储 / 10 万次请求/天 | 缓存与服务;每个 opencode 会话只产生几次请求 |
如果你将来逼近向量上限,可以使用这些设计杠杆:只对值得长期保留的记忆做嵌入(remember 时设置 type: "decision" | "fact"),把长尾交给 search_memory(FTS5,无上限)处理;或者用 bge-small(384 维,仅英文)重建索引,获得约 3 倍的容量。
项目结构
src/index.ts fetch router: dashboard, /api/*, /mcp -> Durable Object
src/session-do.ts MCP session host (Durable Object): sessions, SSE, roots, identity
src/tools.ts the 10 tool definitions (zod schemas + implementations)
src/store.ts D1 / Vectorize / KV data layer
src/identity.ts project-id derivation from folder roots
src/embed.ts Workers AI bge-m3 embeddings
src/api.ts dashboard API (projects, detail, graph, delete)
src/web.ts dashboard page (token-gated)
migrations/ D1 schema
scripts/setup.mjs creates Cloudflare resources and patches wrangler.toml
AGENTS.md template to copy into projects that use this memory serverThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to remember user information and preferences across conversations using vector search technology. Built on Cloudflare infrastructure with isolated user namespaces for secure, persistent memory storage.16MIT
- FlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to remember and retrieve user information across conversations using vector search technology. Built on Cloudflare infrastructure with isolated user namespaces for secure, persistent memory storage.16
- FlicenseNot gradedqualityDmaintenanceProvides cross-device access to a persistent knowledge graph via Cloudflare Workers, enabling memory storage and retrieval through both MCP protocol and REST API with full-text search capabilities.
- AlicenseNot gradedqualityAmaintenanceSelf-hosted semantic memory layer for Claude and MCP-compatible AI clients. Store notes, search by meaning not keywords, and recall relevant context automatically across sessions. Runs free on Cloudflare Workers, D1, Vectorize, and Workers AI4737MIT
Related MCP Connectors
Universal memory for AI agents and tools. Save, organize and search context anywhere.
Cross-session, cross-device memory for your agent: remember and recall notes. No key to start.
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
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/ady133t/Cloudflare-Memory-Mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server