A persistent memory MCP server for Claude Code that remembers decisions, preferences, and context across conversation boundaries.
"I use the Pensieve. One simply siphons the excess thoughts from one's mind, pours them into the basin, and examines them at one's leisure." — Albus Dumbledore
When Claude Code conversations are compacted or cleared:
- Agent "forgets" discovered patterns, decisions, and understanding
- User re-explains the same context repeatedly
- Agent may hallucinate or contradict previous decisions
- Momentum lost every few hours of deep work
Pensieve provides persistent storage via SQLite that Claude can access through native tool calls:
pensieve_remember— Save decisions, preferences, discoveries, entitiespensieve_recall— Query the knowledge basepensieve_session_start— Load context at conversation startpensieve_session_end— Persist learnings before ending
claude mcp add pensieve npx @esparkman/pensieveThat's it! Restart Claude Code and the tools are available.
# Clone the repository
git clone https://github.com/esparkman/pensieve.git ~/Development/pensieve
cd ~/Development/pensieve
# Install dependencies and build
npm install
npm run build
# Add to Claude Code
claude mcp add pensieve node ~/Development/pensieve/dist/index.js# Clone the repository
git clone https://github.com/esparkman/pensieve.git
cd pensieve
# Build the Docker image
docker build -t pensieve .
# Add to Claude Code (mount your project for local database)
claude mcp add pensieve docker run -i --rm \
-v "$PWD/.pensieve:/app/.pensieve" \
-v "$HOME/.claude-pensieve:/root/.claude-pensieve" \
pensieveNote: The Docker approach mounts two volumes:
$PWD/.pensieve— Project-local database (if in a git repo)$HOME/.claude-pensieve— Global fallback database
After installing, restart Claude Code and check that Pensieve is loaded:
# In a new Claude Code session, the tools should be available:
# pensieve_status, pensieve_remember, pensieve_recall, etc.After installing, Claude Code will have access to these tools:
At the beginning of each conversation, Claude should call:
pensieve_session_start()
This loads the last session's summary, work in progress, key decisions, and preferences.
pensieve_remember({
type: "decision",
topic: "authentication",
decision: "Use Devise with magic links",
rationale: "Passwordless is more secure and user-friendly"
})
pensieve_remember({
type: "preference",
category: "testing",
key: "approach",
value: "system tests for UI flows"
})
pensieve_remember({
type: "entity",
name: "Customer",
description: "End user who places orders",
relationships: '{"belongs_to": ["Tenant"], "has_many": ["Orders"]}'
})
pensieve_remember({
type: "discovery",
category: "component",
name: "ButtonComponent",
location: "app/components/base/button_component.rb",
description: "Primary button component with variants"
})
pensieve_recall({ query: "authentication" })
pensieve_recall({ type: "preferences" })
pensieve_recall({ type: "entities" })
pensieve_recall({ type: "session" })
pensieve_recall({ type: "questions" })
Before ending a conversation:
pensieve_session_end({
summary: "Completed invoice list component with filtering",
work_in_progress: "Invoice detail view partially designed",
next_steps: "Complete detail view, add PDF export",
key_files: ["app/components/invoices/invoice_list_component.rb"],
tags: ["invoices", "ui"]
})
Pensieve stores data in SQLite:
- Project-local (if
.gitor.pensieveexists):.pensieve/memory.sqlite - Global (fallback):
~/.claude-pensieve/memory.sqlite
This means each project gets its own memory, but you also have a global memory for general preferences.
Set PENSIEVE_DB_PATH to explicitly specify the database location:
PENSIEVE_DB_PATH=/custom/path/memory.sqlite claude mcp add pensieve ...Pensieve automatically detects and refuses to store potential secrets including:
- API keys (AWS, GitHub, Stripe, etc.)
- Database connection strings with passwords
- Bearer tokens and private keys
- Credit card numbers and SSNs
If a secret is detected, the data is NOT saved and a warning is displayed.
To prevent unbounded growth:
- Decisions: Max 1,000 (oldest auto-pruned)
- Discoveries: Max 500 (oldest auto-pruned)
- Sessions: Older than 90 days auto-deleted
- Field length: Max 10KB per field (truncated with warning)
Data is stored in plaintext SQLite. Do NOT store:
- Passwords or API keys
- Personal identifying information
- Financial credentials
- Any sensitive secrets
The database is local-only and never transmitted over the network.
| Tool | Purpose |
|---|---|
pensieve_remember |
Save decisions, preferences, discoveries, entities, or questions |
pensieve_recall |
Query the knowledge base |
pensieve_session_start |
Start a session and load prior context |
pensieve_session_end |
End a session and save a summary |
pensieve_resolve_question |
Mark an open question as resolved |
pensieve_status |
Get database location and counts |
Important choices with rationale. Searchable by topic.
User conventions (coding style, testing approach, naming patterns).
Things found in the codebase (components, patterns, helpers).
Domain model understanding (models, relationships, attributes).
Summaries of work sessions for continuity.
Unresolved blockers or questions to address.
cd ~/Development/pensieve
npm install
npm run dev # Run with tsx for development
npm run build # Build TypeScriptMIT