🧠 Mnema β€” Long-term Memory for AI

Give your AI agents persistent, searchable memory. Solve the context-window problem with MCP Γ— Vector DB.

CI Install Python License: MIT MCP Status: Beta

Mnema (ΞΌΞ½αΏ†ΞΌΞ± β€” Greek for "memory") is an open-source Model Context Protocol server that gives language-model agents a long-term memory layer. Instead of stuffing every relevant fact into a single conversation (and paying for it in tokens, latency, and lost context), store durable facts once and recall them later β€” by meaning, not by keyword.


✨ Features

  • πŸ”Œ MCP-native β€” drop it into Claude Desktop, Claude Code, Cursor, Zed, Cline, Continue, Windsurf, ZCode, or any MCP-compatible client.
  • πŸ—„οΈ Pluggable vector backends β€” ChromaDB (embedded, default), Qdrant (local or remote), sqlite-vec (pure-SQLite), pgvector (Postgres), or LanceDB (embedded columnar).
  • 🧠 Pluggable embeddings β€” sentence-transformers (offline, default), OpenAI, Ollama, Cohere, Voyage, or Nomic.
  • πŸ” Hybrid search β€” combines semantic similarity + tag overlap + decay scoring into a single ranked score.
  • ⏳ Memory decay β€” a forgetting curve (recency Γ— frequency Γ— importance) so the store stays focused on what matters.
  • πŸŒ™ Auto Dream β€” optional background scheduler that consolidates memories while the server is idle (forget decayed + plan summarization), like a brain sleeping.
  • πŸ“ Summarization β€” plans how to condense many memories into a few high-level ones; the calling AI executes the plan (Mnema never calls an LLM on its own).
  • πŸ‘₯ Multi-user / multi-session β€” scope-based namespace isolation (user:alice, session:abc, agent:bot-1).
  • πŸ”§ Offline by default β€” local sentence-transformers embeddings; no API keys required to start.
  • πŸ“¦ Programmatic SDK β€” use Mnema from Python without standing up an MCP server.
  • πŸ’» CLI β€” mnema add, mnema recall, mnema dream, mnema eval, mnema dashboard… 20+ subcommands for terminal-first workflows.
  • 🌐 REST API β€” mnema serve exposes all memory operations over plain HTTP (FastAPI) for non-AI apps.
  • πŸ–₯️ Web dashboard β€” mnema dashboard opens a browser UI (htmx + Jinja2) to browse, search, edit, forget, and trigger decay/summarize β€” no AI client needed.
  • 🧩 Browser extension β€” select text on any page β†’ right-click "Remember this" β†’ adjust scope/tags β†’ save (Chrome/Edge/Firefox 115+, Manifest V3).
  • πŸ§ͺ Well-tested β€” 164 Python tests + 51 JS tests across pure-function unit tests + a backend matrix that runs against every supported store. Plus a built-in recall eval harness (mnema eval) β€” recall@5 = 100%, MRR = 1.0 on the bundled dataset.

πŸš€ Quick start

One-line install (recommended)

curl -fsSL https://raw.githubusercontent.com/mienetic/mnema/main/scripts/install.sh | bash

That's it. The installer:

  1. Installs uv (no pip / no virtualenv wrangling).
  2. Clones Mnema from GitHub.
  3. Creates an isolated Python 3.11 environment with all dependencies.
  4. Installs the mnema and mnema-update commands.
  5. Runs mnema --doctor to verify.

πŸ‡ΉπŸ‡­ New to this? See GETTING_STARTED.md β€” step-by-step guide (in Thai).

Verify & update

mnema --doctor          # check backend + embedding loaded
mnema --doctor --fix    # attempt to fix common problems (missing dir, etc.)
mnema                   # run the MCP server (stdio, for clients)
mnema-update            # git pull + reinstall + verify (run this to upgrade)

Pick different backends / embeddings (optional)

The default install ships Chroma + local embeddings β€” enough for most users. To use another backend, reinstall with the matching extra(s):

# Qdrant (local or remote)
curl -fsSL https://raw.githubusercontent.com/mienetic/mnema/main/scripts/install.sh \
  | MNEMA_EXTRAS="qdrant,local" bash

# sqlite-vec (smallest footprint)
curl -fsSL https://raw.githubusercontent.com/mienetic/mnema/main/scripts/install.sh \
  | MNEMA_EXTRAS="sqlite_vec,local" bash

# Everything (all backends + OpenAI embeddings)
curl -fsSL https://raw.githubusercontent.com/mienetic/mnema/main/scripts/install.sh \
  | MNEMA_EXTRAS=all bash

Available extras: chroma, qdrant, sqlite_vec, pgvector, lancedb, local, openai, ollama, cohere, voyage, nomic, api, default (= chroma,local), all. See docs/backends.md and docs/embedding-providers.md.

Manual / from source

git clone https://github.com/mienetic/mnema
cd mnema/packages/mnema-python
uv venv --python 3.11 .venv
VIRTUAL_ENV=.venv uv pip install -e '.[default]'
.venv/bin/mnema --doctor

Wire it into your AI client

Pick your client below. Each example assumes Mnema is already installed (mnema is on your PATH after running the installer).

  1. Find or create the config file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json (in Finder, press Cmd+Shift+G and paste the path)
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Paste this into the file (merge with existing mcpServers if present):

    {
      "mcpServers": {
        "mnema": {
          "command": "mnema",
          "env": {
            "MNEMA_BACKEND": "chroma",
            "MNEMA_BACKEND_PATH": "~/.mnema-data",
            "MNEMA_DEFAULT_SCOPE": "user:me"
          }
        }
      }
    }
    
  3. Fully quit Claude Desktop (menu β†’ Quit, not just close the window) and reopen it.

  4. Verify: click the πŸ”Œ plug icon in the chat β€” mnema should appear in the list.

  5. Try: "Remember that I prefer dark mode." then, in a new chat, "What do you know about my preferences?"

  1. From your project root, add the server:

    claude mcp add mnema mnema
    

    Or add it to ~/.claude.json (user scope) directly:

    {
      "mcpServers": {
        "mnema": {
          "command": "mnema",
          "env": { "MNEMA_DEFAULT_SCOPE": "user:me" }
        }
      }
    }
    
  2. Start claude and run /mcp to confirm mnema is connected.

  3. Tools are available automatically β€” try "remember that this project uses Postgres".

  1. Create ~/.cursor/mcp.json (global) or .cursor/mcp.json (project-level):
    {
      "mcpServers": {
        "mnema": {
          "command": "mnema",
          "env": {
            "MNEMA_BACKEND": "chroma",
            "MNEMA_BACKEND_PATH": "~/.mnema-data",
            "MNEMA_DEFAULT_SCOPE": "project:current"
          }
        }
      }
    }
    
  2. Open Cursor β†’ Settings β†’ MCP (or reload the window: Cmd+Shift+P β†’ "Reload Window").
  3. mnema should show a green dot. If red, check the path with which mnema.
  4. Use it in chat: "search my memory for past decisions about the auth module."
  1. Open ~/.config/zed/settings.json (macOS) and add under context_servers:
    {
      "context_servers": {
        "mnema": {
          "command": { "path": "mnema" },
          "env": { "MNEMA_DEFAULT_SCOPE": "user:me" }
        }
      }
    }
    
  2. Restart Zed, then enable the server in Assistant panel settings.
  3. In the Assistant, tag @mnema to pull memory context into the conversation.
  1. Open the Cline sidebar β†’ MCP icon β†’ "Edit MCP Settings".
  2. Add the entry to cline_mcp_settings.json:
    {
      "mcpServers": {
        "mnema": {
          "command": "mnema",
          "env": { "MNEMA_DEFAULT_SCOPE": "workspace" },
          "disabled": false,
          "alwaysAllow": []
        }
      }
    }
    
  3. Cline auto-detects the change β€” no restart needed.
  4. Ask Cline: "search memory for anything I decided about testing strategy."
  1. Open ~/.continue/config.json and add under experimental.modelContextProtocolServers:
    {
      "experimental": {
        "modelContextProtocolServers": [
          {
            "transport": { "type": "stdio", "command": "mnema" }
          }
        ]
      }
    }
    
  2. Reload the window (Cmd+Shift+P β†’ "Reload Window").
  3. Use @mnema in the Continue chat to scope memory tools.
  1. Open Settings β†’ MCP Servers β†’ "Add Server" (or edit ~/.codeium/windsurf/mcp_config.json):
    {
      "mcpServers": {
        "mnema": { "command": "mnema" }
      }
    }
    
  2. Click Refresh on the MCP panel β€” mnema should turn active.
  3. Use Cascade with @mnema to recall project context.

Mnema is a standard stdio MCP server. Any client that supports the Model Context Protocol can launch it:

{
  "mcpServers": {
    "mnema": { "command": "mnema" }
  }
}

For remote / multi-client setups, run Mnema over streamable HTTP:

mnema --transport http --host 127.0.0.1 --port 8000
# then point clients at http://127.0.0.1:8000/mcp

Ready-to-copy configs for all clients are in examples/.


πŸ› οΈ Tools

Tool Description Read-only?
mnema_remember Store a new memory ✏️
mnema_recall Pure semantic vector search πŸ”
mnema_search Hybrid: vector + tags + decay πŸ”
mnema_get_memory Fetch one memory by id πŸ”
mnema_update_memory Patch text/tags/importance/metadata ✏️
mnema_forget Delete one memory πŸ—‘οΈ
mnema_forget_scope Delete all memories in a scope πŸ—‘οΈ
mnema_list_scopes Enumerate scopes + counts πŸ”
mnema_summarize Plan how to condense a scope πŸ”
mnema_apply_decay Find/forget low-value memories πŸ—‘οΈ
mnema_stats Aggregate store stats πŸ”

Plus resources (mnema://memory/{id}, mnema://scope/{s}/summary, mnema://stats) and prompt templates (recall_for, remember_this, summarize_scope).

See SKILL.md for the full agent-facing usage guide.


πŸ’» CLI

You don't need an AI client to use Mnema β€” the mnema command works as a terminal tool too. (Comes free with the installer.)

# Store a memory
mnema add "Alice prefers Earl Grey tea" --tags pref,tea --scope user:alice

# Recall by meaning
mnema recall "what does alice drink?" --scope user:alice

# Hybrid search (vector + tags + decay)
mnema search "preferences" --tag pref --scope user:alice

# Inspect
mnema get <id>
mnema list-scopes
mnema stats

# Maintain
mnema decay --threshold 0.1            # dry-run: list low-value memories
mnema decay --threshold 0.1 --apply    # actually forget them
mnema summarize session:abc            # plan how to condense a scope

# Backup / migrate / snapshot
mnema export -o memories.json
mnema import -i memories.json
mnema backup -o mnema-backup.tar.gz     # portable archive (memories + manifest)
mnema restore mnema-backup.tar.gz

# Evaluate recall quality (recall@k + MRR)
mnema eval                               # seed + run 24 queries, print report

# Re-embed after switching embedding model (see docs/embedding-providers.md)
mnema re-embed

# Servers
mnema serve --port 8000              # REST API (FastAPI) for non-AI apps
mnema dashboard --port 8080          # Web UI (htmx + Jinja2) for browsing memories

Add --json to any read command for machine-readable output. Run mnema <command> --help for full options.


πŸ§‘β€πŸ’» Programmatic SDK

Use Mnema from Python without MCP β€” same engine, no IPC:

import asyncio
from mnema.sdk import MemoryClient

async def main():
    async with MemoryClient() as client:
        await client.remember(
            "Alice's deployment target is fly.io (region sin).",
            scope="project:web",
            tags=["deploy", "infra"],
            importance=8,
        )
        hits = await client.search("where do we deploy?", scope="project:web")
        print(hits.results[0].memory.text)

asyncio.run(main())

Synchronous helper for scripts:

from mnema.sdk import sync_client

with sync_client() as client:
    client.remember("a durable fact", tags=["x"])
    print(client.recall("durable").results)

βš™οΈ Configuration

All settings are environment-driven (or .env):

Variable Default Description
MNEMA_BACKEND chroma chroma | qdrant | sqlite_vec | pgvector | lancedb
MNEMA_BACKEND_PATH .mnema/data Local path or remote URL (http://…)
MNEMA_BACKEND_COLLECTION memories Collection/table name
MNEMA_EMBEDDING local local (offline) | openai | ollama
MNEMA_EMBEDDING_MODEL all-MiniLM-L6-v2 Model name
MNEMA_EMBEDDING_DIM auto Override vector dim
MNEMA_OPENAI_API_KEY β€” Required when embedding=openai
MNEMA_OLLAMA_URL http://localhost:11434 Ollama server URL (when embedding=ollama)
MNEMA_DEFAULT_SCOPE global Scope when a tool omits it
MNEMA_DECAY_HALF_LIFE_DAYS 30 Recency half-life
MNEMA_DECAY_FLOOR 0.05 Min decay score
MNEMA_VECTOR_WEIGHT 0.7 Hybrid score weight (must sum to 1)
MNEMA_KEYWORD_WEIGHT 0.2 Hybrid score weight
MNEMA_DECAY_WEIGHT 0.1 Hybrid score weight
MNEMA_TRANSPORT stdio stdio | http
MNEMA_HTTP_HOST 127.0.0.1 HTTP bind host
MNEMA_HTTP_PORT 8000 HTTP bind port
MNEMA_DREAM_ENABLED false Auto Dream background consolidation
MNEMA_DREAM_INTERVAL_SECONDS 3600 Seconds between dream cycles
MNEMA_DREAM_DECAY_THRESHOLD 0.05 Decay cutoff for forgetting during dreams
MNEMA_LOG_LEVEL WARNING DEBUG | INFO | WARNING | ERROR β€” verbose logs for bug reports

πŸ—„οΈ Choosing a backend

Backend Install extra Embedded? Best for
Chroma (default) chroma βœ… in-process + persistent Quick start, single-user, dev
Qdrant qdrant βœ… local path / :memory: / remote Production, high scale, metadata filtering
sqlite-vec sqlite_vec βœ… pure SQLite Smallest footprint, constrained envs
pgvector pgvector ❌ requires Postgres server Production, existing Postgres infra
LanceDB lancedb βœ… embedded columnar High-performance local, large stores

Switch backends by reinstalling with the right extra and setting the env var:

curl -fsSL https://raw.githubusercontent.com/mienetic/mnema/main/scripts/install.sh \
  | MNEMA_EXTRAS="qdrant,local" bash
export MNEMA_BACKEND=qdrant
mnema --doctor

See docs/backends.md for full details.


🧠 Embedding providers

Provider Install extra Mode Dim
sentence-transformers (default) local Offline (CPU/GPU) 384 (all-MiniLM-L6-v2)
OpenAI openai API (requires key) 1536 (text-embedding-3-small)
Ollama ollama Local server 768 (nomic-embed-text)
Cohere cohere API (requires key) 1024 (embed-english-v3.0)
Voyage AI voyage API (requires key) 1024 (voyage-2)
Nomic nomic API (requires key) 768 (nomic-embed-text-v1)
curl -fsSL https://raw.githubusercontent.com/mienetic/mnema/main/scripts/install.sh \
  | MNEMA_EXTRAS="chroma,openai" bash
export MNEMA_EMBEDDING=openai
export MNEMA_OPENAI_API_KEY=sk-...
mnema --doctor

See docs/embedding-providers.md for model options.


πŸ§ͺ Development

git clone https://github.com/mienetic/mnema.git
cd mnema/packages/mnema-python

# Install with dev deps + all backends
uv venv --python 3.11 .venv
VIRTUAL_ENV=.venv uv pip install -e '.[all,dev]'

# Run tests (skips backends whose deps are missing)
pytest

# Run a specific backend's tests after installing its extra
pytest -m chroma

# Lint + typecheck
ruff check .
mypy src/mnema

Test the server interactively

npx @modelcontextprotocol/inspector uv run mnema

This opens the MCP Inspector web UI where you can call every tool.


🐳 Docker

docker compose -f docker/docker-compose.yml up mnema
# Streamable HTTP on http://localhost:8000/mcp

See docker/ for the Dockerfile and compose setup.


πŸ“¦ Project layout

mnema/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ mnema-python/         # ⭐ MCP server + SDK + CLI + REST API + dashboard
β”‚   β”‚   β”œβ”€β”€ src/mnema/
β”‚   β”‚   β”‚   β”œβ”€β”€ backends/     # chroma, qdrant, sqlite_vec, pgvector, lancedb
β”‚   β”‚   β”‚   β”œβ”€β”€ embeddings/   # sentence_transformers, openai, ollama
β”‚   β”‚   β”‚   β”œβ”€β”€ tools/        # 11 MCP tools
β”‚   β”‚   β”‚   β”œβ”€β”€ api/          # REST API (FastAPI) β€” `mnema serve`
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard/    # web UI (htmx + Jinja2) β€” `mnema dashboard`
β”‚   β”‚   β”‚   β”œβ”€β”€ cli.py        # terminal CLI (22 subcommands)
β”‚   β”‚   β”‚   β”œβ”€β”€ service.py    # orchestration
β”‚   β”‚   β”‚   β”œβ”€β”€ decay.py      # forgetting curve
β”‚   β”‚   β”‚   β”œβ”€β”€ summarize.py  # summarization planner
β”‚   β”‚   β”‚   β”œβ”€β”€ dream.py      # πŸŒ™ Auto Dream scheduler
β”‚   β”‚   β”‚   β”œβ”€β”€ eval_harness.py  # recall@k evaluation
β”‚   β”‚   β”‚   β”œβ”€β”€ diagnostics.py   # logging + error reporting
β”‚   β”‚   β”‚   β”œβ”€β”€ sdk.py        # programmatic SDK
β”‚   β”‚   β”‚   └── server.py     # FastMCP bootstrap
β”‚   β”‚   └── tests/            # 164 tests (unit + backend matrix + eval + dream + diagnostics)
β”‚   └── mnema-extension/      # 🧩 browser extension (MV3) β€” "Remember this" over the REST API
β”‚       β”œβ”€β”€ src/              # popup, options, background service worker
β”‚       └── test/             # 51 JS tests (node:test)
β”œβ”€β”€ docker/                   # Dockerfile + compose
β”œβ”€β”€ docs/                     # architecture, backends, deployment, embedding-providers
β”œβ”€β”€ examples/                 # client config examples
β”œβ”€β”€ scripts/                  # one-line installer + updater
β”œβ”€β”€ SKILL.md                  # agent-facing usage guide
β”œβ”€β”€ ROADMAP.md                # prioritized roadmap (Phase 1–4)
└── README.md

🀝 How it works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    MCP     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AI Client   │◄──────────►│   Mnema Server   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  (stdio/   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                  HTTP)     β”‚  β”‚ 11 tools   β”‚  β”‚
                            β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β”‚
                            β”‚  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”  β”‚
                            β”‚  β”‚  Service   β”‚  β”‚
                            β”‚  β””β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”˜  β”‚
                            β”‚ β”Œβ”€β”€β”€β”€β–Όβ”€β” β”Œβ”€β–Όβ”€β”€β”€β”€β” β”‚
                            β”‚ β”‚embed β”‚ β”‚vectorβ”‚ β”‚
                            β”‚ β””β”€β”€β”¬β”€β”€β”€β”˜ β””β”€β”€β”¬β”€β”€β”€β”˜ β”‚
                            β””β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”˜
                                 β”‚         β”‚
                    sentence-    β”‚  Chroma/Qdrant/sqlite-vec/
                    transformers β”‚  pgvector/LanceDB
                    (local)      β”‚
                                 β–Ό         β–Ό
                              vectors  + metadata

Every memory is embedded, stored alongside its scope/tags/importance, and ranked on retrieval by:

score = 0.7Β·vector + 0.2Β·keyword + 0.1Β·decay

where decay = recency(half-life) Γ— frequency Γ— importance.


πŸ—ΊοΈ Roadmap

Shipped: Python MCP server Β· CLI (22 subcommands) Β· REST API (mnema serve) Β· web dashboard (mnema dashboard) Β· browser extension Β· 5 vector backends (Chroma/Qdrant/sqlite-vec/pgvector/LanceDB) Β· 6 embedding providers (local/OpenAI/Ollama/Cohere/Voyage/Nomic) Β· hybrid search with decay Β· Auto Dream consolidation Β· recall eval (100% recall@5) Β· backup/restore Β· re-embed migration Β· friendly error reporting.

In progress: Slack/Discord bot Β· TypeScript MCP server Β· auth + multi-tenant.

See ROADMAP.md for the full prioritized plan (Phase 1–4) and the open issues to pick from.


πŸ“„ License

MIT Β© Mnema Contributors.

πŸ™ Acknowledgements