Local Memory
FreeNot checkedA fully local MCP memory server for Cursor IDE - no API keys required
About
A fully local MCP memory server for Cursor IDE - no API keys required
README
一个完全本地运行的 MCP (Model Context Protocol) 记忆服务器,无需任何 API 密钥,所有数据存储在本地 JSON 文件中。
✨ 功能特性
- 🔒 完全本地 - 无需网络连接,无需 API 密钥,完全离线运行
- 💾 JSON 存储 - 数据存储在本地 JSON 文件中,易于备份和迁移
- 🔍 智能搜索 - 使用 Fuse.js 实现模糊匹配搜索
- 📊 会话管理 - 支持多会话管理,便于分类组织
- 📅 时间线查看 - 按时间查看记忆历史
- 🏷️ 标签分类 - 支持类型和标签分类
- 🤖 自动记录 - 自动记录关键提示词和代码变更
- 📝 提示词历史 - 完整记录所有提示词历史
- 🔄 代码变更追踪 - 自动记录重要的代码文件变更
🚀 快速开始
前置要求
- Node.js 18+ (下载)
- Cursor IDE 或支持 MCP 协议的 IDE
安装步骤
- 克隆仓库
git clone https://github.com/yourusername/local-memory-mcp-server.git
cd local-memory-mcp-server
- 安装依赖
npm install
- 配置 Cursor
打开 Cursor 设置 (Ctrl+Shift+P → "Preferences: Open User Settings (JSON)"),添加:
{
"mcp.servers": {
"local-memory": {
"command": "node",
"args": ["/path/to/local-memory-mcp-server/server.js"]
}
}
}
⚠️ Windows 用户: 使用完整路径,例如:
"C:\\Users\\YourName\\local-memory-mcp-server\\server.js"
- 重启 Cursor
重启 Cursor IDE 以使配置生效。
📖 使用方法
添加记忆
在 Cursor 中直接说:
记住:用户喜欢使用深色主题
或使用工具:
add_memory({
content: "用户喜欢使用深色主题",
type: "preference",
importance: 8
})
搜索记忆
搜索关于 "主题" 的记忆
查看最近上下文
获取最近24小时的记忆
查看时间线
显示最近7天的记忆时间线
管理会话
列出所有会话
创建一个新会话叫 "项目A"
自动记录功能
系统会自动记录:
- 包含关键词的提示词("记住"、"重要"、"修复"等)
- 重要的代码文件变更(超过10行或包含关键词)
查看自动记录:
获取最近24小时的提示词历史
获取代码变更历史
🛠️ 可用工具
| 工具 | 描述 | 参数 |
|---|---|---|
add_memory |
添加新记忆 | content(必填), type, tags, importance |
search_memory |
搜索记忆(模糊匹配) | query(必填), limit, type |
get_recent_context |
获取最近上下文 | limit, hours |
timeline |
查看时间线 | days, session_id |
get_observation |
获取指定记忆 | id(必填) |
update_memory |
更新记忆 | id(必填), content, importance |
delete_memory |
删除记忆 | id(必填) |
list_sessions |
列出会话 | limit |
create_session |
创建会话 | name(必填) |
get_session |
获取会话详情 | id(必填) |
auto_record_prompt |
自动记录提示词 | prompt(必填), context |
auto_record_change |
自动记录代码变更 | file_path, change_type, content |
get_prompts_history |
获取提示词历史 | limit, hours |
get_changes_history |
获取代码变更历史 | limit, file_path |
stats |
查看统计信息 | - |
help |
获取帮助 | - |
📁 项目结构
local-memory-mcp-server/
├── server.js # MCP 服务器主文件
├── auto-memory.js # 自动记录模块
├── package.json # 项目配置
├── README.md # 项目文档
├── LICENSE # MIT 许可证
├── hooks/ # Git hooks(可选)
│ ├── git-post-commit.js
│ └── cursor-command.js
├── demo.js # 功能演示脚本
├── demo-auto-record.js # 自动记录演示
└── *.md # 文档文件
📁 数据存储
数据默认存储在:
- Windows:
C:\Users\<用户名>\.local-memory-mcp\memory.json - Linux/Mac:
~/.local-memory-mcp/memory.json
可通过环境变量 MEMORY_DATA_DIR 自定义存储位置。
数据文件说明
memory.json- 主数据库文件(包含所有记忆、会话、提示词)prompts.log- 提示词日志文件changes.log- 代码变更日志文件
🔧 高级配置
自定义数据目录
在 Cursor 配置中添加环境变量:
{
"mcp.servers": {
"local-memory": {
"command": "node",
"args": ["/path/to/server.js"],
"env": {
"MEMORY_DATA_DIR": "/custom/path/to/data"
}
}
}
}
Git 集成(可选)
安装 Git post-commit hook 自动记录提交的变更:
# Windows PowerShell
.\setup-auto-record.ps1
# Linux/Mac
cp hooks/git-post-commit.js .git/hooks/post-commit
chmod +x .git/hooks/post-commit
📊 记忆类型
建议使用的记忆类型:
general- 一般信息(默认)fact- 事实信息preference- 用户偏好task- 任务相关note- 笔记code- 代码相关project- 项目信息prompt- 提示词(自动记录)code_change- 代码变更(自动记录)
🎯 使用场景
场景1:记住项目偏好
记住:这个项目使用 Python 3.11,框架是 FastAPI
场景2:记住常用命令
记住:部署命令是 npm run deploy:prod
场景3:回顾项目历史
搜索关于 "部署" 的所有记忆
显示最近30天的记忆时间线
场景4:自动记录工作流程
- 系统自动记录您的提示词
- 自动记录重要的代码修改
- 随时查看历史记录
🔒 隐私与安全
- ✅ 完全本地 - 所有数据存储在您的设备上
- ✅ 无需网络 - 完全离线运行
- ✅ 无需 API - 不需要任何在线服务或密钥
- ✅ 数据可控 - 您完全控制自己的数据
❓ 常见问题
Q: 服务器无法启动?
A: 确保已安装 Node.js 18+ 并运行 npm install
Q: 记忆没有保存?
A: 检查数据目录是否有写入权限
Q: 如何备份数据?
A: 直接复制 memory.json 文件即可
Q: 如何迁移数据?
A: 将 memory.json 复制到新位置,并更新配置中的 MEMORY_DATA_DIR
Q: 为什么有些提示词没有自动记录?
A: 系统只记录包含关键词或较长的提示词。可以修改 auto-memory.js 中的 isKeyPrompt() 函数调整规则。
Q: 数据会丢失吗?
A: 所有数据保存在本地 JSON 文件中。建议定期备份 memory.json 文件。
🤝 贡献
欢迎提交 Issue 和 Pull Request!
📜 许可证
本项目采用 MIT License 许可证。
🙏 致谢
- Model Context Protocol - MCP 协议
- Fuse.js - 模糊搜索库
📞 联系方式
如有问题或建议,请提交 Issue。
Made with ❤️ for privacy-conscious developers
Installing Local Memory
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/wlixi008-byte/local-memory-mcp-serverFAQ
Is Local Memory MCP free?
Yes, Local Memory MCP is free — one-click install via Unyly at no cost.
Does Local Memory need an API key?
No, Local Memory runs without API keys or environment variables.
Is Local Memory hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Local Memory in Claude Desktop, Claude Code or Cursor?
Open Local Memory on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
GitHub
PRs, issues, code search, CI status
by GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Template MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
by mcpdotdirectCompare Local Memory with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All development MCPs
