memory_mcp CLAUDE.md

memory_mcp CLAUDE.md is an instructions file for coding agents from nerdyaustin/memory_mcp. It costs 2,200 tokens per session, scanned A, original, MIT.

A memory service for AI coding assistants that stores and searches past sessions and saved notes. It uses a local database to make earlier conversations searchable across sessions.

In plain words
What is it for?
Indexing Claude Code and OMP session history, searching old sessions, and saving or retrieving cross-session knowledge.
Why use it?
It helps an assistant recover useful context instead of relying only on the current conversation.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/nerdyaustin/memory_mcp/claude-md
Clone the repo
git clone --depth 1 https://github.com/nerdyaustin/memory_mcp

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for memory_mcp CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/nerdyaustin/memory_mcp/claude-md.svg)](https://agentmods.dev/instructions/nerdyaustin/memory_mcp/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/nerdyaustin/memory_mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/nerdyaustin/memory_mcp/claude-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,200 This file is loaded in full into every session.
When invoked 2,200 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02200 $0.02200
Opus 5 $0.01100 $0.01100
Sonnet 5 $0.00440 $0.00440
Haiku 4.5 $0.00220 $0.00220

Measured 3d ago against content hash 7765c99da56a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memory_mcp CLAUDE.md scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

**Test:** `tests/test_startup.py` measures wall time from `subprocess.Popen` to the `tools/list` response. Threshold is 1.5s on this machine; observed values are ~200–300ms cold, ~150–250ms warm. If this test starts fail
CLAUDE.md · 179 lines

How it starts

The opening of the file, as written. The whole thing — 179 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Memory MCP

Persistent memory and session search for AI coding assistants, exposed as an MCP server.

What this is

A Python MCP server that:

  1. Indexes session history from Claude Code (~/.claude/projects/) and OMP (~/.omp/agent/sessions/)
  2. Provides full-text search across all historical sessions via SQLite FTS5
  3. Offers explicit save_memory/search_memory tools for cross-session knowledge persistence

No Flask, no Postgres, no file watchers. SQLite handles everything. The MCP SDK handles transport.

Architecture

memory_mcp/
  server.py              # FastMCP entry point, lifespan yields fast then runs scan in background
  readiness.py           # Lazy embedder + scan/backfill coordination (v0.3.0)
  config.py              # Auto-detects session dirs, DB path (~/.memory_mcp/memory.db)
  db.py                  # SQLite + FTS5 + sqlite-vec schema, all query functions
  embeddings.py          # Lazy fastembed wrapper (BAAI/bge-small-en-v1.5)
  scanner.py             # Walks session dirs, dispatches to parsers, indexes into DB
  parsers/
    base.py              # ParsedSession / ParsedMessage dataclasses, SessionParser protocol
    claude_code.py       # Claude Code JSONL parser (merges streamed assistant blocks)
    omp.py               # OMP JSONL parser
  tools/
    memory.py            # save_memory, search_memory, list_memories, delete_memory
    sessions.py          # list_sessions, get_session, search_sessions, refresh_sessions

Startup contract (v0.3.0)

This is a hard contract. Breaking it causes MCP clients (Claude Code, Codex, VS Code) to silently miss the server's tools on startup, the bug that motivated v0.3.0.

Rule: lifespan MUST yield in <500ms on every cold boot. Anything that blocks longer than that goes in a background task started after yield.

What this means in practice:

  • server.py:lifespan does only init_db() + ReadinessState.new() + init_readiness(state) + asyncio.create_task(_background_startup(...)) before yielding. Do not add anything else pre-yield.
  • The embedding model is never loaded pre-yield. The background startup task warm-starts it (readiness.warm_start_semantic) right after the initial scan, so it's usually ready before the user's first prompt. If a semantic call races the warm-start, ensure_semantic_ready() loads the model on demand — but it must never wait for scan or backfill completion; semantic queries search whatever vectors exist and backfill catches up in the background. Blocking on backfill is what caused the 30s MCP client timeouts fixed in v0.5.0.
  • save_memory uses readiness.get_embedder_if_ready() — opportunistic embedding only. It never triggers a cold load. Backfill embeds any rows saved before the model was up.
  • The initial session scan runs in a background task, not in lifespan. Tools work as soon as MCP is ready.
  • All scan/backfill work runs in worker threads via asyncio.to_thread. SQLite connections are thread-bound, so worker threads always open their own connection via init_db(). Never pass the lifespan connection into to_thread.
  • Scan + backfill are serialised via state.maintenance_lock to prevent concurrent writers and to keep semantic results consistent.
  • embeddings.py does not import fastembed at module top. The import lives inside Embedder.__init__. Probe availability with importlib.util.find_spec("fastembed") instead.

Read the full file on GitHub · 179 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 179 lines · 2,200 tokens per session scan A 7765c99da56a

Subscribe to this mod's changes

memory_mcp CLAUDE.md is an instructions file published in the GitHub repository nerdyaustin/memory_mcp (1 stars, last pushed 1mo ago), licensed MIT. It adds 2,200 tokens to every session, about $0.0110 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories