memory-mcp — Claude Code MCP server: what it does, how to install
Saves project context and architectural choices to local files while creating automatic git snapshots during sessions.
claude mcp add memory-mcp -- npx -y claude-code-memoryWhat memory-mcp does
The server hooks into Claude Code lifecycle events to process conversation transcripts through Haiku. It strips duplicates using Jaccard similarity, logs decisions into .memory/state.json, and condenses vital points into CLAUDE.md. Storage stays entirely local.
During active chats, tools like memory_search or memory_ask query the deep history. Parallel to context capture, it commits working directory states into a dedicated git branch for quick rollback. This protects against destructive edits.
You need Node.js 18+ and an Anthropic API key for background extraction. Without valid Anthropic API credentials, the extraction pipeline fails silently.
What it helps with
- preserve architecture decisions across coding sessions
- query past implementation choices via search tools
- revert files to automated git snapshots
- prune outdated session notes automatically
Example prompts for the agent
- Search memory to recall why we picked PostgreSQL over Redis.
- Check project history to see what was left unfinished yesterday.
- Query memory tools for previous authentication pattern decisions.
How to install memory-mcp
Platform CLI
claude mcp add memory-mcp -- npx -y claude-code-memoryPlatform CLI
codex mcp add memory-mcp -- npx -y claude-code-memoryConfig file
{
"mcpServers": {
"memory-mcp": {
"command": "npx",
"args": [
"-y",
"claude-code-memory"
]
}
}
}Config file
{
"servers": {
"memory-mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"claude-code-memory"
]
}
}
}Platform CLI
gemini mcp add memory-mcp npx -y claude-code-memoryStep by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about memory-mcp
How to install memory-mcp in Claude Code?
Run claude mcp add memory-mcp -- npx -y claude-code-memory. Then complete initial hook configuration in your shell using memory-mcp setup.
What does memory-mcp do?
It captures architectural decisions into a two-tier storage system, keeping short summaries inside CLAUDE.md. It also creates automatic git commits on a hidden branch.
Do I need a separate API key for memory extraction?
Yes, background extraction relies on Haiku and requires an Anthropic API key. You can store it by running memory-mcp setup or memory-mcp key.