Memory MCP
Memory MCP
为 AI 编程助手提供持久化记忆和全文会话搜索功能,以 MCP 服务器形式提供。
问题所在
AI 编程助手在不同会话之间会遗忘所有内容。架构决策、用户偏好、项目上下文、上周二调试的内容——全都消失了。你不得不不断地重复解释相同的事情。
Memory MCP 通过以下两种能力解决了这个问题:
显式记忆 -- 保存笔记、决策、模式和偏好,这些内容会在不同会话间持久存在。你的助手会记住你告诉过它的内容。
会话搜索 -- 对你整个对话历史进行全文搜索。无需滚动浏览日志,即可找到三周前讨论过的内容。
无需数据库服务器。无需后台进程。无需云端。只需你机器上的一个 SQLite 文件。
Related MCP server: MCP Vector Memory
支持的会话来源
来源 | 位置 | 格式 |
| JSONL (流式内容块) | |
Claude Code 历史记录 |
| JSONL (在会话文件清理后依然保留) |
| SQLite (sessions, messages, parts 表) | |
| JSONL (每行一个事件) |
添加新来源需要一个解析器文件和一个注册条目。请参阅 添加新会话来源。
安装
需要 Python 3.11+ 以及 SQLite FTS5 支持(标准 Python 构建中已包含)。
pip install -e .或者直接使用 uv 运行(无需安装):
uv run --directory /path/to/memory_mcp python -m memory_mcpMCP 配置
添加到你的 MCP 客户端配置中(例如 ~/.claude/mcp.json 或项目级的 .mcp.json):
使用 pip 安装:
{
"mcpServers": {
"memory": {
"command": "memory-mcp"
}
}
}使用 uv(无需安装):
{
"mcpServers": {
"memory": {
"command": "uv",
"args": ["run", "--directory", "/path/to/memory_mcp", "python", "-m", "memory_mcp"]
}
}
}工具
记忆(显式知识存储)
工具 | 描述 |
| 持久化保存带有可选标签和上下文的笔记。在所有未来的会话中均可访问。 |
| 对已保存的记忆进行全文搜索。基于关键词,按相关性排序。 |
| 浏览最近的记忆,可选择按标签过滤。 |
| 通过 ID 删除记忆。 |
会话(历史对话搜索)
工具 | 描述 |
| 浏览过去的会话。按来源 ( |
| 获取特定会话的完整对话内容。 |
| 对所有会话消息、思考块和工具使用记录进行全文搜索。 |
| 重新扫描会话目录并索引新增或更改的文件。 |
工作原理
启动时,Memory MCP 会扫描配置的会话目录,并将每段对话索引到带有 FTS5 全文搜索索引的本地 SQLite 数据库中。后续启动时会跳过 mtime(修改时间)未更改的文件。
数据库位置:
~/.memory_mcp/memory.db(可通过MEMORY_MCP_DB环境变量覆盖)会话来源: 从标准位置自动检测(可通过
MEMORY_MCP_SOURCES环境变量扩展,格式:type:path;type:path)索引: 按文件 mtime 增量进行,跨 8 个线程并行处理
搜索: 使用带有 BM25 排序、前缀匹配和短语支持的 FTS5
添加新会话来源
创建
memory_mcp/parsers/your_source.py并实现SessionParser协议:source_type: str属性parse_file(path: str) -> ParsedSession | None方法
在
memory_mcp/parsers/__init__.py中注册它在
memory_mcp/config.py中添加目录检测逻辑
示例请参考 parsers/claude_code.py 或 parsers/omp.py。
测试
python tests/test_e2e.py端到端测试将 MCP 服务器作为子进程启动,通过 stdio 协议测试所有 8 个工具,并断言工具响应。使用临时数据库,因此不会触及你的真实数据。
架构
memory_mcp/
server.py # FastMCP entry point, lifespan manages DB + startup scan
config.py # Auto-detects session dirs, DB path
db.py # SQLite + FTS5 schema, all queries, sync triggers
scanner.py # Walks session dirs, dispatches to parsers, parallel indexing
parsers/
base.py # ParsedSession / ParsedMessage dataclasses, SessionParser protocol
claude_code.py # Claude Code JSONL parser (merges streamed assistant blocks)
claude_history.py # Claude Code history.jsonl parser (one file, many sessions)
omp.py # OMP JSONL parser
opencode.py # OpenCode SQLite parser (reads DB directly, read-only)
tools/
memory.py # save_memory, search_memory, list_memories, delete_memory
sessions.py # list_sessions, get_session, search_sessions, refresh_sessions许可证
MIT
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
- -licenseNot gradedqualityNot gradedmaintenanceProvides persistent local memory functionality for AI assistants, enabling them to store, retrieve, and search contextual information across conversations with SQLite-based full-text search. All data stays private on your machine while dramatically improving context retention and personalized assistance.3
- AlicenseNot gradedqualityNot gradedmaintenanceProvides AI coding agents with persistent, long-term memory through local semantic search and SQLite storage. It enables agents to save and retrieve architectural decisions or project context across different conversation sessions without requiring cloud services.
- AlicenseNot gradedqualityCmaintenanceProvides AI coding assistants with persistent project memory to retain architectural decisions, code patterns, and domain knowledge across sessions. It stores data locally in a SQLite database, allowing agents to remember, recall, and manage project-specific context using full-text search.8Apache 2.0
- AlicenseAqualityBmaintenanceProvides AI coding assistants with persistent memory storage using a local SQLite database. Enables tools to remember project details, notes, and relationships across sessions to maintain context and reduce repetitive explanations.174MIT
Related MCP Connectors
Persistent memory for AI agents. Search, store, and recall across sessions.
Persistent memory for AI agents — verbatim conversations, searchable by meaning.
Universal memory for AI agents and tools. Save, organize and search context anywhere.
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/nerdyaustin/memory_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server