关于 MCP OpenMemory Server
MCP OpenMemory Server 是一个独立的 MCP 服务,让 Claude 能够记住对话内容并随时间学习。它使用 SQLite 本地存储,无需外部依赖,适合在 Claude Desktop 中使用的个人用户。
主要功能
- 01保存并召回对话消息
- 02维护可跨对话更新的记忆摘要
- 03按可配置时间窗口获取近期对话
- 04基于 SQLite 的本地持久化存储
- 05通过 context 参数按项目划分记忆
适用场景
- 01让 Claude Desktop 跨对话保留个人偏好与项目背景
- 02查看近期对话记录以延续上下文
- 03在同一数据库中按项目隔离记忆
MCP 相关
该服务通过 MCP 暴露 save_memory、recall_memory_abstract、update_memory_abstract 和 get_recent_memories 四个工具。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
4收录的工具列表 · 更新于 3 周前
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| speaker | any | 是 | |
| message | any | 是 | |
| context | any | 是 |
详细介绍
MCP OpenMemory 服务
让 Claude 能够记住你的对话,并随着时间的推移从中学习。
https://github.com/user-attachments/assets/aef82b8e-3793-4ebd-b993-ddaef14d52d1
功能
- 记忆存储:保存和回忆对话消息
- 记忆摘要:在不同对话间维护经过总结的记忆上下文
- 近期历史记录:在可配置的时间范围内访问近期对话
- 本地数据库:使用 SQLite 持久化存储,无需外部依赖
⚠️ 重要提示
你必须将 MEMORY_DB_PATH 配置为持久化位置,以免 Claude Desktop 关闭时丢失对话历史记录。 如果未配置,数据库默认存放在临时位置的 ./memory.sqlite,应用重启时该位置可能会被清除。
配置
前提条件
-
Node.js:运行 MCP 服务所需。使用以下命令验证是否已安装:
node --version如果尚未安装,请从 nodejs.org 下载
-
Claude Desktop:下载适用于 macOS 或 Windows 的最新版本
Claude Desktop 集成
配置文件位置
Claude Desktop 配置文件位于:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
访问方法:打开 Claude Desktop → Claude 菜单 → Settings → Developer → Edit Config
macOS/Linux
使用 npm 直接运行
{
"mcpServers": {
"mcp-openmemory": {
"command": "npx",
"args": [
"@peakmojo/mcp-openmemory@latest"
],
"env": {
"MEMORY_DB_PATH": "/Users/username/mcp-memory.sqlite"
}
}
}
}
Windows
使用 npm 直接运行
{
"mcpServers": {
"mcp-openmemory": {
"command": "npx",
"args": [
"@peakmojo/mcp-openmemory@latest"
],
"env": {
"MEMORY_DB_PATH": "C:\\Users\\username\\mcp-memory.sqlite"
}
}
}
}
从源代码运行(所有平台)
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["/path/to/your/repo/server.js"],
"env": {
"MEMORY_DB_PATH": "/path/to/your/memory.sqlite"
}
}
}
}
环境变量
MEMORY_DB_PATH:SQLite 数据库文件的路径(默认值:./memory.sqlite)
验证
配置并重启 Claude Desktop 后,你应该会看到:
- 输入框左下角的滑块图标(🔧)
- 点击滑块后显示的可用工具:
save_memoryrecall_memory_abstractupdate_memory_abstractget_recent_memories
故障排除
未显示服务
- 完全重启 Claude Desktop
- 检查配置文件中的 JSON 语法
- 确认路径为绝对路径(而非相对路径),且路径存在
- 手动测试服务启动:
# Test if the server runs correctly npx @peakmojo/mcp-openmemory@latest
检查日志
日志位置:
- macOS:
~/Library/Logs/Claude/ - Windows:
%APPDATA%\Claude\logs\
查看近期日志:
# macOS/Linux
tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
# Windows
type "%APPDATA%\Claude\logs\mcp*.log"
常见问题
- Windows 上出现 ENOENT 错误:在 env 配置中添加
APPDATA - 工具调用失败:检查服务日志中的错误
- 未找到 NPM:使用
npm install -g npm全局安装 NPM
如需详细的故障排除信息,请参阅 MCP 官方文档。
安全提示
⚠️ Claude Desktop 以你的用户帐户权限运行 MCP 服务。 仅安装来自可信来源的服务。
可用工具
- save_memory:存储单条对话消息
- recall_memory_abstract:获取当前记忆摘要
- update_memory_abstract:更新记忆摘要
- get_recent_memories:检索近期对话历史记录
使用方法
配置 Claude Desktop 后,服务会自动启动。首次使用时会自动创建数据库。
系统提示词示例
# Memory Usage Guidelines
You should use memory tools thoughtfully to enhance conversation continuity and context retention:
## When to Save Memory
- **save_memory**: Store significant conversation exchanges, important decisions, user preferences, or key context that would be valuable to remember in future conversations
- Focus on information that has lasting relevance rather than temporary details
- Save when users share important personal information, project details, or ongoing work context
## When to Update Memory Abstract
- **update_memory_abstract**: After processing recent conversations, combine new important information with existing context to create an improved summary
- Update when there are meaningful developments in ongoing projects or relationships
- Consolidate related information to maintain coherent context over time
## When to Recall Memory
- **recall_memory_abstract**: Use at the beginning of conversations to understand previous context, or when you need background information to better assist the user
- **get_recent_memories**: Access when you need specific details from recent exchanges that aren't captured in the abstract
- Recall when the user references previous conversations or when context would significantly improve your assistance
## What Constitutes Critical Information
- User preferences and working styles
- Ongoing projects and their current status
- Important personal or professional context
- Decisions made and their rationale
- Key relationships or collaborations mentioned
- Technical specifications or requirements for recurring tasks
Use these tools to build continuity and provide more personalized assistance, not as error-prevention mechanisms or intent-guessing systems.
🔀 按项目划分记忆命名空间
你可以通过两种方式按项目分隔记忆:
1. 硬隔离(Claude 与 Cursor)
在每个应用的配置中使用不同的 MEMORY_DB_PATH:
- Claude(
claude_desktop_config.json):
"mcpServers": {
"claude-memory": {
"command": "npx",
"args": ["@peakmojo/mcp-openmemory@latest"],
"env": {
"MEMORY_DB_PATH": "/Users/you/claude-memory.sqlite"
}
}
}
- Cursor(.cursor/config.json 或工具配置):
"mcpServers": {
"cursor-memory": {
"command": "npx",
"args": ["@peakmojo/mcp-openmemory@latest"],
"env": {
"MEMORY_DB_PATH": "/Users/you/cursor-memory.sqlite"
}
}
}
每个应用都会运行自己的实例,并将数据存储在各自的数据库中。
2. 通过 context 进行软命名空间隔离
调用记忆工具时,传入自定义的“context”:
{ "context": "project-x", "message": "Notes from project X." }
使用此方法可在同一个数据库中按逻辑划分记忆。
🔍 暂不支持语义搜索。如有需要,请提交 GitHub issue。
参考资料
- Model Context Protocol(MCP)官方文档 - 完整的 MCP 规范和指南
- 面向 Claude Desktop 用户的 MCP 快速入门 - 分步设置指南
- MCP 服务开发指南 - 用于构建自定义 MCP 服务
- MCP GitHub 仓库 - 官方 MCP 实现和示例
- Claude Desktop - 下载 Claude Desktop 应用
- Node.js - MCP 服务所需的运行时
许可证
MIT 许可证
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。