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. This repository does not yet publish reproducible retrieval-quality benchmarks.

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.

MCP server

mnemotree-mcp gives Claude Code, Claude Desktop, Codex and other MCP clients the same five tools over stdio. It needs no extra.

claude mcp add mnemotree -- mnemotree-mcp --db ~/.mnemotree/memory.sqlite \
  --namespace "$USER" --lexical   # or --config with an embedding

Sessions pointed at the same --db share one memory.

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.

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.1

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.1
File Size Uploaded Provenance Actions
mnemotree-1.0.1.tar.gz 828.2 kB With provenance Details for mnemotree-1.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 894.9 kB

Release files / mnemotree-1.0.1.tar.gz

Download URL mnemotree-1.0.1.tar.gz
Size 828.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9cfa1fe963fd68cffba65f4383e79ca769022861aea2b4e5965b9275df093844
BLAKE2b-256 checksum
How to use checksums
798fbaaf1263ee1692661c5414e09022f3360769d1697c8efce21409bcbecabd
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 3, 2026.

Transparency log

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

Download URL mnemotree-1.0.1-py3-none-any.whl
Size 66.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f93fb0a28e07ef0eb8d4f262fa54900604fc0e1313bce56aa52f2f18af4ff505
BLAKE2b-256 checksum
How to use checksums
7d3d8301ed95be0b2b7782535dc241c5b39f0fbdbda100d2df35a67fd741e8e9
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 3, 2026.

Transparency log

Security for mnemotree 1.0.1

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.1.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 3, 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