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. 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 agent.md has limits
Static instruction files work for small projects. But as context grows, decisions accumulate, and you work across devices, you need something that actively manages knowledge for you.
Your 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.
An agent.md works until it is too big for the context window. MenteDB stores thousands of memories and retrieves only the relevant ones via vector search.
Three steps, zero babysitting
You send conversation turns. MenteDB does the remembering.
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.
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
Fifteen core systems that transform MenteDB from a database into an active participant in your AI's reasoning.
Background 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.
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.
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.
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.