brain — the recorder

io.github.mordechaipotash由 GitHub 帳號 mordechaipotash 發布v2.0.0更新於 Oct 24, 2026

Records your Claude Code, Codex and Pi history before deletion. Cited-or-abstain recall.

發布方自己的服務:BrainDog

概覽

AI 產生的概覽

在 Claude Code、Codex 與 Pi 的工作階段紀錄被刪除前於本機留存,並讓助理帶可驗證引用地檢索這些歷史。

可以做什麼
  • 檢索已記錄的 AI 對話歷史,回傳附引用的命中或明確的「未找到」聲明
  • 取出引用背後的原始行並以 sha256 驗證
  • 依時間列出近期活動,並按日期與代理產生工作階段卡片
  • 回報各通道的擷取健康狀態、代理刪除了什麼,以及記錄機制本身是否在運作
  • 將記錄封存做可驗證的備份,寫到封存之外的目的地
適用情境
當你希望助理回想你在過去 Claude Code、Codex 或 Pi 工作階段中實際寫過的內容,且需要可核對的引用時;也適合在代理自身的清理機制刪除紀錄前,保留一份本機副本。
執行需求
以本機 Python 套件(pipx 或 uvx)透過 stdio 執行,支援 macOS 與 Linux,Windows 不在範圍內。需要它所監看的代理工作階段資料夾、由 BRAIN_HOME 指定的資料目錄(預設 ~/.brain),以及首次建立索引時下載一次 DuckDB 全文檢索擴充。
安裝前請注意
它會把完整工作階段紀錄(含子代理輸出與已儲存的工作結果)持續複製到本機封存,敏感內容會長期留存。還原、遮蔽與備份僅為命令列操作;備份會寫入你指定的目的地。不使用遙測、雲端服務或帳號,但會從 DuckDB 儲存庫下載一次 fts 擴充。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 brain — the recorder,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

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:

bash
# macOSfind ~/.claude/projects -name '*.jsonl' -exec stat -f '%Sm  %N' -t '%Y-%m-%d' {} + | sort | head -3# Linuxfind ~/.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

bash
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 itbrain-mcp restore --list  # what can be put backbrain-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.

Install

bash
pipx install brain-mcp           # or: uvx brain-mcpbrain-mcp install cc             # CC hooks + 60-second schedulerbrain-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

toolwhat
brain_searchBM25 over everything recorded; cited hits or an explicit abstention
brain_getthe raw lines behind a citation, with sha verification
brain_recenttime-ordered recent activity, every row cited
brain_sessionssession cards per day/agent
brain_healthper-lane origin-vs-floor freshness (unknown ≠ healthy), plus the receipt of what the agents deleted
brain_capture_statusis the machinery itself moving (spool, heartbeats, floor)
brain_backupverified 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

bash
brain-mcp record                  # one capture tick (the scheduler runs this every 60s)brain-mcp health [--exit-nonzero-on-stale]   # cron-ablebrain-mcp doctor                  # capture status, health, fts cache, the receipt, runaway generationsbrain-mcp restore [<id>] [--list] [--to DIR] [--dry-run]   # put a deleted session backbrain-mcp redact <file> --lines A B --reason "..."   # tombstone a secret; audited in manifestbrain-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.

來源:README.md,提交 78d8a4f

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

2
  1. v2.0.0最新Oct 4, 2026
  2. v2.0.0b3Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Brain 整合