Offline persistent memory for AI coding agents β 37 tools, 80% fewer calls, no LLM
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)
English | EspaΓ±ol | δΈζ | ζ₯ζ¬θͺ | νκ΅μ΄ | PortuguΓͺs (BR) | Deutsch | FranΓ§ais
The Continuity Layer for AI Agents β AI agents shouldn't have to relearn your project every session.
Ever had that feeling where your AI agent forgets everything from yesterday's session? You explain the same architecture decision for the third time, and it still suggests the approach you already rejected?
toon-memory fixes this. It's the Continuity Layer for AI Agents β a lightweight system that preserves your project's knowledge, decisions, and conventions across sessions, so every session starts where the last one ended. Fully local and private, over MCP β no cloud, no server.
| Scenario | What toon-memory does |
|---|---|
| Design debates | "We chose Redis over Memcached because of pub/sub support" |
| Framework choices | "This project uses Zod for validation, not Joi" |
| Bug fixes | "Redis pool exhaustion β fix was max_connections=20" |
| Architecture notes | "Broker service uses RESP protocol, not HTTP" |
| Onboarding | "The deploy script lives in scripts/deploy.sh" |
| Team context | "PR #142 reverted the caching change β don't re-add it" |
Read How toon-memory Makes Your AI Agent Smarter to see a real-world demo of persistent memory in action.
memory_smart_recall (unified recall with session bias), memory_sessions for multi-session coordination, context_* tools for one-call context generation (briefing, diff, focus, health audit, export), memory_compress (LLM-powered compression), memory_consolidate (deterministic dedup/merge/cleanup), memory_primer (auto-injected context), memory_merge_sessions (cross-session merge), memory_pin/memory_unpin (pin important entries with priority 1-5), memory_checkpoint (session snapshot with 7d TTL), memory_search (unified search with tag filters + session bias), memory_tag (batch tag operations), memory_export_gist/memory_import_gist (GitHub Gist sync), memory_secret (encrypted secrets vault), memory_export_global/memory_import_global (cross-project conventions), memory_forget (soft/hard delete, restore, supersede), memory_reflect (staleness/quality reflection), and memory_promote (auto-promote low-confidence drafts).toon-memory/memory/ to .gitignorelinks/[[key]] refs; memory_recall can expand a relationship-aware subgraph for more precise, lower-token recall (no embeddings, no LLM)memory_recall({ compact: true }) returns numeric-indexed entries, drops id/date/file, renders graph edges as ->2, and truncates graph neighbors to snippetstoon-memory init scans package.json/Cargo.toml/requirements.txt/go.mod and writes a project vocabulary so entries mentioning a dependency get auto-tagged with itmemory_smart_recall combines BM25 + graph + decay + quality in one call; the LLM calls this at the start of every taskkey merges attributes (union of tags, max confidence, latest date, combined links) instead of overwritingmemory_compress uses AI to summarize long entries; memory_consolidate(mode: "low-quality") does batch cleanup deterministicallymemory_merge_sessions merges observations across parallel sessions for a filememory_export_gist and memory_import_gist sync memory entries via GitHub Gist (zero dependencies)config.verbatim preserves original entries instead of overwriting on savecontext_generate (full briefing), context_diff (incremental), context_focus (targeted), context_health (audit), context_export (markdown) β each replaces 5-6 manual tool calls. Zero LLM, pure deterministic aggregationsystemPrimer(), showing top 5 memories for instant contextpath_scope); recall filters by scope automaticallybudget: "tiny" (key+1 line, ~50 tokens), "normal" (compact with tags/edges), "deep" (all fields with origin/scope/status). Backward compatible with compact: truehuman, agent, inferred); human assertions get a quality boostmemory_forget soft-deletes by default (sets status=obsolete). Restore with memory_forget(key, action: "restore"), hide with action: "soft", permanent removal via action: "hard"context_health now detects missing-evidence (path_scope without file) and stale-claims (overlapping content in same category)superseded_by, supersedes, relates), written as type:key in the graph. Explicit links become relates:key, so you can tell how entries are related, not just that they arek = clamp(3..60, round(sqrt(n))). Benchmark (8 gold queries): nDCG 0.776, MRR 0.917 β exact parity with the previous linear scoring. Pass rrf: false to fall backmemory_reflect ranks entries by staleness, quality, and over-connection to surface what needs attention or cleanup. Deterministic, zero LLMmemory_forget(key, action: "supersede", new_key) marks an entry as replaced by a newer one (superseded_by link + supersededOn date). memory_recall({ as_of }) re-includes old entries for point-in-time queries before their supersessionmemory_promote promotes low-confidence drafts to active entries deterministically (threshold 0.65, Jaccard dedup), with dryRun by defaultmemory_recall/memory_smart_recall accept explain: true and append a deterministic reason line to every returned entry (β³ 100% relevance Β· used 14Γ Β· used today Β· importance HIGH) β why it was retrieved, no LLMbudget_tokens caps the recall output by estimated token count; entries accumulate greedily and the tail that would exceed the budget is dropped (0 = no limit)memory_consolidate(mode: "versions") detects entries describing the same subject at different library versions (e.g. "Use React 18" vs "Use React 19") and retires the older ones in favor of the newestwarning category for "do NOT do this" facts; warning entries get a recall boost so the agent sees the landmines before repeating thempath_scope matches the current filememory_remember({ importance }) sets critical, high, medium, or low. Critical decisions surface first (+0.3), low notes stay out of the way (β0.1); empty = auto (recency + frequency). Re-saving keeps the higher levelmemory_remember save is annotated with an evidence level: verified when its referenced file exists on disk, unverified when it doesn't, conflict when it overlaps a warning or critical/high decision. Conflicts get a +0.15 recall boost (verified +0.03, unverified β0.02) and a β οΈ CONTRADICTION warning on save β but never block the writememory_secret stores credentials in an encrypted sidecar (secrets.toon, AES-256-GCM) so data.toon stays a readable open format while sensitive values never hit plaintextmemory_export_global writes project memory to ~/.toon-memory/memory/global.toon; memory_import_global pulls cross-project conventions back with a one-shot, deterministic, offline merge (never a live dual source)@inquirer/checkbox/select/confirm); the MCP SDK, zod, and the TOON parser are bundled into the shipped binary β a single npm i -g downloads ~1 MB (was ~14 MB) and lands ~4.4 MB on disk (was ~33 MB)Tip: The npm install is the most reliable method. The curl/irm scripts are convenience wrappers.
Size: A bare
npm i -g toon-memorydownloads ~1 MB and installs ~4.4 MB β three tiny prompt packages; everything else (MCP SDK, zod, TOON parser) ships bundled.
The installer will:
That's it! In your next agent session, try:
Tip: Always run
memory_recallat the start of a session. Your agent will have context from previous sessions instantly.
Add to .cursor/mcp.json:
Add to claude_desktop_config.json:
Add to ~/.codeium/windsurf/mcp_config.json:
| Agent | Config Location | Format | Hooks | Auto-Setup |
|---|---|---|---|---|
| OpenCode | .opencode/opencode.json + .opencode/plugins/toon-memory.ts | Plugin | SessionStart (plugin, no top-level hooks) | β |
| VS Code / Copilot | .vscode/mcp.json | JSON | β | β |
| Claude Code | .mcp.json (MCP) + .claude/settings.json (hooks) | JSON | SessionStart + PostToolUse + Stop | β |
| Cursor | .cursor/mcp.json | JSON | β | β |
| Windsurf | ~/.codeium/windsurf/mcp_config.json | JSON | β | β |
| Cline | .cline/mcp.json | JSON | β | β |
| Continue | .continue/config.json | JSON | β | β |
| Codex CLI | .codex/config.toml | TOML | SessionStart + PostToolUse + Stop ([[hooks]] event=) | β |
| Gemini CLI | .gemini/settings.json | JSON | SessionStart + PostToolUse + Stop (hooks.*) | β |
| Zed | ~/.config/zed/settings.json | JSONC | β | β |
| Antigravity | .agents/mcp_config.json + .agents/hooks.json | hooks.json | PreInvocation + PostToolUse + Stop (no SessionStart event) | β |
| Aider | β | β | β | π Instructions |
| KiloCode | ~/.kilocode/mcp_settings.json | JSON | β | β |
| OpenClaw | .openclaw.json | JSON | β | β |
| Kiro | .kiro/settings/mcp.json | JSON | β | β |
Tip: You can configure toon-memory for multiple agents at the same time. Each agent gets the same shared memory file at
.toon-memory/memory/.
| Tool | Description |
|---|---|
memory_remember | Save a decision, pattern, bug, knowledge, or warning (negative "do NOT do this" memory, recalled with a boost) β optional TTL, auto-tag inference, links to build the memory graph, merge-dedup on same key, auto quality score and confidence. Write-path intelligence: each save is annotated with an evidence level β verified when the referenced file exists on disk, unverified when it doesn't, conflict when it overlaps a warning or critical/high decision (recalled with a boost and surfaced with a β οΈ CONTRADICTION warning, but never blocks the write) |
memory_recall | Search memory (use BEFORE reading files, filters expired TTL). mode: "graph" expands a relationship-aware subgraph for higher precision. `budget: "tiny" |
memory_smart_recall | Unified recall: BM25 + graph + decay + quality in one call. sessionBias boosts entries from the current git branch. explain: true appends per-entry reasons, budget_tokens caps output by estimated tokens. Use at the START of every task. Returns compact, token-efficient output |
memory_forget | Lifecycle ops by key or id: action: "soft" (default) marks obsolete, "hard" permanently removes, "restore" brings back to active, "supersede" retires it with a superseded_by link to new_key |
memory_stats | View memory state (including TTL stats, quality distribution, origin/status breakdown, cold memories below quality/access thresholds, and hit rate / duplicate / obsolete metrics) |
memory_summary | Save/retrieve file summaries |
memory_archive | Archive old entries (>30 days) and expired TTL entries |
memory_diff | Show changes since a date (24h, 7d, or exact date) |
memory_suggest | Find related entries for a given context |
memory_encrypt | Enable AES-256-GCM encryption |
memory_decrypt | Disable encryption |
memory_backup | Create timestamped backup of memory file (auto-prunes to 10 most recent) |
memory_captured | List activity auto-captured by hooks (opt-in) or clear the log |
memory_checkpoint | Session checkpoint: creates a snapshot of current memory state with 7d TTL. Useful for rollback reference during long sessions |
memory_consolidate | Cleanup ops, deterministic (no LLM): mode: "identical" (default) dedupes identical-content entries, "similar" merges near-duplicates (Jaccard >50%), "low-quality" batch-removes low-quality entries (minQuality, dryRun), "versions" retires older library-version entries in favor of the newest |
memory_sessions | Show active agent sessions (branch, files, last-seen) and soft conflicts for parallel work |
memory_compress | LLM-powered two-step compression: summarize + overwrite. Uses anthropic/openai CLI if available, otherwise returns prompt for manual compression |
memory_primer | One-call context primer: top memories + categories + session file changes. Auto-injected at session start |
memory_merge_sessions | Merge observations across parallel sessions for a file. Deduplicates and optionally auto-promotes to memory |
memory_export_gist | Export memory entries to a GitHub Gist (public or private). Uses GITHUB_TOKEN or gh CLI |
memory_import_gist | Import entries from a GitHub Gist. Merges with existing entries (union of tags, max confidence) |
memory_secret | Encrypted secrets vault (secrets.toon, AES-256-GCM): store/get/list/forget. Keeps data.toon readable while sensitive values stay encrypted at rest. Requires TOON_MEMORY_KEY |
memory_export_global | Write current project memory to the global file (~/.toon-memory/memory/global.toon). One-shot share of cross-project conventions |
memory_import_global | Merge cross-project conventions from the global file into this project (one-shot, deterministic, offline). merge: false replaces instead |
memory_graph_path | BFS shortest path between two entries in the knowledge graph. Shows how concepts are connected |
context_brief | One-call context briefing: memory + sessions + health in compact markdown. Use instead of 5-6 separate memory_* calls. Zero LLM, pure deterministic aggregation |
context_generate | Full project briefing: combines project structure, git state, memory entries, and active sessions in one call. Replaces 5-6 manual tool calls |
context_diff | Incremental briefing: git commits + modified files + new/updated memory + active sessions since last session |
context_focus | Hyper-focused briefing: only relevant memory + related source files + callers + test files for a query |
context_health | Memory health audit: orphan links, duplicates, broken file refs, expired TTL, stale sessions, score 0β100 |
context_export | Export memory as markdown: injectable context for system prompts (full or compact) |
memory_pin | Pin an entry with priority 1-5: pinned entries always appear first in recall results sorted by priority, even without a keyword match |
memory_unpin | Unpin an entry: remove the priority flag |
memory_search | Unified search with filters: same as memory_recall plus category, tags, from_date, to_date filters. Tag filter uses AND logic β all specified tags must match. budget controls output verbosity. path_scope filters by glob pattern. sessionBias boosts entries from the current git branch |
memory_tag | Batch tag operations: add, remove, or set tags on one or more entries by key or id |
Memory is also exposed as MCP resources for direct context reading:
| Resource | URI | Description |
|---|---|---|
| Memory Entries | toon://memory/entries | Full memory dump |
| Current Memory | toon://memory/current | Current memory state with recent entries |
| Memory Stats | toon://memory/stats | Category counts and TTL info |
| System Primer | toon://memory/summaries | Auto-generated knowledge map (top entries, categories, patterns) |
| Prompt | Description |
|---|---|
summarize_project_context | Analyze current TOON memory and generate a compact project summary. Optional intent parameter to focus on a specific area |
Tip: Use descriptive keys like
use-zodinstead of vague ones likevalidation. Your agent searches by key and content, so specificity helps. Saving with the same key auto-merges (union of tags, max confidence).
Tip: Use TTL for temporary context like deadlines, sprint info, or time-sensitive notes. Entries with expired TTL are automatically filtered from search results.
Tip: Mark foundational decisions
criticalso they always rank near the top of recall.importanceacceptscritical,high,medium, orlow; leave it empty to let the system rank by recency and frequency automatically.
Tip: Leave
tagsempty and the system will infer them from your content using a built-in vocabulary of 20+ categories (redis, auth, api, db, security, etc.) plus a project vocabulary derived from your dependencies atinittime. So if your project depends onredis, any entry mentioning "redis" gets auto-taggedredis.
Tip: Search before you read files. This saves tokens and gives your agent context it wouldn't get from code alone. Quality-weighted ranking ensures the most useful entries surface first. Or use
memory_smart_recallfor a more comprehensive result.
Tip: Use date filters when you remember roughly when something happened but not exactly what. Quality-weighted ranking still applies.
Tip: Run this periodically to keep memory lean. Archived entries are still searchable via
memory_recallwith date filters. Entries with expired TTL are also archived automatically. Low-quality entries get lower recall priority. Low-quality entries get lower recall priority.
Tip: Use
memory_diffat the start of a session to see what your agent learned since you last worked on the project. New entries include quality scores. New entries include quality scores.
Tip: Use
memory_suggestwhen you need context about a topic but aren't sure what to search for. Or usememory_smart_recallfor a more comprehensive result.
Tip: Use
memory_smart_recallat the START of every task. It combines BM25 + graph + decay + quality in one call β no need to guess what to search for.
The β³ reason line is deterministic (relevance %, access count, last-used, importance) β no LLM involved. Use explain: true when you want to know why the agent was shown those entries.
budget_tokensTip: Combine
budget_tokenswithbudget: "deep"for a context window that stays inside a hard token ceiling regardless of memory size.
Tip: Use
context_generateat the start of a session to get full context in one call. Replaces 5-6 separate tool calls.
Tip: Run
context_healthwhen memory feels cluttered. Shows orphan links, duplicates, expired TTL entries, broken file references, missing-evidence entries (path_scope without file), and stale claims (overlapping content).
When you save with the same key, attributes are merged instead of overwritten:
Tip: Use descriptive, stable keys. The same key = merge, different key = new entry.
Every entry gets an automatic quality score (0β1) based on structure:
| Factor | Weight | What it measures |
|---|---|---|
| Tags | 0.3 max | More specific tags = higher quality |
| Links | 0.2 max | Connected entries = higher quality |
| Content length | 0.3 max | Detailed > vague |
| Recency | 0.1 max | Recent entries score higher |
| Specificity | 0.1 max | Unique words vs repeated words |
| Origin | +0.1/β0.05 | Human assertions boosted, inferred slightly penalized |
High-quality entries surface first in recall. Check quality with memory_stats:
Each entry tracks how reliable the information is:
| Source | Confidence | Meaning |
|---|---|---|
| User assertion | 1.0 | "We use Postgres" β direct statement |
| Inferred | 0.65β0.75 | Agent inferred from context |
| Uncertain | 0.50 | Agent is guessing |
Confidence is preserved on merge (max of both entries).
The System Primer is an auto-generated knowledge map exposed as an MCP resource. Agents load it at session start for instant context:
Tip: Add
toon://memory/summariesto your agent's system prompt for instant context at session start.
Warning: The encryption key must be set via
TOON_MEMORY_KEYenv var before encrypting. Save it somewhere safe β if you lose it, your memory data is gone forever. Quality scores and confidence are preserved through encryption.
When you run several AI agent sessions in parallel (e.g. three OpenCode sessions on the same repo at once), they can accidentally clobber each other's work. toon-memory ships with memory_sessions, a file-based coordination tool that lets every session see what its siblings are doing β with no server, no network, and no LLM calls.
SessionStart hook writes a heartbeat file for the session at .toon-memory/memory/sessions/<id>.json. Each process writes only its own file, so there's no lock contention.memory_sessions toolconflictsOnly: true to skip the session list and show only soft conflicts:
SessionStart hook already prints the other active sessions and any soft conflicts.memory_smart_recall({ intent: "what I'm working on" }) to get full context (memory + graph + quality).memory_sessions() to see the full picture (branches, files, last-seen) and memory_sessions({ conflictsOnly: true }) if you only care about clashes.Tip: This is purely local and lock-free β safe to run as often as you like. Combine it with
memory_smart_recall({ intent: "project context" })at session start for both cross-session memory and cross-session presence. The system primer (MCP resource) also provides instant context.
When your memory grows, a flat keyword search can return either too much (every match) or the wrong context (no relationships). toon-memory can treat memory as a lightweight knowledge graph so recall returns the right entries with fewer tokens. Combined with quality scoring, the most useful entries surface first.
It's fully deterministic and offline β no embeddings, no vector DB, no LLM, no server. Edges come from two sources:
links β keys you declare when saving an entry.[[key]] refs β any [[some-key]] mention inside the content.memory_remember stores links on the entry (space- or ;-separated keys). Quality score is calculated automatically.memory_recall({ mode: "graph" }) finds keyword matches (seeds), then expands the ego-subgraph up to hops (1 or 2) along the edges.limit, default 6) β smaller, more precise context for the agent. Or use memory_smart_recall for a unified call.Tip: Use
mode: "graph"when a decision ripples across several entries (architecture, specs, related bugs). For isolated facts, the defaultflatmode is enough. Or usememory_smart_recallwhich combines graph + BM25 + quality automatically.
compact)When every token counts, pass compact: true to get a denser output:
How compact changes the output:
[1], [2], β¦) in score order.id, date, and file are dropped β only tags is kept.graph mode, edges render as ->2 (numeric, not key names)..toon file is never mutated β compact only reshapes the response.Tip: Combine
compact: truewithmode: "graph"for the smallest possible context window when recalling from a large, interconnected memory. For proactive/background recall, usebudget: "tiny"which returns just the key + one line (~50 tokens). Or just usememory_smart_recallwhich does this automatically.
Recall is deterministic and offline (no embeddings, no LLM). Each candidate entry gets a combined score:
id + category + key + content + file + tags + quality + confidence.d hops from a seed are multiplied by 0.5^d, so distant context ranks below nearby context.In graph mode, recall seeds on keyword matches, expands the ego-subgraph up to hops, and returns the top limit (default 6) by combined score. memory_smart_recall combines all these signals in one call.
On toon-memory init, the CLI scans your dependency manifests and writes a vocab table into .toon-memory/memory/config.json:
memory_remember then matches new entries against this vocabulary on top of the built-in one, so mentioning a dependency in your content auto-attaches its tag. More tags = higher quality score. Supported manifests: package.json, Cargo.toml, requirements.txt, pyproject.toml, go.mod.
Tip: Re-run
toon-memory initafter adding major dependencies to refresh the vocabulary. Thevocabkey is merged (never clobbered) with theencrypted/captureflags inconfig.json. More tags = higher quality score.
Visualize your memory as an interactive force-directed graph. See entries, their connections, categories, and access patterns at a glance.
Once open, press r in the terminal to reload from disk, or r / β» in the browser to refresh the page.
Call memory_visualize in any MCP Appsβcompatible host to render the graph inline β no server needed. The viewer appears as an interactive panel inside the chat interface.
| Interaction | Description |
|---|---|
| Hover a node | See tooltip with content preview, quality, access count |
| Click a node | Select + center + highlight neighbors |
| Double-click a node | Open the Detail panel |
| Drag a node | Reposition manually (right-click to unfix) |
| Search | Filter entries; matching nodes pulse with glow |
| βΏ Path finder | Click two nodes to find and highlight the shortest path |
| Zoom/pan | Mouse wheel or +/β buttons |
| β Physics | Adjust charge, link distance, center gravity |
| Theme toggle | Dark/light mode (persisted) |
| Export | Save graph as PNG or SVG |
| Graph view | Search highlights | Path finder | Detail panel |
|---|---|---|---|
![]() | ![]() | ![]() | ![]() |

Requires Playwright (npx playwright install chromium) and ffmpeg.
Here are some patterns that work well with toon-memory:
At the beginning of every new session, run:
This gives your agent instant context about what happened before β combining BM25, graph, quality, and decay in one call.
Before closing a session, save anything important:
The entry automatically gets a quality score based on its structure (tags, content detail, links).
| Category | When to use |
|---|---|
decision | Architecture choices, trade-offs, "why X over Y" |
pattern | Conventions, frameworks, code style rules |
bug | Issues you fixed and how |
knowledge | Project facts, domain info, team context |
warning | "Do NOT do this" β anti-patterns, landmines, mistakes to avoid (recalled with a boost) |
Tip: Don't overthink it. If it's something your future self (or agent) would want to know, save it. Detailed entries with specific tags score higher in quality.
Use semicolon-separated tags for easy filtering:
Tip: Keep tags short and consistent. They're not hashtags β they're search filters. More specific tags = higher quality score.
Run memory_archive() monthly to move old entries to the archive. Run memory_stats() to check the size and quality distribution. Low-quality entries (vague content, no tags) get lower recall priority automatically. Use memory_consolidate to merge duplicates and mode: "versions" to retire notes superseded by newer library versions.
Tip: If memory gets too large (100+ entries), consider archiving or removing outdated entries with
memory_forget.
Tip: Export before major refactors. You can always import the backup later if something goes wrong.
Tip: Duplicates are detected by key. If you want to re-import an entry, delete the old one first with
memory_forget.
Tip: Watch mode is great for long-running sessions. Use
-cto compress and-m 5to keep only 5 backups.
Watch Options:
| Option | Description | Default |
|---|---|---|
[interval] | Backup interval in minutes | 5 |
-c, --compress | Enable gzip compression | off |
-l, --log [path] | Enable file logging | off |
-m, --max-backups <n> | Max backups to keep (0=unlimited) | 10 |
The installer (requires a terminal) will:
β config found) and their supported scope (local/global or solo local)1,3,5), by name (claude,codex), all, Enter for all, or q to quit.toon-memory + agent configs in the repo) or (2) Global (~home configs)agent β scope β path (MCP/plugin/hooks/instrucciones)) and ask ΒΏProceder? [Y/n]Sin una terminal (CI/pipes)
npx toon-memoryimprime la ayuda de instalaciΓ³n no interactiva. Usanpx toon-memory init [local|global]para instalar sin preguntas. Unknown commands print usage and exit with an error.
Add to .opencode/opencode.json or ~/.config/opencode/opencode.json:
Hooks are delivered via a plugin, not a top-level
hookskey. OpenCode 1.17+ rejects"Unrecognized key: hooks"in its config βtoon-memory initwrites.opencode/plugins/toon-memory.tsinstead. Do not addhookstoopencode.json.
Add to .mcp.json (project root):
Add to .vscode/mcp.json:
Add to .codex/config.toml:
Add to .gemini/settings.json:
Add to ~/.config/zed/settings.json:
Tip: Use global config if you want memory for every project. Use project-level config if you only want it for specific projects.
.toon-memory/memory/data.toonTOON (Token-Oriented Object Notation) is designed for LLMs:
| Format | Tokens (16 entries) |
|---|---|
| JSON | 1097 |
| TOON | 850 |
Measured with gpt-tokenizer (cl100k_base) over 16 representative memory entries β see scripts/benchmark-toon.mjs (npm run bench).
The token savings compound at session time: npm run bench:impact simulates retrieving context with vs without memory and measures ~68% fewer tokens to get the same context (recall compact instead of re-reading source files). The full session benchmark (npm run bench:full) shows 80% fewer tool calls and 47% fewer tokens with context_* tools.
Tip: Fewer tokens = faster responses + lower API costs. Your agent reads memory files on every session start, so efficiency matters.
| Feature | toon-memory | @modelcontextprotocol/server-memory | mem0 | shodh-memory |
|---|---|---|---|---|
| Storage | Local file (TOON) | Local file (JSON) | Cloud | RocksDB |
| Dependencies | Zero | Zero | Cloud API | sentence-transformers, RocksDB |
| Search | BM25 + graph + quality | Basic keyword | Vector only | Hybrid (vector + graph) |
| Token efficiency | 22.5% fewer than JSON | Baseline (JSON) | N/A (cloud) | Similar |
| Quality scoring | Auto (0β1, heuristics) | None | None | BND algorithm |
| Merge-dedup | Tags union + max confidence | None | None | Content dedup |
| Confidence tracking | Per-entry (0β1) | None | None | Per-entry |
| System Primer | Auto-generated | None | None | None |
| Multi-session | File-based coordination | None | N/A | None |
| Hooks | 15 agents | None | None | Claude only |
| Encryption | AES-256-GCM | None | Cloud-managed | None |
| Setup time | npx toon-memory | Manual JSON | Cloud signup | Docker + config |
The context_* tools replace 3β6 separate tool calls with a single call, saving both tokens and tool-call overhead.
What each scenario measures:
| Tool | Without (manual path) | With (single call) | Why it saves |
|---|---|---|---|
context_generate | Read package.json + README + tsconfig.json + full memory dump + memory stats + sessions = 6 calls | One compact briefing with everything | Eliminates 5 redundant reads; output is deduplicated and compact |
context_diff | git log + git diff --name-only + memory_diff + sessions = 4 calls | One incremental diff | Combines git state + memory changes in one output; no overlap |
context_focus | memory_recall + findCallers + findRelatedFiles + findTestFiles = 4 calls | One targeted briefing | Only returns what's relevant; no full memory scan needed |
context_health | memory_stats + orphan scan + duplicate scan + file ref validation + stale sessions = 5 calls | One health report | Each check is done once and deduplicated; no redundant queries |
context_export | memory_stats + memory_recall({ compact: true, mode: "graph" }) + manual formatting = 3 calls | One markdown export | Formats output directly; agent skips the "format as markdown" step |
Tip: Use
context_generateat session start (93% token savings). Usecontext_difffor "what changed since last time?" (72% savings). Usecontext_focusfor deep dives on specific topics (45% savings).
Measured with gpt-tokenizer (cl100k_base) over realistic project scenarios β see scripts/bench-context-tools.mjs (npm run bench:context).
Simulates a complete 5-phase agent session (session start β debug β implement β review β wrap-up) across 3 approaches: without memory, with memory_recall, and with context_* tools.
Key findings:
| Metric | Without memory | With memory_recall | With context_* tools |
|---|---|---|---|
| Tokens per session | 2,411 | 972 (-60%) | 1,290 (-47%) |
| Tool calls per session | 25 | 12 (-52%) | 5 (-80%) |
| Cost per session (GPT-4) | $0.072 | $0.029 | $0.039 |
The trade-off: memory_recall uses fewer tokens (972 vs 1,290) because it returns only matching entries. context_* tools return richer context (callers, related files, test files, health audit) β more tokens per call, but 80% fewer tool calls. In practice, the agent avoids 3-4 follow-up "find related" calls that context_focus already includes.
Where context_ wins big:*
context_health replaces 5 manual scansTip: Use
memory_recallwhen you need specific entries (fewer tokens). Usecontext_*when you need comprehensive context with fewer round-trips (fewer calls).
Measured with gpt-tokenizer (cl100k_base) β see scripts/bench-full-impact.mjs (npm run bench:full).
Tip:
memory_smart_recallcombines BM25 + graph + quality in one call, saving both tokens and tool-call overhead. Use it at the start of every task.
Since v3.7.0, recall ranks results with Reciprocal Rank Fusion over BM25 (Γ3) and graph-centrality ranks, with an adaptive k = clamp(3..60, round(sqrt(n))). Measured over 8 gold-standard queries with hand-labeled relevance (see scripts/bench-rrf.mjs, npm run bench:rrf):
RRF matches the previous linear weighted score at zero ranking cost, while simplifying the scoring pipeline (BM25Γ3 + centrality, no importance/recency noise). Graph mode supersession is honored: obsolete entries stay excluded except for as_of point-in-time queries.
Since v4.1.0, retrieval is benchmarked against a frozen snapshot of real project memory β a LongMemEval-style test set with hand-authored gold queries. Corpus: 187 real data.toon entries (snapshot 2026-08-01), 42 gold queries across 6 categories (core-fact, temporal, knowledge-updating, multi-hop, meta/session, distractor). The measured code is the production pipeline (src/lib), bundled in-memory with esbuild β no faithful copies. A deterministic today parameter pins recency/decay so results can't drift with the wall clock; runs are read-only (no access tracking). Two priority meta-entries that describe the data file itself are excluded. See benchmarks/retrieval-corpus.toon, benchmarks/gold-queries.json (npm run bench:retrieval):
RRF is the top-ranked mode (0.861 R@5, 97.6% of queries answerable from the top-5); memory_smart_recall stays competitive in a single call.
Symptom: Agent says it doesn't have memory tools.
Fix:
npx toon-memory status to verify installationSymptom: memory_stats shows 0 entries.
Fix: This is normal on first install. Start using memory_remember to save entries.
Symptom: Same key appears multiple times.
Fix: memory_remember with the same key now auto-merges (union of tags, max confidence, latest date). Use memory_consolidate to merge all same-key entries and remove exact-content duplicates. For manual cleanup, use memory_forget.
Symptom: Can't decrypt memory.
Fix: Unfortunately, there's no recovery. The encryption key is not stored anywhere after generation. This is by design for security. You'll need to start fresh or restore from a non-encrypted backup.
Symptom: Agent responses are slow.
Fix:
memory_archive() to move old entries to archivememory_forget to remove irrelevant entriesYes, as long as it supports MCP (Model Context Protocol). We have auto-setup for 22 agents, with manual configuration available for others.
No. Everything stays on your machine. The MCP server runs locally over stdio β no network calls, no telemetry, no cloud.
Yes, if you sync the .toon-memory/memory/ directory (e.g., via Git or a shared folder). Each machine needs toon-memory installed, but the memory file is portable.
Each project gets its own memory file. Memory doesn't leak between projects.
No, encryption applies to the entire memory file. If you need selective encryption, keep sensitive data in a separate tool.
Markdown files aren't structured, aren't searchable by your agent in the same way, don't integrate via MCP, and don't have features like archiving, date filtering, quality scoring, merge-dedup, confidence tracking, or encryption. toon-memory is purpose-built for AI agents.
Contributions are welcome! Please read our Code of Conduct and Contributing Guide first.
git checkout -b feature/amazing-feature)git commit -m 'feat: add amazing feature')git push origin feature/amazing-feature)toon-memory is designed with security and privacy as a core principle.
.toon-memory/memory/. No data is ever sent to external servers, cloud services, or third parties.memory_encrypt (requires TOON_MEMORY_KEY environment variable)..gitignore β The installer adds .toon-memory/memory/ to .gitignore to prevent accidental commits of memory data.MIT
Built with @toon-format/toon and @modelcontextprotocol/server.
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/toon-memory)<a href="https://allmcps.com/mcp/toon-memory"><img src="https://allmcps.com/api/badge/toon-memory?style=directory" alt="Toon Memory on AllMCPs" /></a>