🌳 Mnemotree
Local, source-first memory for LLM agents: SQLite, FTS5 and sqlite-vec.


Mnemotree stores every message exactly as written and recalls the original passages
with their speaker and time. By default it runs no LLM on write or on recall, so you
get back what was said, not a model's summary of it.
- Durable: sources, chunks, both indexes and an idempotency receipt commit in one
transaction.
- Hybrid: FTS5 BM25 and sqlite-vec cosine search, fused with RRF, with optional
reranking.
- Bounded: evidence is packed into an exact token budget, with a trace of every
candidate, rank and packing loss.
- Isolated: every read and write is scoped to one namespace.
The default install needs only Pydantic, sqlite-vec and tiktoken. See
Benchmarks for the Agent Memory Leaderboard result and end-to-end
results on LoCoMo and LongMemEval.
Try it in Claude Code
Add the published MCP server to give Claude local memory tools.
claude mcp add mnemotree -- uvx mnemotree-mcp
Ask Claude to remember something, start a new session, and ask about it.
The default embedding model runs locally and needs no API key.
MCP server covers configuration and other clients.
The Claude Code plugin adds automatic capture and recall per project. Its marketplace
launcher requires mnemotree-mcp 1.2.0 or later on PyPI. Recalled passages become part
of the context sent to Claude. Plugin setup and data handling
Install
For the Python library:
pip install mnemotree
Python's sqlite3 must support loadable extensions and FTS5. Tiktoken downloads its
vocabulary once; see the guide to run offline.
| Extra | Adds |
|---|
embeddings | OpenAI-compatible HTTP embedder and extractor |
lite | Local SentenceTransformer embedder |
serve | HTTP service: AML Add/Search, plus routes to list, read and delete memories |
all | All of the above |
Quickstart
import asyncio
from mnemotree import Memory
async def main():
with Memory("memory.sqlite", namespace="alice") as memory: # lexical without an embedder
await memory.remember("I grow orchids on my balcony.", role="user")
recall = await memory.recall("orchids")
print(recall.context) # packed, attributed evidence
print([item.id for item in recall.items], recall.trace.packed_tokens)
asyncio.run(main())
Memory binds one namespace and offers remember, remember_many, recall, get
and forget. Pass an embedder for hybrid retrieval.
examples/ has three scripts to start from:
- chat_with_memory.py is a chat loop that remembers
across runs, against any OpenAI-compatible server, Ollama included.
- multi_user.py keeps one memory per user in a single
database, with idempotent writes and deletion. It runs offline.
- service_backend.py calls the HTTP service from your
own backend.
Benchmarks
On the Agent Memory Leaderboard
Cycle 2 (2026), mnemotree
placed second in Textual Memory with 60.81, 0.41 behind first.