MCP Hub
Back to servers

M3 Memory

Local-first agentic memory for MCP agents — 25 tools, hybrid search, GDPR, no cloud.

Registry
Stars
3
Updated
Apr 11, 2026
Validated
Apr 12, 2026

Quick Install

uvx m3-memory

🧠 M3 Memory — Local-First Agentic Memory for MCP Agents

M3 Memory Logo

GitHub Stars GitHub Forks Discord

PyPI version PyPI downloads Python 3.11+ License: MIT MCP 25 tools CI Platform

The privacy-first, MCP-native memory layer for desktop coding agents — automatic contradiction detection, hybrid search, and built-in GDPR compliance. 100% local. Zero cloud.


Try it in 60 seconds

pip install m3-memory

Add one line to your agent's MCP config:

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

That's it. Claude Code, Gemini CLI, and Aider now have persistent, private memory.


Table of Contents


Why M3 Memory?

Most agent memory tools make you choose: local speed or cloud persistence or MCP compatibility. M3 Memory gives you all three — running entirely on your hardware with no external API calls.

You're debugging a deployment issue at a coffee shop. Claude Code recalls the architecture decisions from last week, the server configs from yesterday, and the troubleshooting steps that worked before — all from local SQLite, no internet required. Later, at your desktop at home, Gemini CLI picks up exactly where you left off. Same memories. Same knowledge graph. Synced the moment you hit the local network.

Your AI's memory belongs to you, lives on your hardware, and follows you across every device and every agent.

Why choose M3-Memory specifically?

🔒 100% local by defaultZero external APIs, zero token costs, works fully offline
🛠️ Native MCP — 25 toolsAuto-discovers in Claude Code & Gemini CLI with one config line
🚫 Automatic contradiction detectionBitemporal superseding — stale facts resolved without agent-side logic
Bitemporal historyQuery what your agent believed on any past date
🛡️ GDPR built-ingdpr_forget (Art. 17) + gdpr_export (Art. 20) as first-class MCP tools
🔄 Cross-device syncSQLite ↔ PostgreSQL ↔ ChromaDB, bi-directional delta sync
🪶 Ultra-lightweightDrop-in backend — no runtime migration, no framework lock-in

See It in Action

Demo 1 — Automatic contradiction resolution Demo: agent writes a fact, then a conflicting update — old memory auto-superseded with full history preserved Agent writes "server is on port 8080", then later "server is on port 9000" — M3 detects the conflict, supersedes the old memory, preserves full bitemporal history. No manual cleanup.

Demo 2 — Hybrid search across 1,000 memories Demo: memory_search returns FTS5 + vector + MMR ranked results with score breakdown FTS5 keyword match + vector similarity + MMR diversity re-ranking in a single pipeline. memory_suggest returns full score breakdown per result.

Demo 3 — Cross-device sync Demo: memory written on one machine appears on another via SQLite→PostgreSQL bidirectional sync Write on your laptop. Pick it up on your desktop. Bi-directional delta sync via PostgreSQL — crash-resistant, watermark-tracked.

GIFs coming soon — contribute a recording or watch the Discord for updates.

Star if you want local agents that remember — feedback & issues very welcome!


How It Compares

M3-Memory vs Mem0 vs Letta vs LangChain Memory

FeatureM3-MemoryMem0LettaLangChain Memory
TypeLightweight MCP memory layerUniversal memory SDKFull agent runtimeFramework memory
Best forMCP desktop agents (Claude Code, Aider, Gemini)LangChain/CrewAISelf-managing agentsLangGraph users
Local-first✅ 100% local, zero APIs⚠️ Self-hostable✅ Excellent (git)⚠️ Good
MCP native✅ 25 built-in tools⚠️ Wrappers only⚠️ Indirect❌ No
Contradiction✅ Automatic bitemporal⚠️ LLM-based⚠️ Agent self-editing⚠️ Manual/LLM
GDPR tools✅ Built-in (gdpr_forget + gdpr_export)⚠️ Supported⚠️ Via tools❌ Custom
Hybrid search✅ FTS5 + Vector + MMR⚠️ Vector + Graph⚠️ Hierarchical⚠️ Basic
Cross-device sync✅ Built-in bidirectional⚠️ Limited⚠️ Git-based⚠️ Limited
OverheadVery lightLightHigherMedium
Cost✅ Free, MIT⚠️ Free + $249/mo Pro⚠️ OSS + SaaS✅ OSS

Choose M3-Memory if you want the simplest, most private, MCP-native memory backend with automatic consistency and compliance — no framework lock-in.

Choose Mem0 for LangChain / LangGraph / CrewAI and managed cloud memory at scale.

Choose Letta for long-lived autonomous agents that self-edit memory within a full stateful runtime.

Choose LangChain Memory if you're already in the LangGraph ecosystem and want framework-native memory.

→ Full feature-by-feature breakdown: COMPARISON.md


Architecture

graph TD
    subgraph "🤖 AI Agents"
        C[Claude Code]
        G[Gemini CLI]
        A[Aider / OpenClaw]
    end

    subgraph "🌉 MCP Bridge"
        MB[memory_bridge.py — 25 MCP tools]
    end

    subgraph "💾 Storage Layers"
        SQ[(SQLite — Local L1)]
        PG[(PostgreSQL — Sync L2)]
        CH[(ChromaDB — Federated L3)]
    end

    C & G & A <--> MB
    MB <--> SQ
    SQ <-->|Bi-directional Delta Sync| PG
    SQ <-->|Push/Pull| CH

The Memory Write Pipeline

sequenceDiagram
    participant A as Agent
    participant M as M3 Memory
    participant L as Local LLM
    participant S as SQLite

    A->>M: memory_write(content)
    M->>M: Safety Check (XSS / injection / poisoning)
    M->>L: Generate Embedding
    L-->>M: Vector [0.12, -0.05, ...]
    M->>M: Contradiction Detection
    M->>M: Auto-Link Related Memories
    M->>M: SHA-256 Content Hash
    M->>S: Store Memory + Vector
    S-->>M: Success
    M-->>A: Created: <uuid>

Quick Start

Prerequisites

  • Python 3.11+
  • Any OpenAI-compatible local LLM server: LM Studio, Ollama, vLLM, LocalAI, llama.cpp
  • (Optional) PostgreSQL + ChromaDB for full cross-device federation

Install

Option A — pip (recommended):

pip install m3-memory
mcp-memory --version   # confirm the CLI is installed

Add to your agent's MCP config — no path needed:

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

Option B — clone (for development):

git clone https://github.com/skynetcmd/m3-memory.git
cd m3-memory
python -m venv .venv
source .venv/bin/activate        # macOS/Linux
# .\.venv\Scripts\Activate.ps1  # Windows PowerShell
pip install -r requirements.txt

Validate

python validate_env.py    # check all dependencies and LLM connectivity
python run_tests.py       # run the end-to-end test suite

Agent Config Locations

AgentConfig file
Claude Code~/.claude/claude_desktop_config.json or .mcp.json in project root
Gemini CLI~/.gemini/settings.json
Aider.aider.conf.yml (via --mcp-server flag)

For OS-specific setup: macOS · Linux · Windows

M3 Memory auto-discovers in Claude Code and other MCP clients via the MCP Registry. See mcp-server.json for the manifest.


Features

🔍 Hybrid Search That Actually Works

Three-stage pipeline — FTS5 keyword → semantic vector → MMR re-ranking — consistently outperforms pure vector search on technical queries. No more five near-identical results. Every result returns a full score breakdown (vector + BM25 + MMR penalty) via memory_suggest.

🚫 Automatic Contradiction Detection

Write a fact that conflicts with an existing one — M3 detects it automatically. The old memory is soft-deleted, a supersedes relationship is recorded, and the full history is preserved. No stale data. No manual cleanup. No agent-side logic required.

⏳ Bitemporal History

Track not just when a fact was stored, but when it was actually true. Query as_of="2026-01-15" to see what your agent believed on any past date — essential for compliance audits and debugging.

🕸️ Knowledge Graph

Memories auto-link on write (cosine > 0.7). Seven relationship types: related, supports, contradicts, extends, supersedes, references, consolidates. Traverse up to 3 hops with a single memory_graph call.

🧹 Self-Maintaining

Importance decay (0.5%/day after 7 days) · auto-archival (< 0.05 importance after 30 days) · per-agent retention (TTL + max count) · LLM consolidation (merges old groups into summaries) · deduplication (configurable cosine threshold)

🤖 Local LLM Intelligence

Works with any OpenAI-compatible server (LM Studio, Ollama, vLLM, LocalAI): auto-classification into 18 types · conversation summarization · multi-layered consolidation. Zero API costs. Zero data exfiltration.

🛡️ Security & Compliance

LayerProtection
CredentialsAES-256 vault (PBKDF2, 600K iterations) · OS keyring · zero plaintext
ContentSHA-256 signing on every write · tamper detection via memory_verify
InputRejects XSS, SQL injection, Python injection, prompt injection at write boundary
SearchFTS5 operator sanitization prevents query injection
NetworkCircuit breaker (3-failure threshold) · strict timeouts · tokens never logged

GDPR built-in: gdpr_forget (Article 17 — hard delete) · gdpr_export (Article 20 — portable JSON)

🔄 Cross-Device Sync

Bi-directional delta sync: SQLite ↔ PostgreSQL (UUID-based UPSERT, watermark-tracked, crash-resistant) + ChromaDB federation for distributed vector search across LAN. Hourly automated; manual via chroma_sync tool.


25 MCP Tools

CategoryTools
Memory Opsmemory_write, memory_search, memory_suggest, memory_get, memory_update, memory_delete, memory_verify
Knowledge Graphmemory_link, memory_graph, memory_history
Conversationsconversation_start, conversation_append, conversation_search, conversation_summarize
Lifecyclememory_maintenance, memory_dedup, memory_consolidate, memory_set_retention, memory_feedback
Data Governancegdpr_export, gdpr_forget, memory_export, memory_import
Operationsmemory_cost_report, chroma_sync

Documentation

FilePurpose
CORE_FEATURES.mdFeature overview — start here
ARCHITECTURE.mdAgent instruction manual: all 25 MCP tools, protocols, usage rules
TECHNICAL_DETAILS.mdDeep-dive: storage internals, search pipeline, schema, sync, security
ENVIRONMENT_VARIABLES.mdSecurity configuration and credential setup
COMPARISON.mdFull feature-by-feature comparison vs Mem0, Letta, LangChain Memory, Zep
ROADMAP.mdUpcoming milestones and community voting
CHANGELOG.mdRelease history
CONTRIBUTING.mdHow to contribute, run tests, submit changes

Community

Discord

ChannelPurpose
#start-hereNew? Start here — overview & quick links
#ask-anythingSetup help, config questions, how-tos
#bug-reportsReport issues with steps to reproduce
#showcaseShare your M3-Memory setups and demos
#search-qualityHybrid search tuning & benchmarks
#sync-federationMulti-device sync & ChromaDB federation
#memory-designArchitecture discussions & research

M3_Bot is live — mention @M3_Bot or use !ask <question> in any channel to query the documentation directly.


Roadmap

MilestoneHighlights
v0.2Docker image · auto MCP Registry · mcp-memory CLI polish
v0.3Local web dashboard · Prometheus metrics · search explain mode
v0.4Multi-agent shared namespaces · P2P encrypted sync
v1.0Public benchmark suite · stable Python SDK · full docs site

Vote on features and propose new ones → ROADMAP.md


Contributing

See CONTRIBUTING.md for how to get started, run the test suite, and submit changes. Good first issues: GOOD_FIRST_ISSUES.md.


Project Structure

bin/          Core MCP bridges, SDK, and automation scripts
memory/       SQLite database and migration logic
config/       Configuration templates for agents and shell
docs/         Architecture diagrams, API reference, and OS install guides
examples/     Demo notebooks, mcp.json snippets, benchmark scripts
scripts/      Maintenance and utility scripts
tests/        End-to-end test suite (41 tests)

Production Release — v2026.4.8 · MIT License · Changelog


Star History Chart

M3 Memory: the industrial-strength foundation for agents that remember.

Reviews

No reviews yet

Sign in to write a review