Long-term memory for AI coding tools via vector search (Qdrant).
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
Long-term memory for AI coding tools.
Your AI forgets everything when the session ends. NaN Forget fixes that.
That's it. The wizard installs Ollama, embeddings, Claude hooks, MCP config, and a project AGENTS.md for Codex-style agents. Restart Claude Code or reopen Codex. Your AI now remembers.
No API keys needed. No Docker needed. Runs locally. Free forever.
~/.nan-forget/memories.db. Aging memories get automatically compacted into long-term entries.You never call save or search manually. Here's what happens behind the scenes:
| Event | What fires | What happens |
|---|---|---|
| Session starts | memory_sync | Lightweight handshake β checks health, loads stats, lists projects. No heavy search. |
| You send a message | UserPromptSubmit hook | nan-forget recall auto-searches memory for relevant context and injects it into the conversation. |
| You discuss a topic | memory_search | Claude searches the DB dynamically whenever relevant context might exist β like how you recall things on-demand. |
| Claude learns something | memory_save | Claude saves decisions, preferences, and facts immediately. Tool descriptions tell Claude "you MUST call this." |
Claude writes a .md file | PostToolUse hook | memory-sync.js intercepts the write, parses frontmatter, and auto-saves it to SQLite via nan-forget add. |
| Session ends | SessionEnd hook | session-end.js scans the conversation transcript for unsaved decisions/facts and saves the top 5 to the DB. |
| Every 10 saves or 24h | Auto-consolidate | Aging memories get clustered and compacted into long-term entries. Originals are archived. |
Four layers of protection ensure nothing is lost:
Codex and similar agents work well with nan-forget, but they usually need instruction files or shell/API fallbacks instead of Claude's hook model:
npx nan-forget setupAGENTS.md in your repo. It tells Codex-style agents to sync, search, save, and checkpoint automatically.localhost:3456 or local commands like nan-forget sync, nan-forget search, nan-forget add, and nan-forget checkpoint.The REST API and CLI now mirror the important memory workflows closely enough that memories saved by Claude are searchable from Codex and vice versa.
Type these in Claude Code:
| Command | What it does |
|---|---|
/nan-forget | Load context from past sessions |
/nan-forget stats | Show memory health |
/nan-forget clean | Run garbage collection |
/nan-forget compact | Force memory consolidation |
/nan-forget health | Check if services are running |
/nan-forget start | Start all services |
Claude uses MCP. Codex can use AGENTS.md plus CLI/REST fallback:
Codex, Cursor, and Claude all share the same memory database.
Everything below is for developers who want to understand how nan-forget works under the hood.
LLMs have no memory between sessions. Every conversation starts from zero. You re-explain your stack, Claude contradicts decisions from last month, and context disappears when the session ends.
Existing solutions (Mem0) target app developers embedding memory into products. We target you β the developer using AI tools daily who wants AI that just remembers.
Short-term memory = Claude's built-in .md files. Disposable. Current session only.
Long-term memory = SQLite database with sqlite-vec vector search. Single file. Permanent. Searchable across all sessions, all projects, all LLM tools.
Three hooks handle memory automatically:
.md file writes and saves them to the DB.nan-forget recall on every user message, auto-searching memory for relevant context.Memory search follows the same path as human recall:
| Stage | What happens | Cost |
|---|---|---|
| Recognition (blur) | Prefetch 50 candidates, return top 5 summaries. Cheap. | 1 vector search |
| Recall (clarity) | Fetch full content. Expand search cross-project (no project filter). | N point lookups |
| Association | Centroid-based related-memory search over sqlite-vec. Spreading activation from positive IDs. | 1 vector search |
Scoring formula:
High-confidence memories (debate-validated, human-approved) decay much slower and rank higher. A core memory at 0.85 confidence decays at ~15% of normal rate β effectively permanent unless superseded. Cross-project search means auth decisions from Project A surface when you work on Project B.
Aging memories don't just get deleted β they get compacted into long-term entries:
Triggers automatically after every 10 saves or 24 hours. No user action needed.
| Tool | Purpose |
|---|---|
memory_sync | Lightweight session handshake: health check + stats + project list |
memory_save | Save a memory (auto-called by Claude, proactively) |
memory_search | Semantic search with 3-stage retrieval (depth 1-3) |
memory_get | Fetch a specific memory by ID |
memory_update | Change content, type, or tags |
memory_archive | Soft-delete (hidden from search, never truly deleted) |
memory_consolidate | Force consolidation of aging memories |
memory_clean | Garbage collection (decay, dedup, expiry, MEMORY.md sync) |
memory_stats | Memory health dashboard |
memory_health | Check if Ollama, REST API are running |
memory_start | Boot Ollama + REST API |
memory_checkpoint | Save full problemβsolution context after completing a task |
memory_compress | Compress persisted .md memory files to minimal stubs |
memory_save accepts structured fields for richer vector representation:
| Field | Type | Purpose |
|---|---|---|
content | string | Full description (required) |
type | string | fact, decision, preference, task, context |
project | string | Project name |
problem | string | What was the challenge |
solution | string | How it was solved |
concepts | string[] | Searchable tags (["auth", "jwt", "middleware"]) |
files | string[] | Files involved (["src/auth.ts"]) |
confidence | number | Trust level 0.0β1.0 (default based on provenance) |
provenance | string | save, checkpoint, debate, human |
tier | string | regular or core (auto-derived from provenance) |
All fields are embedded together into a single vector. Searches for "JWT auth bug" find memories tagged with those concepts even if the content text doesn't match literally.
Not all memories are equal. Debate-validated and human-approved memories are core β they decay slower, rank higher in search, and survive garbage collection longer.
| Provenance | Default Confidence | Auto Tier | Decay Rate |
|---|---|---|---|
save | 0.5 | regular | Normal (30-day half-life) |
checkpoint | 0.65 | regular | ~35% slower |
debate | 0.85 | core | ~85% slower |
human | 0.95 | core | ~95% slower |
Core memories are designed for the upcoming nan-debate system β multi-AI debate results validated by human approval get persisted as high-trust knowledge that almost never fades.
After completing a task, call memory_checkpoint with task_summary, problem, solution, files, concepts, and project. Saves the full problemβsolution context to long-term memory. Every completed task = one checkpoint.
memory_compress scans .claude/projects/*/memory/ for .md files already persisted to the DB. Persisted files are replaced with minimal stubs. Reduces context window bloat.
Shares the same SQLite database as the MCP server β memories saved by Claude are searchable from Codex and vice versa.
Get the system prompt for any LLM:
| Provider | Model | Dimensions | Cost |
|---|---|---|---|
| Ollama (default) | nomic-embed-text | 768 | Free, local |
| OpenAI | text-embedding-3-small | 1536 | Your API key |
Auto-detection: Ollama running? Use it. Not running? Check for OPENAI_API_KEY. No config needed.
All data lives in a single SQLite file at ~/.nan-forget/memories.db. No Docker, no services, no data loss on updates.
user_id, status, project, typenan-forget export dumps all memories as JSON.All cleanup is deterministic. No API calls. No LLM inference.
expires_at dateCore memories (confidence β₯ 0.85) survive GC far longer than regular ones because their decay formula dampens the time factor: decay^(1 - confidence). A 0.85-confidence memory at 200 days still has a decay weight above 0.1.
NaN Forget is built around three principles: lightweight, automatic, and local.
No Docker. No cloud services. No background processes eating RAM. The entire storage layer is a single SQLite file (~3 MB). Embeddings run through Ollama, which you likely already have. Memory operations (save, search, dedup, GC) use zero LLM calls β all deterministic.
Four hooks capture context at every stage of a session β you never call save manually:
.md file writes and persists themAging memories consolidate automatically. Duplicates merge. Unused memories decay on a 30-day half-life. No maintenance required.
Your data stays on your machine in ~/.nan-forget/memories.db. No accounts, no API keys required (Ollama is free and local), no telemetry. Backup is copying one file. Works across Claude Code (MCP), Codex/Cursor (REST API), and the terminal (CLI) β same database, same memories.
Most AI memory solutions (Mem0, claude-mem) are designed for app developers embedding memory into products, or require Docker/cloud services to run. NaN Forget is designed for you β the developer using AI tools daily who wants context that persists across sessions without managing infrastructure.
Key design differences:
problem, solution, concepts, and files fields β searches find related context even when keywords don't matchnpx nan-forget setup), no Docker, no containers, no services to manageMIT License.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/nan-forget)<a href="https://allmcps.com/mcp/nan-forget"><img src="https://allmcps.com/api/badge/nan-forget?style=directory" alt="Nan Forget on AllMCPs" /></a>