使用说明
克劳德存储器MCP
跨会话的Claude持久内存——适用于VS Code、Claude Desktop和任何MCP客户端。
为什么存在
克劳德不记得以前的对话了。每一次新的会议都会重新开始。
这个MCP服务器给了克劳德 持久内存:
- 💾 保存 重要的背景、决策、发现
- 🔍 搜索 使用全文搜索的过去对话
- 🔄 召回 往届会议发生了什么
- 📝 同步 CLAUDE.md用于特定于项目的上下文
- 🌐 适用于所有地方 --VS Code,克劳德桌面,终端
快速开始
1.安装
# Clone the repository
git clone https://github.com/YOUR_USERNAME/claude-memory-mcp.git
cd claude-memory-mcp
# Install dependencies
npm install
# Build
npm run build
2.配置您的MCP客户端
VS Code with Claude Extension
添加到您的VS代码 settings.json (Cmd/Ctrl+Shift+P→ “首选项:打开用户设置(JSON)”):
{
"claude.mcpServers": {
"memory": {
"command": "node",
"args": ["/absolute/path/to/claude-memory-mcp/dist/server.js"]
}
}
}
Claude Desktop (Mac)
编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"memory": {
"command": "node",
"args": ["/absolute/path/to/claude-memory-mcp/dist/server.js"]
}
}
}
Claude Desktop (Windows)
编辑 %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"memory": {
"command": "node",
"args": ["C:\\path\\to\\claude-memory-mcp\\dist\\server.js"]
}
}
}
3.重新启动客户端
重新启动VS Code或Claude Desktop。克劳德现在有可用的记忆工具了!
可用工具
| 工具 | 说明 |
|---|---|
memory_save |
保存一些要记住的东西 |
memory_search |
搜索过去的记忆(全文) |
memory_get |
按内存ID获取完整详细信息 |
memory_timeline |
查看内存周围的上下文 |
memory_list_sessions |
列出最近的会话 |
memory_recall_session |
从会话中获取所有回忆 |
memory_context |
获取当前任务的相关上下文 |
memory_checkpoint |
保存状态并同步到CLAUDE.md |
memory_stats |
查看内存统计信息 |
memory_delete |
删除内存 |
内存类型
保存记忆时,请使用以下类型以更好地组织:
| 类型 | 用途 | 示例 |
|---|---|---|
discovery |
关键见解 | “API需要OAuth2刷新令牌” |
decision |
选择 | “使用PostgreSQL而不是MongoDB,因为…” |
bug |
问题和修复 | “通过添加互斥体修复了竞争条件” |
todo |
稍后的任务 | “需要添加速率限制” |
context |
项目设置 | “这是一个带有app Router的Next.js 14应用程序” |
research |
研究结果 | “基准测试显示Redis快3倍” |
checkpoint |
会话状态 | 检查点自动生成 |
note |
一般注意事项 | 其他事项 |
使用示例
保存记忆
You: "Remember that the API rate limit is 100 requests per minute"
Claude: [uses memory_save]
✅ Saved memory #1
Type: discovery
Tags: api, rate-limit
搜索
You: "What did we figure out about authentication?"
Claude: [uses memory_search with query="authentication"]
Found 3 memories:
#12 [bug] 2024-01-15
Fixed auth token not refreshing - needed to add...
#8 [decision] 2024-01-14
Using JWT with refresh tokens because...
#5 [discovery] 2024-01-13
Auth service requires specific headers...
获取完整上下文
You: "Show me the full details of memory #12"
Claude: [uses memory_get with ids=[12]]
## Memory #12
**Type:** bug
**Date:** 2024-01-15
**Tags:** auth, token, refresh
The authentication token wasn't refreshing properly...
[full content shown]
会话召回
You: "What did we work on yesterday?"
Claude: [uses memory_list_sessions with days=1]
Recent sessions:
**a1b2c3d4** | 2024-01-15 | 12 memories | my-project
Fixed authentication bugs and added rate limiting
**e5f6g7h8** | 2024-01-15 | 8 memories | my-project
Set up project structure and database
检查点和同步
You: "Let's checkpoint this session"
Claude: [uses memory_checkpoint]
✅ Checkpoint saved (#45)
📝 Synced to ./CLAUDE.md
CLAUDE.md集成
服务器可以将内存同步到 CLAUDE.md 文件在您的项目中。此文件:
- 即使没有MCP服务器也能持续
- 由Claude自动加载(在Claude代码中)
- 包含您的项目规则+自动更新的内存
CLAUDE.md示例
# CLAUDE.md
## Project Overview
E-commerce API built with Node.js and PostgreSQL.
## Rules
- Always run tests before committing
- Use TypeScript strict mode
- Follow REST conventions
## 🧠 Memory (Auto-Updated)
<!-- MEMORY_SYNC_START -->
_Last synced: 2024-01-15T10:30:00Z_
### Recent Sessions
- **2024-01-15**: Fixed auth bugs, added rate limiting (12 memories)
- **2024-01-14**: Database schema design (8 memories)
### Key Discoveries
- API rate limit is 100 req/min
- Auth service requires X-API-Version header
### Decisions Made
- Using PostgreSQL for ACID compliance
- JWT with refresh tokens for auth
<!-- MEMORY_SYNC_END -->
配置
环境变量:
| 变量 | 默认值 | 描述 |
|---|---|---|
MEMORY_DIR |
~/.claude-memory |
数据库的存储位置 |
MEMORY_DB |
memory.db |
数据库文件名 |
MEMORY_PROJECT |
自动检测 | 当前项目名称 |
MEMORY_MAX_RESULTS |
20 |
默认搜索限制 |
MEMORY_LOG_LEVEL |
info |
日志记录级别 |
数据存储
所有数据都存储在本地 ~/.claude-memory/:
~/.claude-memory/
├── memory.db # SQLite database with FTS5
└── memory.db-wal # Write-ahead log (auto-managed)
运作原理
┌─────────────────────────────────────┐
│ Claude (VS Code / Desktop / CLI) │
│ │
│ "Remember the API rate limit" │
└─────────────────┬───────────────────┘
│
│ MCP Protocol (stdio)
│
▼
┌─────────────────────────────────────┐
│ claude-memory-mcp Server │
│ ├── memory_save │
│ ├── memory_search │
│ ├── memory_get │
│ └── memory_checkpoint │
│ │
│ SQLite + FTS5 (full-text search) │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ ~/.claude-memory/memory.db │
└─────────────────────────────────────┘
发展
# Install dependencies
npm install
# Build TypeScript
npm run build
# Watch mode (rebuild on changes)
npm run dev
# Clean build artifacts
npm run clean
故障排除
服务器未连接
- 检查配置中的路径是否为绝对路径
- 确保已安装Node.js 18+:
node --version - 跑
npm run build编译TypeScript - 尝试手动运行:
node dist/server.js
搜索未找到结果
- 检查搜索查询中的拼写
- 尝试更广泛的搜索词
- 使用
memory_stats验证数据是否存在
CLAUDE.md未同步
- 检查项目目录的写入权限
- 跑
memory_checkpoint明确地 - 检查响应中的错误消息
贡献
欢迎投稿!拜托:
- 分叉存储库
- 创建要素分支
- 提交拉取请求
许可证
麻省理工学院——随心所欲地使用它。
学分
灵感来源:
为克劳德社区而建。 🧠