# Persistent memory for Claude Code that survives context compaction

> Source: <https://mentedb.com>
> Published: 2026-07-11 21:07:20+00:00

A Rust database that pre digests knowledge for single pass transformer consumption. Not a wrapper. A ground up storage engine that thinks.

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.

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(); 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,    session_id: None,}, &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_turn`

`store`

`search`

`recall`

`get`

`forget`

`forget_all`

process_turn also triggers sleeptime enrichment when an LLM provider is configured

`search_text`

`search_vector`

`search_by_tag`

`relate`

`get_related`

`find_path`

`get_subgraph`

`find_contradictions`

`propagate_belief`

`consolidate`

`apply_decay`

`compress`

`evaluate_archival`

`extract_facts`

`gdpr_forget`

`record_pain`

`detect_phantoms`

`resolve_phantom`

`record_trajectory`

`predict_topics`

`detect_interference`

`check_stream`

`write_inference`

`register_entity`

`get_cognitive_state`

``` bash
$ npx mentedb-mcp@latest setup setup
  # also: claude-code (hooks), claude, cursor
bash
$ 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.

Simple, transparent pricing

Start free. Upgrade when you need more.

Get started with persistent memory for your AI agents.

For power users and teams who need more capacity.

92%

LongMemEval Accuracy (500 Q)

0.29ms

Avg Insert

<1ms

Context Assembly at 10K

2.3x

Fewer Tokens (Compact)

0%

Stale Beliefs Returned

Measured, not promised

Every claim backed by reproducible tests. Quality validated on every commit, performance measured with Criterion.

[LongMemEval](https://arxiv.org/abs/2410.10813) (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 | 13ms | 244ms | 2.65s |
| Context Assembly | 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.

``` bash
$ npx mentedb-mcp@latest setup  # Claude Code hooks by default; or copilot, claude, cursor  ✓ MCP config written  ✓ Agent instructions installed  ✓ Ready — your AI now has persistent memory.   # Optional: log in to sync memory across devices$ npx mentedb-mcp@latest login  ✓ Cloud sync enabled
```

Or connect via HTTP: `https://api.mentedb.com/mcp`
