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
The systems that turn 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.
Open loads a saved map of where each memory lives and replays only the log since the last checkpoint: 859 ms down to 43 ms on 20,000 memories on a local SSD. MQL filters on type, tag and agent come from the bitmap index, so WHERE type = episodic LIMIT 10 loads 10 memories at any size, and ORDER BY salience DESC LIMIT loads only the top candidates, from a salience cache that can be warmed in the background after open. Salience filters see the current decayed value, and a malformed filter is an error.
Best practicesNamed databases per tenant, tokens scoped to read, write or maintenance and to database name patterns, public key verification, built in HTTPS, clean shutdown on SIGTERM, request deadlines, per caller rate limits, liveness and readiness probes, and a non root Docker image pinned by digest.
Self host itChange a memory's attributes, tags or validity in place, or supersede it: the replacement is stored, the old memory is closed and kept for history, and an edge links the two.
API referenceOne call runs hybrid search over up to 32 databases the token can read, embedding the query once, with each database's heads up context if you ask.
API referenceOn ECS or EKS the server embeds and extracts through AWS Bedrock with the task's IAM role. No API keys, no model download.
Set it upWhen a fact is superseded or corrected and its confidence drops, the memories that depend on it through Caused and Supports links lose a damped share of that drop. The memory that replaced it is never lowered.
How it worksStoring a memory that repeats one already stored returns the existing memory's id, marked as a duplicate, instead of writing a copy.
Memories tagged scope:always never fade and are never archived. Contradictions either supersede the older memory or, in flag mode, keep both and link them so you decide.
Claude Code hooks queue notes and send them in batches. After a timeout the next batch is smaller, so a slow server never jams the queue.
The hosted dashboard shows memory health by band, memories by type, and memories and recalls by project.
Extraction defaults to Claude Haiku 5.5 and reading to Sonnet 5.5, with an output budget sized for thinking models that fails with a clear error instead of a partial answer.
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 an MCP server with 32 tools across 5 categories in local mode (the 4 essential ones by default, all 32 with --full-tools), and a hosted endpoint with 14 tools for cloud memory. 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_turnstore_memorysearch_memoriesrecall_memoryget_memoryforget_memoryforget_allingest_conversationprocess_turn also triggers sleeptime enrichment when an LLM provider is configured
assemble_contextget_statsrelate_memoriesget_relatedfind_pathget_subgraphfind_contradictionspropagate_beliefconsolidate_memoriesapply_decaycompress_memoryevaluate_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. The setup command configures Claude Code (hooks), Claude Desktop, Cursor, and Copilot CLI; other clients use a manual config.
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.
The engine is Apache-2.0. Read every line, run it yourself, fork it. Self-hosting depends on nothing closed.
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 number comes from a script in the open repo that you can run yourself; performance is 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.
6/6 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)
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
34%
More memories per budget than markdown
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.