Long-term memory for AI agents: a managed API, or a Rust engine you self-host. One call per turn stores what was said and returns the memories for your next prompt. Engineered from scratch, not a wrapper: a real storage engine.
Hosted: get an mdb_ API key and call the endpoint. Self-host: pip install mentedb or run the server. Same process_turn either way.
AI has a memory problem
Current AI systems consume context in a single pass with no ability to revisit, reflect, or recognize what they are missing.
AI gets a single context window. No re-reading, no follow ups. Every token must count.
AI can't sense what it doesn't know. It can't feel uncertainty or detect its own knowledge gaps.
AI reads linearly but attends associatively. Raw text dumps waste compute on noise.
Your AGENTS.md has limits, and we measured them
We tested real public agent files from OpenAI, Kiali and Temporal. With the whole 70 KB file in context the model followed 80 percent of the file's own rules. Delivered from memory, the same rules hit 100 percent at 2 to 8 times fewer tokens, and the cost per turn stays flat no matter how large the file grows.
See the dataYour AI reads every conversation and decides what is worth remembering. Facts, preferences, decisions, and corrections are stored without you lifting a finger.
"What did we decide about auth?" works via embeddings, not string matching. MenteDB finds relevant memories even when you use different words.
If you said Postgres last month and MySQL this month, MenteDB flags the inconsistency. A static file cannot detect when your decisions change.
Past mistakes surface automatically when you are about to repeat them. Anti-patterns you recorded are matched against your current context.
Your laptop and desktop share the same brain. Cloud mode means every device sees every memory instantly.
We measured the breaking point: a 70 KB AGENTS.md fully in context cost 17,500 tokens per turn and the model still missed a fifth of its own rules. Through memory the same rules hit 100 percent at a fraction of the tokens.
One memory, every tool you already use
Setup for each is in the docs.
Capture, reconcile, recall
You send conversation turns. MenteDB does the remembering, with nothing to tune.
Your agent's turns stream in. MenteDB extracts atomic facts automatically, no manual tagging or schema wrangling.
New facts are deduplicated, contradictions are resolved, stale beliefs decay, and everything links into a knowledge graph, with no nightly job to babysit.
At query time it assembles a bounded, ranked context in a single pass, so your model sees exactly what matters and nothing else.
A cognitive engine, not just storage
Sixteen core systems that transform MenteDB from a database into an active participant in your AI's reasoning.
Swap one base URL and any OpenAI or Anthropic compatible client gets persistent memory: context injected before the model responds, every turn captured after, your provider key passed through untouched.
Set it upIngest any CLAUDE.md, AGENTS.md or .cursorrules once and your rules become memories that arrive when they matter. Measured on real public files: 100 percent of rules followed at 2 to 8 times fewer tokens than carrying the file every turn.
See the dataBackground pipeline extracts semantic facts, links entities, detects communities, and builds user profiles from raw conversations. Like the brain consolidating memories during sleep.
Continuous memory ingestion with real time belief updates as conversations unfold.
Automatically derives new knowledge from stored memories at write time, not query time.
Maps conversation paths through topic space to predict where dialogue is heading.
Detects knowledge gaps and creates placeholder memories so the AI knows what it does not know.
Prevents contradictory memories from polluting context by isolating conflicting beliefs.
Records negative feedback and emotional triggers to prevent the AI from repeating mistakes.
Predicts upcoming queries and pre builds context windows, like branch prediction for knowledge.
Memories carry valid_from/valid_until timestamps. Temporal invalidation instead of deletion, with point-in-time queries.
LLM judges whether new memories invalidate, update, or are compatible with existing ones. 100% accuracy on 62 test cases.
BM25 + HNSW vector + RRF fusion for best-of-both-worlds retrieval. Keyword precision meets semantic understanding.
Run N nodes and they shard themselves: gossip membership, rendezvous placement, and single-writer lock handoff. No external coordinator, no routing to write. Write throughput scales linearly with the fleet.
Claude Code hooks make memory automatic on every turn. The claude.ai connector, ChatGPT, Cursor, and Copilot connect with one URL.
Rust, Python, and TypeScript bindings with native performance. pip install, npm install, or cargo add and start building.
Create, revoke, and monitor API keys from the dashboard. Scoped access control for teams and production deployments.
Get real-time notifications when memories change. HMAC-signed payloads with delivery logs, status tracking, and automatic retries.
The difference memory makes
Same user. Same question. Completely different experience.
Deploy to production
Running deploy script...
✗ Deploy failed — wrong AWS region
I told you LAST WEEK it's us-west-2!
Sorry, I don't have context from previous sessions.
🤦 This is the THIRD time...
Deploy to production
Deploying to us-west-2 (your production account)...
✓ Deploy successful
Simple by design
One call per conversation turn. MenteDB handles extraction, storage, retrieval, contradiction detection, and background enrichment automatically.
use mentedb::MenteDb;use mentedb::process_turn::ProcessTurnInput;use mentedb_context::DeltaTracker;let db = MenteDb::open("./agent-memory")?;let mut delta = DeltaTracker::default();// Pass agent_id + user_id to isolate each user's memory.let result = db.process_turn(&ProcessTurnInput {user_message: "I switched from Postgres to SQLite".into(),assistant_response: Some("Got it!".into()),turn_id: 0,project_context: None,agent_id: None, // scope to an agent (optional)session_id: None,user_id: None, // scope to a user, isolated from all others (optional)}, &mut delta)?;// result.context — memories ready for your prompt// result.facts_extracted — what was learned// result.contradiction_count — conflicts detected// Sleeptime enrichment runs automatically in the background:// → semantic facts extracted from conversations// → entities linked and deduplicated// → community summaries generated// → user profile built and updated
Six layers, one engine
A purpose built stack where every layer is designed for AI memory, from storage pages to cognitive processing.
The database shards itself
Run N nodes and they self-organize into a sharded fleet: no router to run, no hash ring to maintain, no external coordination service. Write throughput scales linearly with the fleet.
Each node gossips with a few peers to converge on the live set, with no external store and no consensus leader. A node that stops heartbeating drops out; a new one is picked up from a seed address or a headless DNS name. The Cassandra/Dynamo model.
Every node maps a user to its owner by rendezvous (highest-random-weight) hashing, computed identically everywhere, so a request reaches the same owner from any node. Add or remove a node and only about 1/N of users move, not the full reshuffle a hash % N ring forces.
Ownership is the single-writer lock: when a user re-homes, the old owner releases it and the new owner takes it. A user's database is only ever written by one node, so handoff moves the lock, not the data.
MENTEDB_SHARDING=1 \
MENTEDB_NODE_ADDR=http://node-1:6677 \
MENTEDB_SEEDS=node-0,node-1,node-2 \
mentedb-serverOff by default; a single node behaves exactly as before. Zero-copy handoff assumes shared storage; on local disks placement still routes, but data does not migrate on a rebalance yet.
Watch it like a real database
Not a black box. Every node exports the signals you expect from a database — write and read throughput, cache hit ratio, recall latency, storage and index growth — in Prometheus format, so they land in the tools you already run.
Scrape with Prometheus + the bundled Grafana dashboard, or the one-command docker-compose stack. Reference →
Aggregate only, with no per-account labels — safe to scrape, cheap to store. On the managed cloud the same series flow to CloudWatch.
MenteDB ships a production MCP server with 32 tools across 6 categories. Connect Claude, Cursor, ChatGPT, or any MCP client in seconds — locally via stdio or remotely via Streamable HTTP.
Cloud endpoint: https://api.mentedb.com/mcp
process_turnstoresearchrecallgetforgetforget_allprocess_turn also triggers sleeptime enrichment when an LLM provider is configured
search_textsearch_vectorsearch_by_tagrelateget_relatedfind_pathget_subgraphfind_contradictionspropagate_beliefconsolidateapply_decaycompressevaluate_archivalextract_factsgdpr_forgetrecord_paindetect_phantomsresolve_phantomrecord_trajectorypredict_topicsdetect_interferencecheck_streamwrite_inferenceregister_entityget_cognitive_state$ npx mentedb-mcp@latest setup setup # also: claude-code (hooks), claude, cursor
$ npx mentedb-mcp@latest login
Local mode: Works with any MCP-compatible client via stdio: Claude Desktop, Cursor, Claude Code by default. Copilot CLI, Cursor, VS Code, custom agents via explicit setup targets.
Cloud mode: Connect via Streamable HTTP MCP at https://api.mentedb.com/mcp — works with ChatGPT, remote clients, and any environment that supports HTTP MCP.
Privacy is the architecture, not a checkbox
Self-host and your conversations never leave your servers. Use the managed cloud and they stay isolated and out of any training set. You choose the trust model.
Self-host and your memories never leave your servers. On the managed cloud, every account is isolated. No shared pool, no mystery retention.
Self-host with your own LLM and embedding keys on your own hardware. Prefer managed? The cloud runs the models for you. Either way, your data is never used to train anything.
Apache-2.0, top to bottom. Read every line, run it yourself, fork it. There is no closed core you have to trust.
Per-account and per-agent scoping is enforced in the engine, so one owner's memory can never bleed into another's.
Simple, transparent pricing
Start free in the cloud. Upgrade when you need more, or self-host the open-source engine for free, forever.
Persistent memory for your AI agents, in the cloud.
For individuals who have outgrown the free limits.
For power users running serious agent workloads.
For teams sharing memory across people and agents.
Run the open-source engine on your own infrastructure. No seat or usage caps, all 7 cognitive features, your LLM keys and your hardware, and your data never leaves it. Docker or a single binary, Apache-2.0 licensed.
Point any OpenAI or Anthropic compatible client at MenteDB and every conversation gets memory. Your provider key passes through untouched and model tokens are billed by your provider, never by us. Each proxied conversation turn counts as one memory turn against your plan's monthly limit, the same as every other integration.
Measured, not promised
Every claim backed by reproducible tests. Quality validated on every commit, performance measured with Criterion.
LongMemEval (ICLR 2025) is the standard benchmark for long-term conversational memory: 500 questions across six reasoning types over long, multi-session histories (~115K tokens each). Graded by the official judge, unmodified.
7/7 passing
Superseded memories correctly excluded via graph edges
90.7% reduction in memory retrieval tokens over 20 turns
100 turns, 3 projects, 0% stale returns, 0.29ms insert
U-curve ordering maintains 100% LLM compliance
100% useful memories vs 80% naive (+20pp improvement)
100% correct on stale beliefs, 4.8x faster than brute-force scan
10,000 memories, 6/6 belief changes tracked, 0 stale returns
Measured across memory counts
| Benchmark | 100 | 1,000 | 10,000 |
|---|---|---|---|
| Insert (per memory) | 130us | 244us | 265us |
| Context Assembly (per query) | 217us | 342us | 693us |
Same 25 memories, different formats
| Format | Tokens | vs Raw JSON |
|---|---|---|
| Raw JSON | 947 | — |
| Structured | 576 | 1.6x fewer |
| Compact | 414 | 2.3x fewer |
~80%
Delta savings over 20 turns
30%+
More memories per budget
One command. Persistent memory.
Sets up Claude Code hooks by default. Also works with claude.ai (connector), Copilot, Cursor, and any MCP client.
Or connect via HTTP: https://api.mentedb.com/mcp
Frequently asked questions
MenteDB is a database engine built specifically for AI agent memory. Instead of dumping raw text into a vector store, it keeps structured memories in a knowledge graph, deduplicates and reconciles contradictions, and assembles the right context in a single pass. It is written in Rust and runs as a real database, not a wrapper around one.
Still have a question, or hit an issue? Open an issue on GitHub.