# brain — the recorder

Records Claude, Codex and Pi sessions before cleanup deletes them, then makes them searchable with citations you can verify.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 81
- Author: mordechaipotash
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/mordechaipotash/brain-mcp
- Updated: 2026-10-04
- HTML: https://affpapa.org/en/nevibecode/mcp/brain-the-recorder

## What it does

Claude wipes session files older than `cleanupPeriodDays` (default 30) at startup. brain-mcp gets there first: Stop and SessionEnd hooks write line-deltas plus a final snapshot, and a 60-second poll-scan sweeps the whole session folder, subagent transcripts, `.meta.json` and `tool-results/` included. Codex and Pi land in the same spool through the scanner.

Everything goes to `~/.brain/lake/<lane>/<session>.jsonl` — append-only, byte-identical to the origin, with an append-only sha256 manifest. The DuckDB index is a cache and can be rebuilt from the lake and manifest. Search returns BM25 hits carrying `{file, line span, sha256}`, checkable with `sed` and `shasum`; zero hits produce an explicit abstention naming the lanes and dates that were searched.

One thing to plan for: the package installs via `pipx` or `uvx`, and the first index build makes DuckDB download its full-text-search extension `fts` from DuckDB's own repository, cached under `~/.duckdb`. On an air-gapped machine that fetch has to be arranged beforehand, or the index never gets built. There is no telemetry and no cloud in the package.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `BRAIN_HOME` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env BRAIN_HOME=<BRAIN_HOME> --transport stdio brain-the-recorder -- uvx brain-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from brain-mcp <command>

### Codex

**Platform CLI**
```bash
codex mcp add brain-the-recorder --env BRAIN_HOME=<BRAIN_HOME> -- uvx brain-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from brain-mcp <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "brain-the-recorder": {
            "command": "uvx",
            "args": [
                "brain-mcp"
            ],
            "env": {
                "BRAIN_HOME": "<BRAIN_HOME>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from brain-mcp <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "brain-the-recorder": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "brain-mcp"
            ],
            "env": {
                "BRAIN_HOME": "<BRAIN_HOME>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from brain-mcp <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e BRAIN_HOME=<BRAIN_HOME> brain-the-recorder uvx brain-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from brain-mcp <command>

## When to use it
- restore a Claude session that cleanup already deleted
- find a past exchange with a citation you can verify by hash
- see exactly which sessions and files the agents removed
- back up the history with re-hashing at the destination
- tell fresh lanes apart from stale and unmeasured ones

## Example prompts
- Search my history for what I wrote about the migration: `brain_search(query="migration", role="user")`
- Show me what the agents deleted with `brain_health`
- Restore a session: `brain-mcp restore --list`, then `brain-mcp restore <id>`

## Similar
- [REA](https://affpapa.org/en/nevibecode/mcp/rea.md) — MCP server · ★ 386989
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33918
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81115
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119160
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47392
- [mcp-server](https://affpapa.org/en/nevibecode/mcp/mcp-server.md) — MCP server · ★ 43872

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
