Extract structured knowledge from Gmail and ChatGPT archives into GBrain or Obsidian.
Andrej Karpathy's been talking about personal AI and the idea of an AI that knows you — your history, your contacts, your thinking. That requires real data: years of email and conversations, not just what you choose to curate.
gbrain-import turns your archive exports into a structured knowledge graph. It extracts people, companies, projects, ideas, and concepts — with timeline events, confidence scores, and provenance — and writes them as clean markdown pages ready for semantic search.
# Bun only (uses bun:sqlite)
bun add --global gbrain-importOr run directly without installing:
bunx gbrain-import --input ~/Downloads/Mail.mbox# Stage 1: Index your archive (fast, no API calls)
bunx gbrain-import --input ~/Downloads/Mail.mbox
# This prints extraction batches as JSON to stdout.
# An agent stores results via the MCP tool (see below).
# Or use --api to extract directly with Anthropic:
bunx gbrain-import --input ~/Downloads/Mail.mbox --api# Point at the ChatGPT export directory (contains conversations-*.json)
bunx gbrain-import --input ~/Downloads/chatgpt-export --apibunx gbrain-import --input ~/Downloads/Mail.mbox --api \
--adapter obsidian --vault ~/Documents/BrainThree stages:
- Index — parse the archive into a local SQLite database. No API calls. Fast.
- Extract — LLM reads batches of threads/conversations and extracts structured entities.
- Materialize — resolve entities, apply quality gate, write markdown pages.
Two extraction modes:
- Agent-driven (default) — print batch prompts to stdout. Your agent (Claude Code, OpenClaw, etc.) reads them and stores results via the MCP
store_batch_resultstool. Resumable: re-run any batch without double-counting. --apimode — calls Anthropic directly via SDK. Default 5 concurrent.--modeland--concurrencyflags.
gbrain-import exposes a one-tool MCP server for agent-driven extraction:
# Start the server pointing at an existing workspace
bunx gbrain-import --mcp --workspace ~/.gbrain-import/my-workspace --connector gmailTool: store_batch_results
{
"batchId": "42",
"result": {
"people": [...],
"companies": [...],
"projects": [...],
"events": [...]
}
}The workspace is created automatically on first --input run. Find it at:
ls ~/.gbrain-import/Writes pages to a running GBrain instance via its engine API. Requires gbrain >= 0.19.0 as a peer dep.
bunx gbrain-import --input ~/Downloads/Mail.mbox --api --adapter gbrainWrites .md files directly to an Obsidian vault. No GBrain required.
bunx gbrain-import --input ~/Downloads/Mail.mbox --api \
--adapter obsidian --vault ~/Documents/BrainPages land at <vault>/<connector>/<directory>/<slug>.md — e.g. Brain/gmail/people/alice-example.md. The connector-name prefix prevents collisions when importing from multiple sources.
Only entities that appear in 3+ threads and have 2+ extracted events become pages. Everything else is captured in the database for future use but not written. This keeps noise out.
Every extraction batch is tracked by batch_id in the workspace database. storeBatchResults is idempotent: re-submitting a batch deletes the prior results before inserting new ones. You can safely re-run failed batches or retry the whole pipeline.
Stranded in_progress batches (older than 30 minutes) are reset to failed automatically on startup.
--input <path> Archive path (required)
--connector <name> gmail | chatgpt (auto-detected)
--adapter <name> gbrain | obsidian (default: gbrain)
--vault <path> Obsidian vault path (required for obsidian adapter)
--account <name> Account label for metadata
--workspace <dir> SQLite workspace directory
--api Use Anthropic API directly
--model <model> Model for --api mode (default: claude-haiku-4-5-20251001)
--concurrency <n> Concurrent API calls (default: 5)
--dry-run Preview without writing
--quiet Suppress progress output
--json JSON summary output
--mcp Start MCP stdio server
- Bun >= 1.1.0
- GBrain >= 0.19.0 (optional, only needed for
--adapter gbrain) ANTHROPIC_API_KEYin env (only needed for--apimode)