Memory MCP

Memory MCP

Provides persistent cross-session memory and full-text search for AI coding assistants, storing project context, decisions, and preferences while enabling searchable access to conversation history via local SQLite.

Category
访问服务器

README

Memory MCP

Persistent memory and full-text session search for AI coding assistants, exposed as an MCP server.

The problem

AI coding assistants forget everything between sessions. Architecture decisions, user preferences, project context, what you debugged last Tuesday -- gone. You re-explain the same things constantly.

Memory MCP fixes this with two capabilities:

  1. Explicit memory -- save notes, decisions, patterns, and preferences that persist across sessions. Your assistant remembers what you told it.
  2. Session search -- full-text search across your entire conversation history. Find that thing you discussed three weeks ago without scrolling through logs.

No database servers. No background processes. No cloud. One SQLite file on your machine.

Supported session sources

Source Location Format
Claude Code ~/.claude/projects/ JSONL (streamed content blocks)
Claude Code history ~/.claude/history.jsonl JSONL (survives session file pruning)
OpenCode ~/.local/share/opencode/opencode.db SQLite (sessions, messages, parts tables)
Oh My Pi ~/.omp/agent/sessions/ JSONL (event-per-line)

Adding a new source requires one parser file and a registry entry. See Adding a new source.

Installation

Requires Python 3.11+ with SQLite FTS5 support (included in standard Python builds).

pip install -e .

Or run directly with uv (no install needed):

uv run --directory /path/to/memory_mcp python -m memory_mcp

MCP configuration

Add to your MCP client config (e.g., ~/.claude/mcp.json or project-level .mcp.json):

With pip install:

{
  "mcpServers": {
    "memory": {
      "command": "memory-mcp"
    }
  }
}

With uv (no install):

{
  "mcpServers": {
    "memory": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/memory_mcp", "python", "-m", "memory_mcp"]
    }
  }
}

Tools

Memory (explicit knowledge store)

Tool Description
save_memory Persist a note with optional tags and context. Survives across all future sessions.
search_memory Full-text search across saved memories. Keyword-based, ranked by relevance.
list_memories Browse recent memories, optionally filtered by tag.
delete_memory Remove a memory by ID.

Sessions (historical conversation search)

Tool Description
list_sessions Browse past sessions. Filter by source (claude_code, omp) or project path.
get_session Retrieve the full conversation from a specific session.
search_sessions Full-text search across all session messages, thinking blocks, and tool usage.
refresh_sessions Re-scan session directories and index new or changed files.

How it works

On startup, Memory MCP scans configured session directories and indexes every conversation into a local SQLite database with FTS5 full-text search indexes. Subsequent startups skip files whose mtime hasn't changed.

  • Database location: ~/.memory_mcp/memory.db (override with MEMORY_MCP_DB env var)
  • Session sources: auto-detected from standard locations (extend with MEMORY_MCP_SOURCES env var, format: type:path;type:path)
  • Indexing: incremental by file mtime, parallelized across 8 threads
  • Search: FTS5 with BM25 ranking, prefix matching, phrase support

Adding a new session source

  1. Create memory_mcp/parsers/your_source.py implementing the SessionParser protocol:
    • source_type: str attribute
    • parse_file(path: str) -> ParsedSession | None method
  2. Register it in memory_mcp/parsers/__init__.py
  3. Add directory detection in memory_mcp/config.py

See parsers/claude_code.py or parsers/omp.py for examples.

Testing

python tests/test_e2e.py

The end-to-end test starts the MCP server as a subprocess, exercises all 8 tools over the stdio protocol, and asserts tool responses. Uses a throwaway database so your real data is untouched.

Architecture

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

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选