Skip to main content
Glama

brain-mcp — the recorder for your AI conversations

Your AI history is being deleted right now. Claude Code deletes session files older than cleanupPeriodDays (default 30) at startup. Run this and see your own cliff edge:

# macOS
find ~/.claude/projects -name '*.jsonl' -exec stat -f '%Sm  %N' -t '%Y-%m-%d' {} + | sort | head -3
# Linux
find ~/.claude/projects -name '*.jsonl' -printf '%TY-%Tm-%Td %p\n' | sort | head -3

The oldest date you see is where your history ends. brain-mcp records it before it goes — the whole session, subagent transcripts and saved tool output included, byte-exact, content-hashed, locally — makes it queryable with citations you can verify with sed and shasum, tells you what was deleted, and puts it back.

If Claude Code deleted it

brain-mcp health          # the receipt: "3 session(s) and 41 file(s) are gone from where the
                          #   agent kept them; the floor holds every one" — each re-hashed
                          #   against the manifest when the recorder first noticed it
brain-mcp restore --list  # what can be put back
brain-mcp restore <id>    # writes the session (and its folder) back, byte-exact, then:
                          #   cd <its working directory> && claude --resume <id>

restore never overwrites different bytes (identical bytes are a no-op), is all-or-nothing, and takes --dry-run and --to <dir>. It is a CLI verb only — no MCP tool writes outside the floor.

Related MCP server: LoreConvo

Install

pipx install brain-mcp           # or: uvx brain-mcp
brain-mcp install cc             # CC hooks + 60-second scheduler
brain-mcp serve                  # the MCP server (stdio) — add to your client config

Or as a Claude Code plugin (hooks + server in one step):

/plugin marketplace add mordechaipotash/brain-marketplace
/plugin install brain

What it does

  • Captures at source. Claude Code via Stop/SessionEnd hooks (line-deltas + a final snapshot); Codex, Pi, and everything inside a Claude Code session's own folder (subagent and workflow transcripts, .meta.json, tool-results/) via a 60-second poll-scan. One spool, one floor.

  • Keeps the bytes. The floor is ~/.brain/lake/<lane>/<session>.jsonl — append-only, byte-identical to the original, with an append-only sha256 manifest. Nothing is parsed and discarded; the DuckDB index is a cache, fully re-derivable from the lake.

  • Cites or abstains. Every search hit carries {file, line span, sha256} — checkable by anyone with sed -n 'A,Bp' file | shasum -a 256, no database required. Zero hits return an explicit abstention naming the lanes and dates actually searched.

  • Reports health honestly. fresh = the floor holds everything the agent's files show; stale = the agent has content the recorder missed; unknown = unmeasured, not healthy — never folded into "looks fine".

  • Backs up verifiably. brain-mcp backup <dest> syncs lake+manifest and re-hashes sampled files at the destination. The verify can fail; that is the point.

  • One network fetch, ever, and it is not about you. No telemetry, no cloud, no accounts, and no HTTP client in this package. The exception: DuckDB downloads its full-text-search extension (fts) from DuckDB's own extension repository the first time the index is built, and caches it under ~/.duckdb. brain-mcp install does that fetch up front and says so; brain-mcp doctor reports whether it is cached.

The 7 MCP tools

tool

what

brain_search

BM25 over everything recorded; cited hits or an explicit abstention

brain_get

the raw lines behind a citation, with sha verification

brain_recent

time-ordered recent activity, every row cited

brain_sessions

session cards per day/agent

brain_health

per-lane origin-vs-floor freshness (unknown ≠ healthy), plus the receipt of what the agents deleted

brain_capture_status

is the machinery itself moving (spool, heartbeats, floor)

brain_backup

verified backup; writes only outside the floor

🤖 For AI Assistants

You're reading this because your human runs THE RECORDER and gave you access to their AI history. This is the honesty contract.

The one rule: everything you state from these tools is either CITED or ABSTAINED — there is no third state. A cited claim carries a checkable pointer (file + line span + sha256); verify it with brain_get(expect_sha256=...) before building on it. An abstention means "not found above threshold in the lanes and dates the tool measured" — it does NOT mean "it never happened". Never fill an abstention with your own guess.

  • Present recall as their words, dated: "On 2026-08-19 you wrote: '…' (sess-7f2a.jsonl:412)" — never as your own knowledge. One claim, one citation.

  • verified: false from brain_get means the floor changed since indexing. Say so plainly.

  • A health response containing any unknown lane is never "everything looks fine". The honest sentence is: "2 lanes fresh, 1 stale, 1 unmeasured."

  • "What do I think about X" → brain_search(query, role="user"). That returns what the PERSON wrote: text the harness injected under the user role (skill bodies, reminders, slash-command wrappers, compaction summaries, Codex context blocks — a quarter to two thirds of "user" rows, measured) is excluded unless you pass include_machine=True, and subagent transcripts unless include_subagents=True. "How did my thinking evolve" → add order="time_asc"; bound it with since / until. The server has no opinion about your human's mind; it has their words, with receipts.

The floor format

~/.brain/
  spool/<lane>/                 hooks + scanner write here (atomic, dot-tmp invisible)
  lake/<lane>/<session>.jsonl   THE FLOOR: append-only, byte-identical to the origin;
                                a rewrite opens <session>.g2.jsonl — old kept, never deleted
  lake/cc_sessiondir/<project>/<session>/...   a CC session's folder, mirrored at the
                                same relative paths (subagents/, tool-results/, *.meta.json)
  manifest/manifest.jsonl       one versioned line per chunk: byte range, line range, sha256
  offsets/<lane>/<session>      hook fast-path line counters
  health/*.last_run             side-effect heartbeats (mtimes are the proof, never a report)
  brain.duckdb                  the index — a cache, re-derivable from lake/ + manifest/

Where your agents keep their transcripts: Claude Code ~/.claude/projects/**/*.jsonl (rolling window!), Codex ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl, Pi ~/.pi/agent/sessions/**/*.jsonl.

Other verbs

brain-mcp record                  # one capture tick (the scheduler runs this every 60s)
brain-mcp health [--exit-nonzero-on-stale]   # cron-able
brain-mcp doctor                  # capture status, health, fts cache, the receipt, runaway generations
brain-mcp restore [<id>] [--list] [--to DIR] [--dry-run]   # put a deleted session back
brain-mcp redact <file> --lines A B --reason "..."   # tombstone a secret; audited in manifest
brain-mcp migrate-v1 <all_conversations.parquet>     # import v1 data (marked v1_derived)
brain-mcp uninstall               # removes hooks + scheduler; your floor is KEPT

v1 → v2

v2 is a rebuild around one principle: capture the bytes first; derive everything else. v1 parsed conversations into a parquet and discarded the originals — v2's floor makes that structurally impossible. v1's 25 tools became 7: the synthesis tools ("cognitive patterns", "switching cost") are gone because a claim that can't carry a line-span citation isn't one this server makes. Migration: brain-mcp migrate-v1 — v1 rows are kept, marked as derived, and floor-backed rows win wherever the source still exists.

Windows: out of scope for v2.0. Scheduling is LaunchAgent (macOS) / systemd user timer (Linux).

MIT.

Available Tools

25 tools
alignment_checkA

Check if a decision aligns with your principles. Searches principles file and semantic history for guidance.

Inputs: decision (required). Returns: result

brain_statsA
    Brain overview, domain distribution, and thinking pulse.

    Args:
        view: What to display:
            - "overview" (default): Stats across all data sources
            - "domains": Domain breakdown with counts, %, breakthroughs, top concepts
            - "pulse": Domain × thinking_stage matrix — what's crystallizing vs exploring
            - "conversations": Detailed conversation stats
            - "embeddings": Embedding coverage stats
            - "github": Repository and commit stats
            - "markdown": Document corpus stats
    

Inputs: view. Returns: result

cognitive_patternsC
    Analyze cognitive patterns and problem-solving approaches.
    Answers: 'When do I think best?' with data.
    

Inputs: domain. Returns: result

context_recoveryB
    Full 'waking up' brief for re-entering a domain.
    Returns recent summaries + accumulated state — everything needed to resume work.
    The prosthetic's core value: making re-entry cheap.
    

Inputs: domain (required), summary_count. Returns: result

conversations_by_dateC

Get conversations from a specific date (YYYY-MM-DD format).

Inputs: date (required), limit. Returns: result

dormant_contextsC

Find abandoned tunnels — domains with open questions you haven't resolved. The 'what have I forgotten?' alarm.

Inputs: min_importance, limit. Returns: result

get_conversationA
    Get the full content of a specific conversation by ID.
    Use search_conversations() first to find conversation IDs.
    

Inputs: conversation_id (required). Returns: result

get_principleC

Get detailed info about a specific principle.

Inputs: name (required). Returns: result

list_principlesA

List your configured principles. Principles are loaded from the YAML/JSON file specified in config.toml.

Inputs: no named parameters. Returns: result

open_threadsC

Global inventory of ALL open questions across ALL domains. The 'unfinished business' dashboard.

Inputs: limit_per_domain, max_domains. Returns: result

query_analyticsA
    Query analytics across timeline, tool stacks, problem resolution,
    spend, and conversation summary.

    Args:
        view: What to analyze:
            - "timeline" (default): What happened on a specific date
            - "stacks": Technology stack patterns over time
            - "problems": Debugging and problem resolution patterns
            - "spend": Cost breakdown by source/time
            - "summary": Comprehensive conversation analysis summary
        date: Date in YYYY-MM-DD format (used with view="timeline")
        month: YYYY-MM filter (used with stacks, problems, spend views)
        source: Source filter for spend (e.g., "openrouter", "claude_code")
        limit: Max results (default 15)
    

Inputs: view, date, month, source, +1 more. Returns: result

search_conversationsA
    Full-text search across all conversation messages.

    Args:
        term: Search term (keyword). If empty with role="user", finds recent user questions.
        limit: Max results (default 15)
        role: Filter by role — "user" for your words, "assistant" for AI responses.
              With role="user" and empty term, returns recent questions asked.
    

Inputs: term, limit, role. Returns: result

search_docsA
    Search markdown corpus and IP documents with various filters.

    Args:
        query: Search query (keyword for markdown, semantic for IP docs)
        filter: What to search/filter:
            - None (default): Keyword search on markdown corpus
            - "ip": Vector search on curated IP documents
            - "breakthrough": Documents with BREAKTHROUGH energy
            - "deep": High depth-score documents
            - "project": Documents for a specific project
            - "todos": Documents with open TODOs
        project: Project name (used with filter="project" or filter="todos")
        limit: Max results (default 15)
        min_depth: Minimum depth score (used with filter="deep", default 70)
    

Inputs: query, filter, project, limit, +1 more. Returns: result

search_summariesA
    Search conversation summaries with hybrid vector + keyword search.

    Args:
        query: Search query
        extract: What to extract from results:
            - "summary" (default): Full summary with metadata
            - "questions": Open questions from matching conversations
            - "decisions": Decisions made in matching conversations
            - "quotes": Quotable phrases from matching conversations
        limit: Max results (default 10)
        domain: Filter by domain (e.g. "ai-dev", "business-strategy")
        importance: Filter by importance ("breakthrough", "significant", "routine")
        thinking_stage: Filter by stage ("exploring", "crystallizing", "refining", "executing")
        source: Filter by source ("claude-code", "chatgpt", etc.)
        mode: Search mode — "hybrid" (default), "vector", "fts"
    

Inputs: query (required), extract, limit, domain, +4 more. Returns: result

switching_costB
    Estimate cognitive cost of switching between domains.
    Factors: open questions left behind, shared concepts (overlap discount).
    Returns 0-1 score where lower = cheaper switch.
    

Inputs: current_domain (required), target_domain (required). Returns: result

thinking_trajectoryA
    Track the evolution of thinking about a topic over time.

    Args:
        topic: The concept/term to track
        view: What to show:
            - "full" (default): Complete trajectory with genesis, temporal pattern, semantic matches, thinking stages
            - "velocity": How often the concept appears over time with trend analysis
            - "first": When the concept first appeared — the genesis moment
    

Inputs: topic (required), view. Returns: result

trust_dashboardB
    System-wide stats proving the prosthetic works.
    Shows everything that's preserved: conversations, domains, questions, decisions.
    The 'everything is okay' view.
    

Inputs: no named parameters. Returns: result

tunnel_historyA

Meta-view of your engagement with a domain over time. Shows total conversations, thinking stage distribution, importance peaks, and cognitive patterns.

Inputs: domain (required). Returns: result

tunnel_stateB
    Reconstruct cognitive save-state for a domain — where you left off.
    Returns: thinking stage, open questions, decisions, concepts, emotional tone.
    The 'load game' button for your mind.
    

Inputs: domain (required), limit. Returns: result

unfinished_threadsC
    Find conversations worth revisiting: exploring/crystallizing stage with open questions.
    

Inputs: domain, importance. Returns: result

what_do_i_thinkA
    Synthesize what you think about a topic, or find similar past situations.

    Args:
        topic: The topic or situation to analyze
        mode: Analysis mode:
            - "synthesize" (default): Full synthesis with decisions, open questions, quotes
            - "precedent": Find similar past situations with context and decisions made
    

Inputs: topic (required), mode. Returns: result

what_was_i_thinkingB
    Time-travel snapshot: What was on your mind during a specific month?
    Format: YYYY-MM (e.g., '2024-08')
    

Inputs: month (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 25 tools

    Disambiguation4/5

    Tools are largely distinct, with clear descriptions differentiating similar ones (e.g., search tools target different sources). Some potential confusion between 'open_threads' and 'unfinished_threads' but descriptions clarify.

    Naming Consistency4/5

    All tool names use snake_case and follow a verb_noun or noun phrase pattern consistently. Minor variation in style (e.g., 'brain_stats' vs 'get_conversation') but still very readable.

    Tool Count4/5

    25 tools is on the high side but appropriate for the broad scope of personal knowledge management (search, stats, analytics, principles, threads, etc.). Each tool earns its place.

    Completeness5/5

    Coverage is comprehensive for the stated purpose: searching, retrieving, analyzing, and introspecting on a personal knowledge base. No obvious gaps given the read-heavy, analysis-oriented domain.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Persistent memory MCP server for AI coding agents (Claude Code, Codex, Gemini CLI). Hybrid retrieval (vector + BM25), cross-encoder reranking, knowledge graph, session checkpoint/resume, and multi-scope isolation. Local-first with LanceDB.
      30
      26 npm
      15
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Persistent memory for AI agents across Claude Code, Cowork, Codex, Cursor and Hermes Agent. Saves, searches and recalls sessions from a local SQLite store through 40+ MCP tools, with auto-save and auto-load hooks, project tagging and export/import. Also a Hermes Agent memory provider plugin in the official catalog. Free: keyword search, 50 sessions. Pro ($8/mo): semantic search and team memory.
      33
      368 PyPI
      12
      Business Source 1.1
    • F
      license
      Not graded
      quality
      C
      maintenance
      Local-first memory for AI coding agents. Indexes your Claude Code, Codex, Cursor, Cline and Gemini CLI history by repo/branch/worktree and hands a context capsule (decisions, touched files, next steps) to the next agent over MCP.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables personal AI agents to perceive ambient context, retain episodic memory with decay, act proactively, and route routine decisions through fast System-1 reflexes while escalating ambiguous multi-hop plans to frontier LLMs. Includes reversible execution checkpoints, token budgets, and local-first memory retention, and plugs into MCP clients like Claude Desktop, Cursor, and Windsurf.
      7
      MIT