lean-memory MCP server
Embedded, local-first agent memory: one SQLite file per namespace, no server, no cloud.
42 stars
Reviews
Write oneNobody has reviewed lean-memory yet.
If you have run it, two minutes of your experience saves the next person an afternoon.
lean-memory tools (7, 2 write)
write = sends, deletes, buys or postsRead from the package source without running it. The installed server may list more.
memory_addDistill durable facts from text and write them to a namespace's memory.
memory_clearwrite actionDelete ALL memory for a namespace by removing its SQLite file. Irreversible.
memory_maintenance_runwrite actionRun one sleep-time maintenance pass on a namespace (§6.3).
memory_maintenance_statusReport a namespace's maintenance ledger — runs + pending proposals (§6.3).
memory_review_decideDecide a maintenance proposal: approve | reject | edit | promote (§6.3).
memory_review_queueList pending maintenance proposals, grouped by entity, with evidence (§6.3).
memory_searchRetrieve the facts most relevant to a query from a namespace's memory.
Public scan report
scanner v0.1.9 · 2026-09-24 · same rubric, same numbers if you re-run it
- Code scan36 source files scanned25/25
- –Live reliabilityno gateway calls yet and no remote to proben/a
- –Tool poisoningtools not inspected (local package is not executed); not countedn/a
- Auth qualitylocal package, no credentials required12/15
- Maintenancelast push 48 days ago12/15
- Maintainer identityregistry namespace matches repository owner; GitHub account older than a year8/10
What the publisher says
From the lean-memory repository's README, as published. We do not edit it. Read it on GitHub
lean-memory
Embedded, local-first agent memory. No server, no daemon, no mandatory cloud key.
Status (2026-07): first public release line (0.2.1) is live on PyPI and
the MCP Registry (MCP-first launch); the Claude Code plugin ships in this
repo (marketplace listing pending).
Roadmap and rationale: docs/superpowers/specs/2026-07-08-strategic-direction-design.md.
Public benchmark runs (LongMemEval/LoCoMo) are deliberately deferred until
after launch; the harness is complete (bench/phase2_*.py) and the engine
flaws it exposed are fixed — see docs/phase2-learnings.md.
from lean_memory import Memory
mem = Memory(root="./data")
mem.add("user-42", "I work at Acme Corp.")
mem.add("user-42", "I now work at Globex.") # supersedes Acme automatically
mem.search("user-42", "where does the user work?") # → "I now work at Globex."Facts are extracted from natural language, stored in a per-namespace SQLite file, and retrieved with hybrid dense+sparse search. Old facts are never deleted — they're superseded and queryable at any past point in time.
Install
pip install lean-memoryRuns fully offline out of the box. Optional extras unlock real model quality:
Quickstart
from lean_memory import Memory
mem = Memory(root="./data") # one SQLite file per namespace, stored under ./data/
# Store facts in natural language
mem.add("alice", "I work at Stripe.")
mem.add("alice", "I now work at Vercel.") # supersedes Stripe automatically
# Retrieve — the superseded Stripe fact drops out; only the current one is returned
results = mem.search("alice", "what does Alice do for work?", k=3)
for hit in results:
print(hit.fact.fact_text, hit.final_score)
# → I now work at Vercel. 0.89
# Point-in-time query — what was true at a specific moment?
mem.search("alice", "employer", as_of=1_700_000_000_000, is_latest_only=False) # epoch ms
# Always close when done (flushes WAL)
mem.close()Demo Agent
A terminal chatbot showing the full memory loop — add, retrieve, supersede, restart. The demo script lives in the repo (it is not installed with the package):
git clone https://github.com/Wuesteon/lean-memory && cd lean-memory
pip install -e '.[examples]'
export ANTHROPIC_API_KEY=sk-ant-...
python examples/chat.py # uses offline stubs by default
python examples/chat.py --namespace bob # separate memory tenant, persists across restartsNo API key? The demo still runs — it echoes the retrieved memory context instead of calling Claude, so you can watch the engine work offline.
MCP Server — memory for Claude Code / Claude Desktop
Give any MCP agent persistent local memory: three tools (memoryadd, memorysearch, memory_clear), one SQLite file per namespace, nothing leaves your machine.
pip install 'lean-memory[mcp,models,extract]'Shortened. The full README is on GitHub.
Nothing above is checked by us. What we check is on the safety report.
Install directly
claude mcp add lean-memory -- uvx lean-memory
lean-memory: common questions
- Is lean-memory MCP server safe?
- Yes, by our scan: it is graded A (88/100). Read the lean-memory safety report
- How do I install lean-memory?
- It runs on your machine. Copy the Claude Code, Claude Desktop or Cursor config from the install section.
- Does lean-memory need an API key?
- No secret keys are declared. It reads 1 setting from the environment.
- Is lean-memory maintained?
- The last commit was 48 days ago (2026-08-07). The latest release is v0.3.0.
- What can I use instead of lean-memory?
- Servers from other publishers that do the same job: Remem MCP server, memo MCP server and remem-mcp — Local-first MCP Memory + CodeGraph + Wiki MCP server. Compare all lean-memory alternatives.
Alternatives to lean-memory
Same job from other publishers: the closest match first, then the best rated.
- RememLocal-first automatic memory for Claude Code and Codex: capture, distill, recall from SQLite.not reviewedEstablishedB
- memoMemory for AI agents — MLX (Apple Silicon) or CPU (Linux), sqlite-vec + BM25, zero cloud.not reviewedGrowingA
- remem-mcp — Local-first MCP Memory + CodeGraph + WikiLocal-first memory for AI coding agents. Memory + CodeGraph + Wiki in one SQLite file.not reviewedGrowingB
- CitadelEncrypted-first embedded database with vector search and agent memory, exposed as MCP toolsnot reviewedGrowingB
- KEPTA — Agent MemoryLocal memory for AI agents. One SQLite file on your machine — no cloud, no account.not reviewedGrowingA