personal-memory-mcp
Personal Memory MCP Server
一个无损、结构化、可查询的事实存储库,存储关于你生活的事实,Claude 在任何对话中都会读取和写入它。一次部署服务一个人。完全运行在 Cloudflare 的免费套餐上(Workers + D1 + KV)。完整规范见 requirements.md。
事实,而非文档。 每条事实都是一条带日期的陈述,并附有来源。
仅追加。 更正会插入新事实,并用指针淘汰旧事实;不会删除任何内容。
认证: OAuth 2.1 配合 Dynamic Client Registration;通过 GitHub 进行身份验证,锁定到单个 GitHub 账户。
传输: 在
/mcp上使用 Streamable HTTP(无状态createMcpHandler,不使用 Durable Objects)。
设置
1. 创建 Cloudflare 资源
npm install
npx wrangler d1 create memory
npx wrangler kv namespace create OAUTH_KV将返回的 D1 database_id 和 KV 命名空间 id 填入 wrangler.jsonc,然后应用迁移:
npx wrangler d1 migrations apply memory --remote2. 创建 GitHub OAuth 应用
在 https://github.com/settings/developers → New OAuth App:
Homepage URL:
https://personal-memory-mcp.<your-subdomain>.workers.devAuthorization callback URL:
https://personal-memory-mcp.<your-subdomain>.workers.dev/callback
在 https://api.github.com/users/<your-login> 找到你的数字 GitHub id(id 字段)。
3. 设置密钥
npx wrangler secret put GITHUB_CLIENT_ID
npx wrangler secret put GITHUB_CLIENT_SECRET
npx wrangler secret put COOKIE_ENCRYPTION_KEY # e.g. openssl rand -hex 32
npx wrangler secret put OWNER_GITHUB_ID # numeric id, not login(通过 Workers Builds CI/CD 部署时,在 Cloudflare 仪表板的 Worker 的 Settings → Variables and Secrets 下设置一次即可;它们会在部署后保留。)
4. 部署
npm run deploy或者在 Cloudflare 仪表板(Workers Builds)中连接 GitHub 仓库,这样每次推送都会部署。迁移不会在部署时自动运行;要么继续手动应用,要么将 Workers Builds 部署命令设置为:
npx wrangler d1 migrations apply memory --remote && npx wrangler deploy5. 从 Claude.ai 连接
Settings → Connectors → Add custom connector → URL https://personal-memory-mcp.<your-subdomain>.workers.dev/mcp,Client ID/Secret 留空(Dynamic Client Registration)。你会被引导通过 GitHub 登录;除 OWNER_GITHUB_ID 之外的任何账户都会收到 403。之后该连接器即可在 Claude 网页版、Desktop 和 iOS 上使用。
添加到你的 Claude.ai 个人资料偏好设置中:
我运行一个名为 "memory" 的个人记忆 MCP 服务器。它是我生活的真相来源,并覆盖你的内置记忆。当我们谈论任何个人话题时,请按照工具描述使用它。如果它不可达,请告诉我,并注明你的回答可能已过时。
6. 种子数据(可选)
让 Claude 根据其内置记忆起草
seed.json:[{topic, content, fact_date?, tags?}],每条目一条事实。审阅后,然后:
npm run seed # validates seed.json, writes seed-import.sql
npx wrangler d1 execute memory --remote --file=seed-import.sql在第一次对话中,让 Claude 编写初始主题摘要(
update_summary)。
Related MCP server: chronomem
开发
cp .dev.vars.example .dev.vars # separate GitHub OAuth app with callback http://localhost:8788/callback
npx wrangler d1 migrations apply memory --local
npm run dev # http://localhost:8788/mcp
npm test # vitest (workers runtime, real D1 + FTS5)
npm run typecheck使用 MCP inspector 测试:npx @modelcontextprotocol/inspector@latest → 连接到 http://localhost:8788/mcp。inspector 的 localhost OAuth 重定向仅在设置 ALLOW_LOCALHOST_REDIRECTS=1 时有效(在 .dev.vars 中设置,切勿在生产环境中设置——生产环境只接受 Claude 连接器回调)。
备注
备份:使用
export工具(markdown 或 json)。在存在 FTS5 虚拟表时,D1 的原生导出无法工作。D1 Time Travel 提供时间点恢复(付费套餐 30 天,免费套餐更短——请核实当前的保留期限)。有意推迟(所有者决定,并非疏忽):§11 每周备份 cron 到私有 GitHub 仓库,以及 §12
/view只读查看器。在 cron 存在之前,请定期运行export并将输出保存在安全的地方。OAuth 批准流程只接受
claude.ai/claude.com连接器回调作为重定向 URI(localhost 需要上述仅限开发的标志)。正常操作中永远不会删除行;所有者通过告诉 Claude 来更正事实。
This server cannot be deployed
Maintenance
Related MCP Connectors
Persistent AI memory shared across Claude, ChatGPT, coding agents, and compatible MCP clients.
- mcpOAuthai.butlerbrain
Persistent memory for AI assistants. Save once; recall from Claude, ChatGPT, or any MCP client.
Person-owned AI memory that learns, not just stores — portable context for any MCP client.
- HeirmosOAuthcom.heirmos
Persistent memory shared across Claude, ChatGPT, Grok and other MCP clients.
Related MCP Servers
AlicenseNot gradedqualityBmaintenanceEnables persistent memory storage and retrieval for MCP clients, allowing AI assistants to remember facts and context across conversations.17 npmMIT- AlicenseAqualityCmaintenanceEnables AI agents and MCP clients to store, retrieve, and manage bi-temporal, graph-aware facts in an embedded SQLite memory engine with token-budgeted recall and contradiction tracking.61MIT
- AlicenseAqualityAmaintenanceEnables personal AI memory management through MCP tools for adding, searching, exporting, and deleting memories, with knowledge-graph retrieval and multi-hop association for clients like Claude Desktop and Cursor.6Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients such as Cursor, Claude, and Windsurf to store and recall user preferences, behaviors, and other text-based information across conversations, using vector similarity search so conceptually related items are found even when exact keywords differ.15 npmMIT