Brain: Shared Memory for AI Agents
Claude Code and Codex share one memory, so no session starts from scratch.
Every AI coding session ends with amnesia. Brain is my fix: a self-hosted MCP memory server that Claude Code and Codex both read and write, backed by an Obsidian vault of linked Markdown notes I can browse, link and review by hand. Decisions, project state and handoffs live in one place, so the next session, in either tool, picks up where the last one stopped.
- Obsidian vault of linked Markdown notes (projects, decisions, session handoffs, per-container homelab notes), versioned in Git; graph view and backlinks show how the work connects
- Hybrid retrieval: exact entity matching (hostnames, container IDs, ports), SQLite FTS5 with BM25 ranking, and vector search over local embeddings (Ollama, sqlite-vec), merged with reciprocal rank fusion; falls back to keyword search with a degraded flag when the embedding model is offline
- MCP tools for search, note lookup, handoffs and inbox capture, registered in both Claude Code and Codex
- Session handoffs: hooks track context and plan usage, prompt a wrap-up near the limit, and keep the session open until a handoff is saved
- File leases for multi-agent coordination: a write claims its files until commit, release, 20 minutes idle, session end or an explicit takeover, so two agents can share one repo without overwriting each other
- Least-privilege writes: agents can only create new inbox notes and filing stays a human step; secrets, tokens and public IPs are redacted before indexing, on write and on output, with Git hooks as a second check
- Python 3.13, hash-pinned dependencies, offline installs with tested rollback, 288 automated tests
Stack: Python, MCP, SQLite FTS5, sqlite-vec, Ollama, Obsidian, Git, Claude Code, OpenAI Codex