freshcrate
Home > MCP Servers > m3-memory

m3-memory

Local-first Agentic Memory Layer for MCP Agents • 25 tools • Hybrid search (FTS5 + vector + MMR) • GDPR • 100% local

Description

Local-first Agentic Memory Layer for MCP Agents • 25 tools • Hybrid search (FTS5 + vector + MMR) • GDPR • 100% local

README

M3 Memory — Local-First Agentic Memory for MCP Agents

GitHub StarsDiscordPyPI versionDownloads Python 3.11+ License: MIT MCP 25 tools CI Platform

Your AI agents finally remember things between sessions.

Persistent, private memory for MCP agents. Runs entirely on your hardware.
No cloud. No API keys. No subscriptions.

Claude CodeGemini CLIAiderOpenClaw

  • Quick Start
  • Let Your Agent Install It
  • The Problem
  • With M3 Memory
  • The Moment It Clicks
  • Who This Is For
  • Use Cases
  • Features
  • Core Tools
  • How It Compares
  • Architecture
  • See It in Action
  • Documentation
  • Community
  • Roadmap
  • Contributing

  • Quick Start (<1 minute)

    Prerequisites: Python 3.11+ and Ollama (or any OpenAI-compatible embedding endpoint).

    ollama pull nomic-embed-text && ollama serve
    pip install m3-memory

    Add to your MCP config (~/.claude/settings.json, ~/.gemini/settings.json, etc.):

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

    Restart your agent. It now has memory. Done.


    Let Your Agent Install It

    Already inside Claude Code, Gemini CLI, or Aider? Paste one of these prompts and let the agent set it up for you:

    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 nomic-embed-text. 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 nomic-embed-text.
    

    Aider / Any MCP agent:

    Install m3-memory for persistent memory. Run: pip install m3-memory
    Then add {"mcpServers":{"memory":{"command":"mcp-memory"}}} to the
    MCP config file for this agent. Make sure Ollama is running with
    nomic-embed-text.
    

    After install, test it:

    Write a memory: "M3 Memory installed successfully on [today's date]"
    Then search for: "M3 install"
    

    The Problem

    Every new session, your AI agent has amnesia. It forgets your project structure, your preferences, the decisions you made together yesterday. You paste the same context. You re-explain the same architecture. You correct the same mistakes.

    When facts change — a port number, a dependency version — there's no mechanism to update what the agent "knows." Contradictions accumulate silently until something breaks.

    With M3 Memory

    Your agents remember. Architecture decisions, server configs, debugging history, your preferences — all searchable, all persistent across sessions and devices.

    When facts change, M3 detects the contradiction, updates the record, and preserves the full history. No stale data. No manual cleanup. You just talk to your agent, and it knows what it should know.


    The Moment It Clicks

    Session You say Agent response
    Session 1 "Our API server runs on port 8080." Stored.
    Session 2 (3 days later) "We moved the API to port 9000." Contradiction detected. Updated. History preserved.
    Session 3 (a week later) "What port is the API on?"

    Without M3: "I don't have that information. Could you tell me?"

    With M3: "Port 9000. (Updated from 8080 — change recorded March 12th.)"

    No prompts. No manual logic. Automatic contradiction resolution with full history.


    Who This Is For

    For you if... Not for you if...
    You use Claude Code, Gemini CLI, Aider, or any MCP agent You're building LangChain/CrewAI pipelines — see Mem0
    You want memory that survives across sessions + devices You want a full agent runtime — see Letta
    You prefer local-first: no cloud, no API costs, works offline You only need short-term chat context in a single session
    You care about privacy and data ownership

    Use Cases

    Coding agents Remember architecture decisions, configs, and debugging steps across sessions
    Personal assistants Persist user preferences, goals, and history long-term
    Dev workflows Track environment changes, server configs, and fixes automatically
    Multi-device setups Write a memory on your MacBook, pick it up on your Windows desktop — same knowledge graph, synced locally

    Features

    Hybrid Search

    Three-stage pipeline: FTS5 keyword matching, semantic vector similarity, and MMR diversity re-ranking. Better recall than vector-only search, especially for technical content with exact names and versions.

    Automatic Contradiction Detection

    Write conflicting information and M3 detects it automatically. The outdated memory is superseded via bitemporal versioning, a supersedes relationship is recorded, and the full history is preserved.

    Bitemporal History

    Query as_of="2026-01-15" to see exactly what your agent believed on any past date. Every change is tracked with both the time the fact was true and the time it was recorded.

    Knowledge Graph

    Related facts are linked on write when cosine similarity exceeds 0.7. Eight relationship types (related, supports, contradicts, extends, supersedes, references, consolidates, message). Traverse up to 3 hops with memory_graph.

    Cross-Device Sync

    Bi-directional delta sync across SQLite, PostgreSQL, and ChromaDB. Write on your MacBook, continue on your Windows desktop. No cloud intermediary.

    GDPR Built-In

    gdpr_forget (Article 17 — Right to Erasure) and gdpr_export (Article 20 — Data Portability) as native MCP tools.

    Fully Local + Private

    Local embeddings via Ollama, LM Studio, or any OpenAI-compatible endpoint. Zero cloud calls. Zero API costs. Works completely offline.

    Self-Maintaining

    Automatic decay, expiry purging, orphan pruning, deduplication, and retention enforcement. Old memories consolidate into LLM-generated summaries.


    Core Tools

    Start with three — memory_write, memory_search, and memory_update — that covers 90% of daily use. The rest is there when you need it.

    Tool What it does
    memory_write Store a memory — facts, decisions, preferences, configs, observations
    memory_search Retrieve relevant memories using hybrid search
    memory_suggest Same as search, with full score breakdown (vector, BM25, MMR)
    memory_get Fetch a specific memory by ID
    memory_update Refine existing knowledge — content, title, metadata, importance

    Full list of all 25 tools


    How It Compares

    Feature M3-Memory Mem0 Letta LangChain Memory
    Local-first āœ… 100% āš ļø partial āœ… good āš ļø partial
    MCP native āœ… 25 tools āš ļø wrappers āš ļø indirect āŒ no
    Contradiction handling āœ… automatic āš ļø LLM-based āš ļø agent-driven āš ļø manual
    GDPR tools āœ… built-in āš ļø supported āš ļø via tools āŒ custom
    Cross-device sync āœ… built-in āš ļø limited āš ļø git-based āš ļø limited
    Setup āœ… 1 line āš ļø SDK needed āŒ full runtime āŒ framework only
    Cost āœ… free, MIT āš ļø $249/mo Pro āš ļø OSS + SaaS āœ… free

    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
    
    Loading
    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>
    
    Loading

    See It in Action

    Contradiction Resolution

    Agent writes two conflicting facts — the old one is automatically superseded:

    Demo: automatic contradiction detection and resolution

    Hybrid Search with Score Breakdown

    FTS5 keyword + semantic vector + MMR diversity re-ranking — with full explainability:

    Demo: hybrid search with FTS5, vector, and MMR score breakdown

    Cross-Device Sync

    Write a memory on your MacBook, search it on your Windows desktop — no cloud:

    Demo: cross-device memory sync between MacBook and Windows

    Have a real recording to share? See CONTRIBUTING.md or post in #showcase on Discord.


    Documentation

    File Purpose
    QUICKSTART.md New here? Start here
    CORE_FEATURES.md Feature overview
    ARCHITECTURE.md Full system internals + all 25 MCP tools
    TECHNICAL_DETAILS.md Search pipeline, schema, sync, security
    COMPARISON.md M3 vs Mem0 vs Letta vs LangChain vs Zep
    ENVIRONMENT_VARIABLES.md Config and credential setup
    ROADMAP.md Upcoming milestones
    CHANGELOG.md Release history
    CONTRIBUTING.md How to contribute
    GOOD_FIRST_ISSUES.md Good first issues

    Community

    DiscordGet help, share your setup, and follow development. M3_Bot is live — use !ask <question> in any channel.


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

    Vote on features in ROADMAP.md


    Project Structure

    bin/          MCP bridge, core engine, sync, and maintenance scripts
    m3_memory/    Python package — CLI entry point (mcp-memory)
    memory/       SQLite database and migrations
    docs/         Architecture diagrams and install guides
    examples/     Demo notebooks and ready-to-paste mcp.json configs
    tests/        End-to-end test suite (41 tests)
    

    Next Steps

    1. Star the repo — helps others find it
    2. Try a real session — install, write a memory, close your agent, reopen it, and search
    3. Share feedback — what worked, what didn't
    4. Open an issue — bugs, questions, feature requests
    5. Contribute — good first issues listed

    Contributing

    See CONTRIBUTING.md | Good first issues: GOOD_FIRST_ISSUES.md


    Star History Chart

    Your AI should remember. Your data should stay yours.

    M3 Memory: the foundation for agents that don't forget.

    Release History

    VersionChangesUrgencyDate
    v2026.4.20## Fixes - Resolve SQLite deadlock in `memory_consolidate` via connection reuse in `memory_link_impl` - Resolve database contention and sync hangs on large DBs (migration timeout bump, SAVEPOINT-wrapped pg_sync, VACUUM skip for >500MB DBs, WAL contention fix in `record_history`) ## Features - `memory_search` gains `recency_bias` (float) and `adaptive_k` (bool) params - `conversation_search` auto-pairs user turns with adjacent assistant replies (0.85x score) - `precedes` / `follows` added to `VAHigh4/17/2026
    v2026.4.6## What's New M3 Memory is a local-first agentic memory layer for MCP agents — 25 tools, hybrid search (FTS5 + vector + MMR), contradiction detection, cross-device sync, GDPR-ready, 100% local. ## Install ```bash pip install m3-memory ``` Or clone for development: ```bash git clone https://github.com/skynetcmd/m3-memory.git cd m3-memory pip install -r requirements.txt ``` ## Highlights - **25 MCP tools** — write, search, link, graph, verify, sync, export, and more - **Hybrid search** — FTHigh4/10/2026

    Dependencies & License Audit

    Loading dependencies...

    Similar Packages

    zotero-mcp-litešŸš€ Run a high-performance MCP server for Zotero, enabling customizable workflows without cloud dependency or API keys.main@2026-04-21
    spoon-awesome-skillšŸš€ Explore high-quality skills for SpoonOS, Web3, AI productivity, and enterprise tooling with 57+ curated Python scripts across multiple challenge tracks.master@2026-04-21
    antigravity-awesome-skills🌌 Explore 255+ essential skills for AI coding assistants like Claude Code and GitHub Copilot to enhance your development workflow.main@2026-04-21
    sqltools_mcpšŸ”Œ Access multiple databases seamlessly with SQLTools MCP, a versatile service supporting MySQL, PostgreSQL, SQL Server, DM8, and SQLite without multiple servers.main@2026-04-21
    claude-copilotTransform Claude Code into a full development team. 11 specialized agents (Architect, Engineer, QA, Security, UX, DevOps, and more), persistent memory across sessions, and 25,000+ on-demand skills. Wov2.10.0