M3 Memory
M3 Memory is a persistent, bitemporal, hybrid-search knowledge base MCP server for AI agents to store, retrieve, and manage memories, chat logs, files, tasks, and agents across sessions.
Memory Management
Store facts, preferences, and configurations with automatic contradiction detection and supersession (
memory_write)Hybrid semantic (vector) + keyword (BM25/FTS5) search with filtering by scope, type, user, and time (
memory_search)Retrieve by UUID or prefix (
memory_get), or explicitly replace memories while retaining history (memory_supersede)Bitemporal
as_ofqueries to reconstruct past system state
Chat Log Management
Append chat turns with full provenance (agent, model, provider, cost) via
chatlog_writeSearch logs by keyword, agent, model, provider, or time range (
chatlog_search)Health/status summary of the chat subsystem (
chatlog_status)
File Ingestion & Search
Ingest, chunk, and index files into corpora; search with hybrid FTS5+vector (
files_search)File-level summaries (
files_index), corpus statistics (files_stats), integrity checks (files_health), and corpus listing (files_corpus_list)
Agent & Task Tracking
List registered agents filtered by status/role (
agent_list)List tasks filtered by state, owner, or parent (
task_list)
Tool Discovery & Meta-Operations
Browse the full tool catalog (
m3_index), discover capabilities by domain or keyword (m3_help_capabilities)Dynamically load tool domains on demand (
tools_load_domain) โ only ~18 core tools load at startup to minimize token usageInvoke any catalog tool by name without pre-loading its domain, including batch calls up to 100 (
m3_call)
Key Features
Hybrid retrieval: vector similarity, BM25, MMR diversity, and reranking
Automatic contradiction resolution on write
Multi-database/multi-tenant support via a
databaseparameterSupports offline/air-gapped deployments with local embeddings; storage via SQLite or PostgreSQL/ChromaDB
Optionally uses Ollama to load a small chat model for auto-classification, summarization, and consolidation of memories.
Enables syncing memory data across devices using PostgreSQL, allowing seamless continuation between different machines.
Uses local SQLite databases as the primary storage for memories, chat logs, files, and knowledge graph, ensuring sovereign data storage.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@M3 Memorysave this conversation about project requirements"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ง M3 Memory
M3 treats agent memory as a distributed-systems infrastructure problem, not a simple retrieval feature.
Instead of every tool keeping its own throwaway context, M3 is a shared, evolving, bitemporal knowledge base that multiple heterogeneous agents and machines read and write. It is designed to solve a fundamental challenge: How do agents maintain a consistent, evolving, and temporal knowledge base over months and years?
๐ฆ Core Release Feature: Drop-in LangChain & LangGraph Support M3 now functions as a drop-in Mem0 replacement (one-line import swap) and is fully LangMem-compatible (
store=M3Store()). Gain automatic contradiction supersession, bitemporal historical queries, local sovereign embedding, and the full 100+ MCP tool set inside your LangChain apps viapip install m3-memory[langchain]. (See LangChain Integration Guide).
๐ Quick Links & Badges
๐ก Get Started Quickly:
๐ฅ๏ธ OS Installation: Windows Setup ยท macOS Setup ยท Linux Setup
Related MCP server: Smriti
๐ Table of Contents
โก M3 at a Glance
Feature | Details |
Works With | Claude Code ยท Gemini CLI ยท Aider ยท Google Antigravity ยท OpenCode ยท Hermes ยท LangChain/LangGraph ยท Any MCP Agent |
M3 Is | A persistent memory layer ยท An MCP server ยท A hybrid retrieval engine ยท A bitemporal knowledge base |
M3 Is Not | An LLM ยท A chatbot ยท A plain vector database ยท A RAG framework ยท An IDE |
Core Promise | Private, offline-capable, locally owned memory shared securely across all your developer tools โ with FIPS 140-3-ready crypto and atomic multi-agent writes for regulated and multi-agent environments. |
Retrieval Accuracy | State-of-the-art for a local-first substrate โ 99.2% session-hit-rate @ k=10, 100% @ k=20 on LongMemEval-S (no oracle routing), with the correct session as the #1 result for ~92% of questions. See Benchmarks. |
Context Efficiency | Exposes 100+ tools but occupies just ~1.8% of a 200K context window at startup โ lazy domain-gating loads the rest on demand. |
Maturity | Stable, battle-tested core engine (1,283 tests) that's safe to build on today; new features and integrations are added actively. SQLite by default for lightweight operation; scales out to PostgreSQL for enterprise sync. (See features.json) |
๐ง Memory Model at a Glance
M3 is a typed, bitemporal, confidence-scored, self-maintaining knowledge base. Every feature listed below is implemented natively (see Memory Model Details):
Structured Metadata: Every memory contains a
type,source,confidence,scope, provenance (change_agent), and salience (importance,decay_rate).Verbatim, Non-Destructive Storage: Memory content is stored exactly as written and never altered in place โ the raw text is always retrievable byte-for-byte. Corrections don't overwrite: a superseded fact is closed (its validity interval ends) and the new fact is linked to it, so both the original wording and its full edit history stay queryable. You get true verbatim recall and an audit trail, not one or the other.
Bitemporal History: Distinguishes valid-time from transaction-time. Because superseded facts are closed rather than deleted, you can query what the agent believed at any specific point in time.
Contradiction Management: Conflicting facts are resolved automatically on write. The stale fact is marked as superseded, and confidence values are updated dynamically via Bayesian confidence posteriors.
Self-Maintaining Lifecycle: Implements memory decay, deduplication, automatic consolidation into higher-order beliefs, TTL expiry, and GDPR erasure.
Write-Gating & Content Safety: Filters out low-signal noise via an enrichment queue and content safety guardrails before storage.
Explainable Retrieval: Hybrid engine combining vector similarity, BM25 (FTS5), MMR diversity, and reranking.
memory_suggestreturns the exact score breakdown per result. (See Confidence and Trust Guide).Proven Accuracy: On LongMemEval-S, M3 delivers state-of-the-art retrieval for a local-first substrate โ 99.2% session-hit-rate @ k=10 and 100% @ k=20 (no oracle routing), with the correct session as the #1 result for ~92% of questions. End-to-end QA accuracy is 92.0% with no oracle metadata (see Benchmarking Report).
๐ฆ Installation
The One-Liner (macOS & Linux)
curl -fsSL https://raw.githubusercontent.com/skynetcmd/m3-memory/main/install.sh | bashFor Windows, please follow the Windows Manual Installation Guide.
To install manually on any platform, refer to the OS-Specific Install Instructions or examine the installer script.
Developer Setup Wizard
If you are developing inside python environments:
pip install m3-memory
m3 setupThe m3 setup wizard automatically scans your PATH for active agents (Claude Code, Gemini CLI, OpenCode, OpenClaw), installs settings files/hooks, provisions the sovereign CPU embedder, and performs a system diagnostic.
Integrating with AI Coding Tools
๐ค Claude Code
Install as a plugin to unlock /m3:* slash commands, curation subagents, and automatic hooks:
/plugin marketplace add skynetcmd/m3-memory
/plugin install m3@skynetcmdSee Claude Code Plugin Reference and Claude.ai Connector Guide.
๐ช Google Antigravity
Install the plugin directly:
agy plugin install https://github.com/skynetcmd/m3-memorySee Antigravity Plugin Reference.
๐ฆ Hermes Agent
Run the wizard to automatically wire up optimal memory providers:
m3 setupSee Hermes Plugin Integration Guide.
๐ Python / LangChain & LangGraph
Use M3 as a drop-in Mem0 replacement or LangMem backend:
pip install m3-memory[langchain]See LangChain Integration Guide.
Manual MCP Server Configuration
To expose M3 to any Model Context Protocol host, add it to your configuration file:
{
"mcpServers": {
"memory": {
"command": "m3"
}
}
}๐๏ธ Domain Gating: the Full Catalog Without the Context Cost
M3 gives you the full 100+ tool surface while occupying just 1.8% of a 200K context window at startup โ most MCP servers make you pay for every tool in every prompt. Tools are grouped into 9 domains (memory, chatlog, files, entity, agent, tasks, conversations, diagnostics, admin) and loaded lazily.
Only the essential core set (~18, ~3,540 tokens) registers at startup. When your agent needs advanced functionality, it calls tools_load_domain(domain="...") to fetch the rest on demand โ so a large catalog costs near-zero context until you actually use a domain.
Gating Mode | Registered Tools | Tokens in Schema | % of 200K Window |
Lazy (Default) | ~18 | ~3,540 | 1.8% |
Typical Active Session | 64 | ~17,975 | 9.0% |
Eager Mode ( | 109 | ~24,918 | 12.5% |
๐ ๏ธ Note: If your client does not support dynamic tool registration, set the environment variable
M3_TOOLS_LAZY=0to register all tools eagerly.
๐ก๏ธ Sovereign & Air-Gapped Deployments
M3 operates completely offline by default.
Sovereign Local Embedder
A high-performance BGE-M3 embedder runs locally after installation.
Default: in-process via the
m3-core-rsnative module (llama.cpp linked in-process, zero IPC โ not a separate service you have to run or monitor). CPU execution using GGUF format (_assets/models/bge-m3-Q4_K_M.gguf). A local HTTP embed server on127.0.0.1:8082exists only as an automatic fallback if the in-process path can't load.Hardware Acceleration (GPU): Execute
m3 embedder install-gputo compile with CUDA, Vulkan, or Metal.External Provider Fallback: Set
EMBED_BASE_URLto route requests to Ollama, LM Studio, or vLLM.
Rust-Oxidized Performance Core
M3 includes an optional Rust performance module (m3_core_rs) that speeds up MMR re-ranking, batch cosine distance calculations, and FTS compilations by 90ร to 800ร. If absent, M3 falls back to pure Python execution automatically. Disable with M3_CORE_RS_DISABLE=1. (See Oxidation Benchmarks).
Enterprise Security & Compliance
FIPS 140-3 Ready: Standardized encryption pathways allow routing through validated cryptographic modules (e.g., wolfSSL via
M3_FIPS_MODE=1).Air-Gapped Install: Supports installation without internet access via pre-compiled python wheels. (See Sovereign Deployment Guide & FIPS Boundary Reference).
Storage Location: All config and data files reside under
~/.m3-memory(configurable viaM3_MEMORY_ROOT).
๐ฎ What M3 Does
Memory Persistence: Saves system architecture, project decisions, and preferences across tool boundaries using a local SQLite database.
Autonomous Cognitive Loop: Background worker (
m3_cognitive_loop.py) that periodically sweeps chat logs to extract facts, reconcile contradictions, and construct an entity relationship graph.Hybrid Vector & Keyword Search: Seamlessly merges vector space, Full-Text Search (FTS5 BM25), and MMR diversity.
Hierarchical File Ingestion: A dedicated 26-tool files domain reads directories, chunks files, extracts facts, and reviews staleness โ with ~4ร faster incremental re-ingest (unchanged sections reuse cached embeddings).
Verbatim Chatlog Capture: A dedicated 10-tool chatlog domain records conversation turns before compaction, so prior Claude/Gemini sessions stay searchable and nothing is lost to context-window truncation.
Cross-Device Sync: Optional PostgreSQL or ChromaDB synchronization backend. Access the same memories on your laptop, desktop, or cloud environments.
๐ Documentation Index
Quick & Core | Advanced & Architecture | Integrations & Compliance |
๐๏ธ System Architecture | ๐งฉ LangChain/LangGraph | |
โจ Core Features | ๐งฉ Hermes Agent | |
โ๏ธ Environment Variables | ๐ก๏ธ Compliance Guide (GDPR, FISMA) | |
๐ ๏ธ Operations Playbook | ๐ก๏ธ FIPS Cryptographic Boundary | |
๐ Myths & Facts Guide | ๐ Homelab Patterns | |
More Documentation
Guide | Guide | Guide |
๐บ๏ธ Roadmap | ๐ Cross-Device Sync | |
โ๏ธ Comparison vs Alternatives | โ FAQ | ๐ Security Policy |
๐ฉน Troubleshooting | โจ๏ธ CLI Reference | ๐ API Reference |
๐ Files Memory | ๐ฌ Chat Log Subsystem | โจ Enrichment Guide |
โฌ๏ธ Upgrade Guide | ๐ฉบ Health FAQ | ๐งฌ Dual Embedding |
๐ Changelog | ๐ค Code of Conduct | ๐๏ธ Build Wheels |
๐ฏ Who This Is For
M3 is a great fit if...
You use multiple desktop coding agents: Interoperate Claude Code, Gemini, and Aider on a shared local history.
You build with LangChain/LangGraph: An advanced replacement for standard memory models, adding bitemporal queries, contradiction management, and local embeddings.
You need security and compliance: Built-in
gdpr_forgetandgdpr_exporttools, air-gapped support, and audit logs.You value privacy: Zero external cloud requests or subscriptions required.
M3 is NOT a fit if...
You use CrewAI and want standard, framework-native memory models (use Mem0).
You need a hosted SaaS dashboard with managed infrastructure (use Letta).
You only want transient in-session chat context that resets when you exit the terminal (rely on your agent's defaults).
Your need is only contextual retrieval + a little user state: if plain conversation history, RAG over a knowledge base, and a small structured user profile cover you, that's simpler to build and operate โ persistent evolving memory earns its keep when users interact repeatedly over time and benefit from accumulated context.
You require a server-based store as the system of record: M3 is local-first โ SQLite is always the source of truth. PostgreSQL and ChromaDB are optional sync/federation tiers, not a drop-in replacement backend.
๐ก๏ธ Why Trust This
Benchmarked Retrieval: State-of-the-art for a local-first substrate โ 99.2% session-hit-rate @ k=10, 100% @ k=20 on LongMemEval-S โ with a published, reproducible methodology and no oracle routing. See Benchmarks.
Robust Coverage: Verified with 1,283 tests across 154 test files (~2,070 cases with parametrization) spanning search, sync, GDPR lifecycle, and files ingestion.
Audit Reports: Regular vulnerability reports (Bandit, secrets scans, pip-audit) published directly under
docs/audits/.Explainable Retrieval: No black-box queries; retrieval math is open, readable, and scoring parameters are outputted directly.
Open Source: Apache 2.0 licensed, free, with no SaaS walls or usage limits.
๐ Benchmarks
Retrieval Recall (Session Hit-Rate @ k)
Evaluated on the 500-question LongMemEval-S dataset under default server configurations:
Retrieve Depth (k) | Session Hit-Rate (SHR) | Success Count | vs. Prior Version |
5 | 98.2% | 491 / 500 | +2.0pp |
10 (Default) | 99.2% | 496 / 500 | +2.4pp |
20 | 100.0% | 500 / 500 | First Report |
End-to-End QA Accuracy
92.0% accuracy (460/500 correct responses) with zero oracle metadata routing:
Question Domain | Count (n) | Accuracy |
single-session-user | 70 | 94.3% |
single-session-assistant | 56 | 96.4% |
single-session-preference | 30 | 80.0% |
multi-session | 133 | 87.2% |
temporal-reasoning | 133 | 95.5% |
knowledge-update | 78 | 93.6% |
Overall Summary | 500 | 92.0% |
Methodology and reproducibility details are located in the LongMemEval-S Benchmarking Report.
๐งฐ Core Tools
While M3 features 100+ tools, these five serve as your primary interface:
Tool Name | Operation Description |
| Save a specific fact, project preference, or technical configuration. |
| Run hybrid keyword (BM25) and semantic vector search. |
| Edit existing facts to keep memory accurate. |
| Query memories alongside a mathematically explicit score breakdown. |
| Fetch details of a single memory using its unique ID. |
Refer to the Agent Instructions Guide and Full MCP Tool Catalog for complete parameter definitions.
๐ค For AI Agents
You can drop the agent ruleset file examples/AGENT_RULES.md into your workspace to teach your agent best practices (e.g., query before writing, update existing records instead of duplicating).
Command Installation Prompts
Copy and paste these prompts into your terminal client to let your agent set up M3 for you:
Claude Code Prompt
Install m3-memory for persistent memory. Run: pip install m3-memory
Then add {"mcpServers":{"memory":{"command":"m3"}}} to my
~/.claude/settings.json under "mcpServers". For best retrieval, ensure
Ollama is running with qwen3-embedding:0.6b (optional, falls back
to keyword search without it). Then use /mcp to verify the memory server loaded.Gemini CLI Prompt
Install m3-memory for persistent memory. Run: pip install m3-memory
Then add {"mcpServers":{"memory":{"command":"m3"}}} to my
~/.gemini/settings.json under "mcpServers". For best retrieval, ensure
Ollama is running with qwen3-embedding:0.6b (optional, falls back
to keyword search without it).Active Chatlog Capture Plugin
To configure instant conversation logging and backup, tell your active coding agent:
Install the m3-memory chat log subsystem.The agent executes bin/chatlog_init.py and configures execution triggers (see Chat Log Architecture Guide).
๐ฌ See it in action
Contradiction Detection & Automatic Resolution
Hybrid Search Scoring Details
Multi-Device Database Sync
๐ฌ Community
How to Contribute ยท Good First Issues
๐ License & Attributions
This project is licensed under the Apache License 2.0. See LICENSE for details.
Asset & Icon Credits
The provider badges under docs/badges/ embed small logo glyphs:
OpenClaw & OpenCode icons are from the MIT-licensed LobeHub icon set (
lobe-icons).The Hermes badge uses a generic caduceus glyph.
See NOTICE for the full third-party attribution list.
โญ Star History
Chart regenerated on a schedule by .github/workflows/star-history.yml using the repo's own token โ no third-party embed. Click through for the live interactive version.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/skynetcmd/m3-memory'
If you have feedback or need assistance with the MCP directory API, please join our Discord server