claude-memory-mcp
Local, Persistent Memory for Any MCP-Compatible AI A lightweight, zero-cloud, token-efficient Model Context Protocol (MCP) server that gives your AI durable, searchable, and context-aware memory - entirely under your control.
Built with TypeScript, SQLite + FTS5, and minimal runtime dependencies (MCP SDK + better-sqlite3), it runs locally and stores everything in a single, portable .db file.
Works with Claude Desktop, Cursor, Windsurf, or any MCP client.
📦 Now available on npm: Install with npx @whenmoon-afk/memory-mcp
Why Local Memory?
You Control | Cloud Services |
Data never leaves your machine | Sent to remote servers |
Portable
file | Locked in proprietary storage |
Full audit & backup | Opaque retention policies |
Zero recurring cost | Subscription required |
Related MCP server: ClaudeKeep
Features
Feature | Benefit |
Dual-Response Pattern | Returns all matches (compact index) + full details within token budget |
Token Budgeting | Auto-respects
(~30% index, ~70% details) |
Hybrid Relevance Scoring | 40% relevance, 30% importance, 20% recency, 10% frequency |
Auto-Summarization | Generates ≤20-word natural-language summaries |
Entity Extraction | Detects people, tools, concepts, preferences |
FTS5 Full-Text Search | Sub-10ms queries, Unicode, stemming — no embeddings |
Provenance Tracking | Full audit trail: source, timestamp, updates |
Soft Deletes | Memories preserved for debugging/rollback |
Single-File DB |
— copy, backup, move freely |
Installation
Prerequisites
Node.js ≥ 18
An MCP-compatible client (Claude Desktop, Cursor, Windsurf, etc.)
Option 1: NPM Package with Auto-Setup (Recommended)
Automatic installation (configures Claude Desktop for you):
This will automatically:
Detect your operating system (macOS/Windows/Linux)
Add the memory server to your Claude Desktop configuration
Create a backup of your existing config
Configure the correct command format for your platform
After installation, restart Claude Desktop completely (quit and reopen).
Or install globally:
Option 2: From Source
For development or customization:
Output:
dist/index.js— your memory server.
Claude Code Installation
For users of Claude Code (terminal-based Claude), use the claude mcp add command:
Recommended (user-wide installation):
Alternative (direct node invocation, more reliable, no npx):
Per-Project Memory (project-specific, stored in project directory):
Verify installation:
Note: The server automatically uses platform-appropriate database location. Both Claude Desktop and Claude Code will share the same memory database by default.
Tip: Use
--scope userfor personal knowledge that spans projects. Use--scope localwithMEMORY_DB_PATH=./memory.dbfor codebase-specific context that stays with the repository.
Docker Deployment
Run the Memory MCP server in a containerized environment with persistent storage.
Prerequisites
Docker installed (Get Docker)
Docker Compose (included with Docker Desktop)
Quick Start with Docker Compose
1. Clone the repository:
2. Start the container:
This will:
Build the Docker image with Node.js 20
Create a persistent volume at
./data/for the databaseStart the MCP server in detached mode
3. View logs:
4. Stop the container:
Manual Docker Build
Build the image:
Run the container:
Interact with the running container:
Volume Persistence
The database is stored in a Docker volume mapped to ./data/ on your host:
Location | Path |
Host |
|
Container |
|
To backup your database:
To restore from backup:
Environment Variables (Docker)
Configure via docker-compose.yml or -e flags:
Variable | Default | Description |
|
| Database file location inside container |
|
| Default memory expiration (days) |
|
| Database driver (better-sqlite3 or sqljs) |
|
| Node environment |
Docker Notes
No HTTP Port: This is a stdio-based MCP server. Communication happens via stdin/stdout, not HTTP requests.
Native Dependencies: Uses multi-stage build to compile better-sqlite3 native bindings
Resource Limits: Default docker-compose.yml sets 512MB memory limit (adjustable)
Auto-restart: Container restarts automatically unless explicitly stopped
Using with MCP Clients
When running in Docker, you'll need to configure your MCP client to communicate with the containerized server. The exact method depends on your client:
For local development: Use
docker execto run commandsFor production: Consider using a container orchestration platform (Kubernetes, ECS, etc.)
Tip: For most use cases, the NPM package installation (Option 1) is simpler and more suitable than Docker, since MCP servers typically run locally and communicate directly with the AI client via stdio.
Integrate with Your MCP Client
Add to your client's MCP config file:
Claude Desktop:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Cursor/Windsurf: Check your editor's MCP settings
💡 Recommended: Use the automatic installer (
npx @whenmoon-afk/memory-mcp) which handles platform differences automatically.
Manual Configuration (macOS/Linux)
Manual Configuration (Windows)
Windows requires the to execute npx properly:
Using Global Install
From Source
Restart or reload MCP servers.
MCP Tools
Tool | Input | Description |
|
| Store or update memory with auto-summary |
|
| Search memories with token-aware loading |
|
| Soft-delete memory (preserves provenance) |
Store a Preference
→ Auto-creates:
Summary:
"User follows 90/15 focused work cycles."Entities:
focused work,90-minute blocksProvenance: current session
Smart Recall (Dual-Response)
Response:
Your AI knows what it knows — and can ask for more.
Forget a Memory
Response:
Soft-deleted memories are preserved in the database with full provenance trail. They won't appear in searches but remain recoverable.
Dual-Response Pattern
Index: Always included → discovery
Details: Budget-safe → precision
Follow-up: Use
ids: [...]to expand
Database & Portability
File:
memory.db(SQLite) — path viaMEMORY_DB_PATHPortable: Copy to USB, cloud sync, or new machine
Backup: Just copy the file
Tip: For extra security, store
memory.dbon a VeraCrypt Encrypted USB drive (adds friction, but maximum control).
Dependencies
This project uses minimal runtime dependencies to keep the package lightweight:
Dependency | Version | Purpose |
| ^1.0.4 | Official MCP protocol implementation |
| ^11.0.0 | Fast, native SQLite3 bindings with FTS5 support |
Why these dependencies?
MCP SDK: Required for implementing the Model Context Protocol standard
better-sqlite3: Native performance for full-text search and database operations, essential for memory recall speed
All other dependencies are dev-only (TypeScript, testing, linting).
Environment Variables
Variable | Default | Description |
| Platform-specific* | Database file location |
|
| Database driver (
or
) |
|
| Default time-to-live for memories (days) |
*Default database locations (when installed via npx):
macOS:
~/.claude-memories/memory.dbWindows:
%APPDATA%\claude-memories\memory.dbLinux:
~/.local/share/claude-memories/memory.db
Security
This is a local-only MCP server.
Data is stored in a plain SQLite file (memory.db).
For sensitive data, use OS-level encryption (FileVault, BitLocker).
Best Practices
Start with — adjust per model and task.
Filter by to reduce noise and improve relevance.
Use entity filtering to narrow searches to specific topics.
Reference provenance: Track source and context for audit trails.
Backup regularly — it's just a file!
Quick Links
📦 NPM Package: https://www.npmjs.com/package/@whenmoon-afk/memory-mcp
🐙 GitHub Repository: https://github.com/WhenMoon-afk/claude-memory-mcp
🐛 Report Issues: https://github.com/WhenMoon-afk/claude-memory-mcp/issues
📖 MCP Documentation: https://modelcontextprotocol.io
Contributing
Contributions are welcome! Feel free to:
Report bugs or request features via GitHub Issues
Submit pull requests for improvements
Share your use cases and feedback
License
MIT License - see LICENSE file for details.
Copyright (c) 2025 WhenMoon-afk
Built with ❤️ for the MCP community