π§ Mnema β Long-term Memory for AI
Give your AI agents persistent, searchable memory. Solve the context-window problem with MCP Γ Vector DB.
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 serveexposes all memory operations over plain HTTP (FastAPI) for non-AI apps. - π₯οΈ Web dashboard β
mnema dashboardopens 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:
- Installs
uv(no pip / no virtualenv wrangling). - Clones Mnema from GitHub.
- Creates an isolated Python 3.11 environment with all dependencies.
- Installs the
mnemaandmnema-updatecommands. - Runs
mnema --doctorto 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).
-
Find or create the config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json(in Finder, pressCmd+Shift+Gand paste the path) - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Paste this into the file (merge with existing
mcpServersif present):{ "mcpServers": { "mnema": { "command": "mnema", "env": { "MNEMA_BACKEND": "chroma", "MNEMA_BACKEND_PATH": "~/.mnema-data", "MNEMA_DEFAULT_SCOPE": "user:me" } } } } -
Fully quit Claude Desktop (menu β Quit, not just close the window) and reopen it.
-
Verify: click the π plug icon in the chat β
mnemashould appear in the list. -
Try: "Remember that I prefer dark mode." then, in a new chat, "What do you know about my preferences?"
-
From your project root, add the server:
claude mcp add mnema mnemaOr add it to
~/.claude.json(user scope) directly:{ "mcpServers": { "mnema": { "command": "mnema", "env": { "MNEMA_DEFAULT_SCOPE": "user:me" } } } } -
Start
claudeand run/mcpto confirmmnemais connected. -
Tools are available automatically β try "remember that this project uses Postgres".
- 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" } } } } - Open Cursor β Settings β MCP (or reload the window:
Cmd+Shift+Pβ "Reload Window"). mnemashould show a green dot. If red, check the path withwhich mnema.- Use it in chat: "search my memory for past decisions about the auth module."
- Open
~/.config/zed/settings.json(macOS) and add undercontext_servers:{ "context_servers": { "mnema": { "command": { "path": "mnema" }, "env": { "MNEMA_DEFAULT_SCOPE": "user:me" } } } } - Restart Zed, then enable the server in Assistant panel settings.
- In the Assistant, tag
@mnemato pull memory context into the conversation.
- Open the Cline sidebar β MCP icon β "Edit MCP Settings".
- Add the entry to
cline_mcp_settings.json:{ "mcpServers": { "mnema": { "command": "mnema", "env": { "MNEMA_DEFAULT_SCOPE": "workspace" }, "disabled": false, "alwaysAllow": [] } } } - Cline auto-detects the change β no restart needed.
- Ask Cline: "search memory for anything I decided about testing strategy."
- Open
~/.continue/config.jsonand add underexperimental.modelContextProtocolServers:{ "experimental": { "modelContextProtocolServers": [ { "transport": { "type": "stdio", "command": "mnema" } } ] } } - Reload the window (
Cmd+Shift+Pβ "Reload Window"). - Use
@mnemain the Continue chat to scope memory tools.
- Open Settings β MCP Servers β "Add Server" (or edit
~/.codeium/windsurf/mcp_config.json):{ "mcpServers": { "mnema": { "command": "mnema" } } } - Click Refresh on the MCP panel β
mnemashould turn active. - Use Cascade with
@mnemato 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
- Model Context Protocol β the protocol that makes this possible.
- ChromaDB, Qdrant, sqlite-vec, pgvector, LanceDB β excellent open-source vector stores.
- sentence-transformers β offline embeddings for everyone.
- Contributors: @faizmullaa (Ollama provider), @Nitjsefnie (REST API + browser extension + Node CI + MCP registry), @Adiiiipawar (pgvector), @Oneshot1123 (LanceDB), @NEMEZIZ1234 (web dashboard), @jaineel132 (Cohere/Voyage/Nomic embeddings).
No comments yet
Be the first to share your take.