Skip to main content

🌳 Mnemotree

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

License: MIT Python 3.11+ CI Quality Gate Status CodeQL

Mnemotree Logo

Mnemotree keeps every message exactly as written and recalls attributed source spans instead of rewritten summaries.

  • 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 end-to-end results on LoCoMo and LongMemEval.

Install

pip install mnemotree

This README describes the 0.5 API. When using it before the 0.5 release, install the development version instead:

pip install "mnemotree @ git+https://github.com/kurcontko/mnemotree.git@main"

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 AML Add/Search HTTP service
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.

Benchmarks

These scores measure end-to-end question answering with the v1.0.0 engine. Mnemotree packs at most 8,000 tokens of evidence per question. gpt-4o-mini answers from that evidence and also judges the answer. Embeddings come from DashScope text-embedding-v4 at 1,024 dimensions. Retrieval fuses BM25 and vector search with RRF and adds the neighboring messages around each hit. No LLM runs inside Mnemotree.

Benchmark Questions Mnemotree Published, gpt-4o-mini answering
LoCoMo, categories 1 to 4 1,540 72.1 Full context (26K tokens) 72.9, Mem0 with graph 68.4, Mem0 66.9, Zep 66.0, LangMem 58.1 (Mem0 paper, Table 2)
LongMemEval-S 500 60.8 Zep 63.8, full context (115K tokens) 55.4 (Zep paper, Table 2)

On LoCoMo-Refined, a cleaned release of LoCoMo with 1,382 questions, Mnemotree scores 78.7 with the official scorer, which judges with Qwen3-14B. That run used Nemotron-3-Embed-8B embeddings.

On BEAM we ran BEAM's own answer and scoring code, with gpt-4.1-nano answering and gpt-4.1-mini judging. We also ran BEAM's RAG baseline in the same harness. Its scores under the paper-era scorer match the paper's Table 1.

BEAM conversation length Questions Mnemotree BEAM RAG, same harness
100K tokens 400 37.7 32.5
500K tokens 700 41.2 33.4
1M tokens 700 38.5 31.8
10M tokens 200 29.9 21.9

Mnemotree used Qwen3-Embedding-4B embeddings here. With the RAG baseline's own bge-small embedder it still leads at every length.

Each score is a single run of ours. The published rows are the authors' own runs with their own prompts and judges, and the Zep paper judges LongMemEval with gpt-4o. docs/BENCHMARKS.md has the setup, the method, how to size the evidence budget and the limitations. The evaluation harness is not in this repository yet.

MCP server

mnemotree-mcp gives Claude Code, Claude Desktop, Codex and other MCP clients the same five tools over stdio, with semantic search on a local embedding model. It needs no API key or configuration:

claude mcp add mnemotree -- uvx mnemotree-mcp

The first start downloads the English-only granite-embedding-small-english-r2 model (about 200 MB) to ~/.mnemotree/models; the server answers while it loads.

Setting Flag Default
MNEMOTREE_DB --db ~/.mnemotree/memory.sqlite
MNEMOTREE_NAMESPACE --namespace default
MNEMOTREE_CONFIG --config local model
MNEMOTREE_LEXICAL=1 --lexical off
uvx mnemotree-mcp --lexical                    # keyword-only, no model download
uvx mnemotree-mcp --config ~/.mnemotree/config.json   # e.g. an HTTP embedder

Sessions pointed at the same database share one memory. With pip install mnemotree, mnemotree mcp runs the same server, but with no default model: pass --config or --lexical.

Command line

# Retrieval evaluation on the bundled plumbing example (needs a fresh database).
mnemotree-evidence --db demo.sqlite --config examples/evidence/lexical.json \
  evaluate examples/evidence/corpus.jsonl examples/evidence/queries.jsonl \
  --output demo-results.json

# AML Add/Search service with a bearer key (the serve extra).
export MNEMOTREE_API_KEY='replace-with-your-service-key'
mnemotree-evidence --db service.sqlite serve

mnemotree-evidence also runs add, search, and the ablate, ablate-context and ablate-retrieval comparisons.

Documentation

docs/GUIDE.md covers the API contract, MCP configuration, embeddings, storage and retrieval behavior, atomic projections, the AML service, evaluation and limits. docs/BENCHMARKS.md records how the benchmark numbers were produced and what they leave out.

Releases up to 0.4.0 shipped MemoryCore, pluggable vector/graph backends and an older MCP server. They have been removed, and Memory does not read their databases. See the 0.5 release notes for API and compatibility changes.

Development

git clone https://github.com/kurcontko/mnemotree.git
cd mnemotree
uv sync --extra dev --extra serve
make lint typecheck test
make build
make precommit-install

See CONTRIBUTING.md.

License

MIT, see LICENSE.

Metadata

Release files for mnemotree 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mnemotree 1.0.4
File Size Uploaded Provenance Actions
mnemotree-1.0.4.tar.gz 930.3 kB With provenance Details for mnemotree-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mnemotree 1.0.4
File Interpreter ABI Platform Actions
mnemotree-1.0.4-py3-none-any.whl Python 3 none any Details for mnemotree-1.0.4-py3-none-any.whl

Total release size: 1.0 MB

Release files / mnemotree-1.0.4.tar.gz

Download URL mnemotree-1.0.4.tar.gz
Size 930.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c6afc6745f7e4023abef431f9ecb409ac03b472e7deb4e4cc722bef567e11170
BLAKE2b-256 checksum
How to use checksums
efe83efc32a2cae8d9bd2b557e2cb46be5b1d900a2c778adafb0b6c7fc3174e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / mnemotree-1.0.4-py3-none-any.whl

Download URL mnemotree-1.0.4-py3-none-any.whl
Size 89.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b792411070d76fdd70976ec751958f245f5d02e8bd05d39c6d015a64030b83a
BLAKE2b-256 checksum
How to use checksums
e8f87fa5a3b92ee2ceb269aa1566d9a60c049171136c3cbd95e65e77fe663be2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for mnemotree 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mnemotree-1.0.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page