Local-first persistent memory for MCP agents — 46 tools, 89% LongMemEval, hybrid search, GDPR, zero cloud
Project description
M3 Memory
Persistent, local memory for MCP agents.
Your agent forgets everything between sessions. M3 Memory fixes that. Install it, add one line to your MCP config, and your agent remembers across sessions, detects contradictions, and keeps its own knowledge current — all on your hardware, fully offline.
Works with Claude Code, Gemini CLI, Aider, OpenCode, and any MCP-compatible agent.
📦 Install
pip install m3-memory
Add to your MCP config:
{
"mcpServers": {
"memory": { "command": "mcp-memory" }
}
}
Requires a local embedding model. Ollama is the easiest:
ollama pull qwen3-embedding:0.6b && ollama serve
Qwen3-Embedding-0.6B (1024-dim, Q8 quantized, ~639 MB) is the default model M3 Memory is tuned for. nomic-embed-text (768-dim) also works — set EMBED_MODEL=nomic-embed-text in your environment.
Prefer a GUI? LM Studio works too — load any embedding model and start its server (defaults to port 1234).
Restart your agent. Done.
🔮 What happens next
You're at a coffee shop on your MacBook, asking Claude to debug a deployment issue. It remembers the architecture decisions you made last week, the server configs you stored yesterday, and the troubleshooting steps that worked last time — all from local SQLite, no internet required.
Later, you're at your Windows desktop at home with Gemini CLI, and it picks up exactly where you left off. Same memories, same context, same knowledge graph. You didn't copy files, didn't export anything, didn't push to someone else's cloud. Your PostgreSQL sync handled everything in the background the moment your laptop hit the local network.
💡 Why this exists
Most AI agents don't persist state between sessions. You re-paste context, re-explain architecture, re-correct mistakes. When facts change, the agent has no mechanism to update what it "knows."
M3 Memory gives agents a structured, persistent memory layer that handles this.
⚡ What it does
Persistent memory — facts, decisions, preferences survive across sessions. Stored in local SQLite.
Hybrid retrieval — FTS5 keyword matching + semantic vector similarity + MMR diversity re-ranking. Automatic, no tuning required.
Contradiction handling — conflicting facts are automatically superseded. Bitemporal versioning preserves the full history.
Knowledge graph — related memories linked automatically on write. Eight relationship types, 3-hop traversal.
Zero-config local install — pip install m3-memory, one line in your MCP config, done. SQLite stores everything locally — no external databases, no cloud calls, no API costs. Works offline.
Cross-device sync — optional, easy-to-add bi-directional delta sync via PostgreSQL or ChromaDB. Set one environment variable and your memories follow you across machines.
📚 Learn more
🎯 Who this is for
| Good fit | Not the right tool |
|---|---|
| You use Claude Code, Gemini CLI, Aider, or any MCP agent — plus non-MCP clients via the built-in HTTP proxy server | You need LangChain/CrewAI pipeline memory — see Mem0 |
| You're coordinating multiple agents on a shared local store | You need a hosted agent runtime with managed scaling — see Letta |
| You need GDPR primitives, bitemporal state, or pure SQLite | You want state-of-the-art retrieval benchmarks today — see Hindsight |
| You want memory that persists across sessions and devices | You only need in-session chat context |
🛡️ Why trust this
| 46 MCP tools | Memory, search, GDPR, refresh lifecycle — plus agent registry, handoffs, notifications, and tasks for multi-agent orchestration |
| 193 end-to-end tests | Covering write, search, contradiction, sync, GDPR, maintenance, and orchestration paths |
| Explainable retrieval | memory_suggest returns vector, BM25, and MMR scores per result |
| SQLite core | No external database required. Single-file, portable, inspectable |
| GDPR compliance | gdpr_forget (Article 17) and gdpr_export (Article 20) as built-in tools |
| Self-maintaining | Automatic decay, dedup, orphan pruning, retention enforcement |
| Apache 2.0 licensed | Free. No SaaS tier, no usage limits, no lock-in |
📊 Benchmarks
89.0% on LongMemEval-S (445/500 correct) — a 500-question evaluation of long-horizon conversational memory. Without oracle metadata: 74.8% (smart retrieval) to 68.0% (fixed-k baseline).
| Question type | n | Accuracy |
|---|---|---|
| single-session-user | 70 | 91.4% |
| single-session-assistant | 56 | 94.6% |
| single-session-preference | 30 | 93.3% |
| multi-session | 133 | 85.0% |
| temporal-reasoning | 133 | 86.5% |
| knowledge-update | 78 | 92.3% |
| Overall | 500 | 89.0% |
Full methodology, ablations, and honest caveats: benchmarks/longmemeval/README.md.
🧰 Core tools
Most sessions use three tools. The rest is there when you need it.
| Tool | Purpose |
|---|---|
memory_write |
Store a fact, decision, preference, config, or observation |
memory_search |
Retrieve relevant memories (hybrid search) |
memory_update |
Refine existing knowledge |
memory_suggest |
Search with full score breakdown |
memory_get |
Fetch a specific memory by ID |
All 45 tools are documented in AGENT_INSTRUCTIONS.md.
🤖 For AI agents
M3 Memory exposes 46 MCP tools for storing, searching, updating, and linking knowledge — including conversation grouping, a refresh lifecycle for aging memories, agent registry, handoffs, notifications, and tasks for multi-agent orchestration. Any MCP-compatible agent can use them automatically.
To teach your agent best practices (search before answering, write aggressively, update instead of duplicating), drop the compact rules file into your project:
examples/AGENT_RULES.md
Full tool reference with all parameters and behaviors: AGENT_INSTRUCTIONS.md
🪄 Let your agent install it
Already inside Claude Code or Gemini CLI? Paste one of these prompts:
Claude Code:
Install m3-memory for persistent memory. Run: pip install m3-memory
Then add {"mcpServers":{"memory":{"command":"mcp-memory"}}} to my
~/.claude/settings.json under "mcpServers". Make sure Ollama is running
with qwen3-embedding:0.6b. Then use /mcp to verify the memory server loaded.
Gemini CLI:
Install m3-memory for persistent memory. Run: pip install m3-memory
Then add {"mcpServers":{"memory":{"command":"mcp-memory"}}} to my
~/.gemini/settings.json under "mcpServers". Make sure Ollama is running
with qwen3-embedding:0.6b.
After install, test it:
Write a memory: "M3 Memory installed successfully on [today's date]"
Then search for: "M3 install"
🎬 See it in action
Contradiction detection
Hybrid search with scores
Cross-device, cross-platform sync
💬 Community
Contributing · Good first issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file m3_memory-2026.4.17.tar.gz.
File metadata
- Download URL: m3_memory-2026.4.17.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b61428d74213bbad38839f59ad2270144fe517d1d4c02855f0ab2262590a4fb6
|
|
| MD5 |
4d34328d73fd64dcbc253526d3d7d7e8
|
|
| BLAKE2b-256 |
69940378623d1955acdaacdcdae1ecaaf742b3d35b299400e97801bb370d6966
|
Provenance
The following attestation bundles were made for m3_memory-2026.4.17.tar.gz:
Publisher:
publish.yml on skynetcmd/m3-memory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
m3_memory-2026.4.17.tar.gz -
Subject digest:
b61428d74213bbad38839f59ad2270144fe517d1d4c02855f0ab2262590a4fb6 - Sigstore transparency entry: 1316963335
- Sigstore integration time:
-
Permalink:
skynetcmd/m3-memory@06f1cc707ba6fa281d7686d75458d3f35d59fa72 -
Branch / Tag:
refs/tags/v2026.4.17 - Owner: https://github.com/skynetcmd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06f1cc707ba6fa281d7686d75458d3f35d59fa72 -
Trigger Event:
release
-
Statement type:
File details
Details for the file m3_memory-2026.4.17-py3-none-any.whl.
File metadata
- Download URL: m3_memory-2026.4.17-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa97ad99935f32bafb5c1d4afce6941ef7867cbefaa69024e42ad2326f7dd704
|
|
| MD5 |
94c29bf39f92f402349056aa72c01ea2
|
|
| BLAKE2b-256 |
52e33bf8a0d33f79676091d010e1dae09ff04372503bef41b81d246847e983e6
|
Provenance
The following attestation bundles were made for m3_memory-2026.4.17-py3-none-any.whl:
Publisher:
publish.yml on skynetcmd/m3-memory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
m3_memory-2026.4.17-py3-none-any.whl -
Subject digest:
fa97ad99935f32bafb5c1d4afce6941ef7867cbefaa69024e42ad2326f7dd704 - Sigstore transparency entry: 1316963345
- Sigstore integration time:
-
Permalink:
skynetcmd/m3-memory@06f1cc707ba6fa281d7686d75458d3f35d59fa72 -
Branch / Tag:
refs/tags/v2026.4.17 - Owner: https://github.com/skynetcmd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06f1cc707ba6fa281d7686d75458d3f35d59fa72 -
Trigger Event:
release
-
Statement type: