// query first · write back after
Company knowledge scattered across repos, chat transcripts, and meetings dies between sessions, and gets re-derived from scratch, over and over.
The problem
Without a shared memory, every agent session starts from zero: the same architecture decisions re-litigated, the same context re-explained, the same debugging history re-discovered.
What it does
GBrain is self-hosted company memory served over MCP. Every agent I run queries it before answering and writes back after working, so decisions, infrastructure, and history survive the session that produced them. Retrieval is hybrid vector + keyword search with multi-query expansion and a reranker. On top sit versioned pages, session logs, a timeline, a knowledge graph, and code intelligence: definitions, callers, and call flow.
- GBrain engine · garrytan/gbrain
- Bun
- PostgreSQL 16 + pgvector
- BGE-M3 embeddings
- MCP over HTTP
- Docker Compose
Receipts
- 84 MCP tools on the live server: pages, hybrid retrieval, graph traversal, code intelligence, background jobs, fact extraction.
- 2,386 pages and 17,932 chunks, 100% embedded, plus 1,683 links and 1,072 timeline entries as of July 2026.
- 6 registered knowledge sources on a nightly ingest cron: every RandomSynergy17 repo’s docs, claude-mem observations from 3 machines, 232 transcripts from 118 Claude Code sessions.
- 12 tagged releases since first deploy on 2026-05-27, including a 6,230-chunk re-embedding that took brain health from 33 to 74/100.
- 12 skills (query, capture, meeting ingest, daily prep) run on both Claude Code and claude.ai from one source of truth.
Under the hood
The core engine is Garry Tan’s upstream gbrain project; my build is the deployment and integration layer: a 4-service Docker stack (Bun MCP server, background worker, PostgreSQL 16 + pgvector, Google Drive sync), all LLM and embedding traffic routed through a LiteLLM gateway, BGE-M3 embeddings in ~40ms on GPU. I also diagnosed and patched two upstream schema bugs and reported one upstream.
Outcome
Brain-first is policy now: every Claude Code session on my 3 machines checks GBrain before answering anything about projects, infrastructure, or history; this site’s own build decisions are recorded there too. The code stays private by design; it holds the company’s memory. No public repo, no demo. This write-up is the public artifact.
