gbrain README

The project's README from github.com/garrytan/gbrain. As one markdown file: README.md.

GBrain

GBrain gives your AI agents shared, cited memory over plain Markdown. Save a decision in Claude Code and find it in Codex, Cursor, or ChatGPT: GBrain indexes Markdown into local PGLite or Postgres with keyword + vector search and a typed knowledge graph—returning cited answers that flag gaps instead of isolated search chunks, over MCP and a CLI.

MIT-licensed and free to self-host (starts keyless with local keyword + graph search; add an embedding key for vectors), or managed at gbrain.io.

What it looks like

Your notes stay plain Markdown—[[wikilinks]] and frontmatter become typed graph edges:

---
type: person
company: "[[companies/acme]]"
---
Alice leads engineering at [[companies/acme]].

Ask a connected agent (illustrative):

"What do I need to know before my meeting with Alice tomorrow?"

GBrain follows links across Alice, Acme, and past meetings—and flags where the record stops:

Alice leads engineering at Acme, a Series B fintech [people/alice, companies/acme].
Last met April 22 on the enterprise tier [meetings/2026-04-22-pricing]:
- Security review from Alice was due May 1 [meetings/2026-04-22-pricing].
- You sent a 500-seat quote April 25; no recorded reply [notes/2026-04-25-quote].

Gaps: no notes added for Alice or Acme since April 25—check email or Slack before
assuming these items are still open.

Quickstart

Self-hosted Hosted (gbrain.io)
Best for Local-first ownership, offline keyword + graph search, or your own Postgres + pgvector Always-on memory across Claude, ChatGPT, Codex, and Cursor with nothing to host
Storage & keys Local PGLite (zero API keys; add an embedding key for vector search) or Postgres + pgvector Managed Postgres + pgvector (hybrid search included; paid plans)
Access Local stdio MCP, or remote HTTPS via Tailscale Native HTTPS OAuth (notes hosted on gbrain.io)

Prefer your coding agent to handle setup? Point it at INSTALL_FOR_AGENTS.md.

Self-hosted

Prerequisites: macOS or Linux with Bun 1.4.4+.

[!WARNING] Not on npm. Install only from GitHub or the release binary below—the gbrain package on npm is unrelated. If you installed it by mistake or hit an install error, remove it first and follow install recovery.

1. Install and connect your agent (swap claude-code for codex; for Hermes, see docs/mcp/HERMES.md):

bun install -g github:garrytan/gbrain#stable
gbrain --version
gbrain setup claude-code   # initializes ~/.gbrain (PGLite), wires MCP, and adds agent hooks (reversible)
No Bun? Release-binary installer (macOS Apple Silicon / Linux x86-64 glibc)

Verifies SHA-256 against GitHub build provenance before installing (scripts/install.sh; omit --setup claude-code for binary + keyless brain only):

( f="$(mktemp)"; trap 'rm -f "$f"' EXIT; curl -fsSL https://raw.githubusercontent.com/garrytan/gbrain/stable/scripts/install.sh -o "$f" && bash "$f" --setup claude-code )
Cursor or other stdio MCP clients

Install the compiled release binary above (avoids macOS GUI PATH issues and untrusted-repo bunfig.toml loading per SECURITY.md), initialize a keyless brain, and add its path to your MCP config (for example ~/.cursor/mcp.json):

gbrain init --pglite --no-embedding
which gbrain
{
  "mcpServers": {
    "gbrain": {
      "command": "<path-to-gbrain>",
      "args": ["serve", "--surface", "starter", "--advertise", "verbs"]
    }
  }
}

Client guides: Claude Desktop · OpenClaw (uses full tool surface) · All clients.

2. Try the offline sample brain, then index your own Markdown notes:

# Isolated offline sample brain: 15 company pages, prints cited answers, touches no personal files
gbrain sources demo company-brain

# Index a Markdown folder keyless (--no-embed skips vector embeddings) and search it
gbrain import <path-to-markdown-folder> --no-embed
gbrain search "pricing"

Optional—for standalone CLI synthesis, set ANTHROPIC_API_KEY or OPENAI_API_KEY in your environment (over MCP, your agent uses its own model):

gbrain think "what did we decide about pricing?"

For vector embeddings, Git sync, or Postgres + pgvector, see docs/INSTALL.md and move to Postgres.

Hosted (gbrain.io)

  1. Create a workspace at gbrain.io.
  2. Connect your client over HTTPS MCP and approve the browser OAuth prompt (one-click Claude/Cursor links; ChatGPT · OpenClaw · Hermes):
# Claude Code (skips if a gbrain MCP entry already exists)
claude mcp get gbrain >/dev/null 2>&1 || claude mcp add --transport http --scope user gbrain https://gbrain.io/mcp

# Codex (skips if a gbrain MCP entry already exists)
codex mcp get gbrain >/dev/null 2>&1 || codex mcp add gbrain --url https://gbrain.io/mcp

# Optional (requires gbrain CLI): add per-turn brain-first instructions without changing MCP
gbrain setup claude-code --instructions-only

Cursor and other HTTP MCP clients connect to https://gbrain.io/mcp (client config snippets).

Verify in a live agent session (both paths): Confirm your gbrain MCP entry points at the brain you want, then say "Remember that the Q3 launch moved to October 12." Open a new session and ask "When is the Q3 launch?"—it should return the fact with its source.

How it compares

Approach Strengths What GBrain adds
Raw Markdown + grep Zero setup; strong on single-user exact text lookups Hybrid keyword + vector ranking, typed entity graph, and server-enforced team permissions
Plain RAG Simple chunk-embed-retrieve pipeline Graph traversal across linked pages, gap-aware synthesis, and source trust labels (separating your notes from untrusted email/web text)
Standalone vector DB Fast semantic similarity search Plain Markdown files stay on disk, Git-diffable and rebuildable alongside full-text search and typed links

Measured benchmarks

Six comparisons from gbrain-evals (commit 898e0ebf; methodology, intervals, and caveats in docs/proof.md):

Benchmark Baseline With GBrain Delta
Personal-notes Q&A (98 tasks) 13.3% (no retrieval) 86.7% +73.5 pts (paired)
LongMemEval (500 questions, dev set) 89.0% plain Postgres hybrid; 94.2% full paste 93.6% +4.6 pts vs hybrid; tied with paste (−0.6 pts, p = 0.72) at ~1/7 answer-reader cost ($0.023 vs $0.172)
Role-scoped permissions (100 runs) Plain Postgres: 97/100 to context (4 to answers); grep: 100/100 to context (0 to answers) 0/100 to context or answers 0 restricted-doc leaks
Planted false claims (100 scenarios, 600 sessions) 10.2% adopted (plain Postgres) 2.8% adopted −7.3 pts (paired) with trust labels
Very long chat logs — BEAM-10M (199 questions) 67.4% (agent with grep) 55.2% GBrain behind by 12.2 pts
Window-sized chats — LoCoMo (200 questions) 84.2% (whole conversation pasted) 80.0% GBrain behind by 4.2 pts

When not to use GBrain: Skip it if your notes fit inside one prompt window, or if you are a single user grepping huge chat logs with no need for shared access or permissions (what you'd build without GBrain).

Architecture

flowchart LR
    Files[Markdown + wikilinks & frontmatter] <--> Sync[Sync & parse]
    Sync --> DB[(PGLite or Postgres + pgvector)]
    Agent[AI agents via MCP] <--> Engine[Keyword / hybrid search & typed graph]
    CLI[CLI search & optional gbrain think] <--> Engine
    Engine <--> DB

Docs


MIT License · Contributing · Security · Origin story

gbrain (garrytan/gbrain)

Searching Database…

33.8K ·GitHub
What is this?GBrain is a memory-and-knowledge layer for AI coding agents: instead of raw search hits it returns synthesized, well-cited answers across your pages, people, companies and ideas, plus a self-wiring knowledge graph and an explicit note on what it doesn't know yet. Garry Tan (YC's CEO) built it to run his own OpenClaw and Hermes agents.
Is this an app I open, or something my coding agent uses?It's a layer your coding agent uses, not an app you open: a bun-installed CLI wired over MCP, running against a local database — or an always-on daemon on your own server. A lighter two-command mode just adds a seven-verb memory protocol (recall, remember, and more) to any coding agent.
How do I get it running?Install with bun install -g github:garrytan/gbrain, then open Codex or Claude Code in a new empty folder and paste the install block. In ~15 minutes you get a short interview, identity files, a local brain ready in 2 seconds (no server), MCP wiring, and a private GitHub repo. The always-on OpenClaw/Hermes path takes ~30 minutes.
Does it work without any API keys?Yes — keyless mode gives keyword search plus whatever memory the agent writes itself. Optional keys upgrade it: OpenAI adds semantic search and automatic fact extraction, Voyage adds semantic search, Anthropic adds fact extraction.
What's the biggest install trap?The npm package named gbrain is unrelated to this project, and installing it can shadow the real binary on your PATH. Install only via the GitHub path, and gbrain doctor detects and prints the fix if you already tripped the trap.
Is my brain stored locally or in someone else's cloud?On your hardware, your DB, your keys: the brain is a local database and every memory is a markdown file in your own private GitHub repo, which you can clone or delete. Company-brain mode scopes each person's slice by login, fuzz-tested across all read paths with zero leaks.
What does the knowledge graph add over plain search?Every page write extracts entity references and creates typed edges — attended, worksat, investedin, founded, advises — with zero LLM calls, so questions like 'who works at Acme AI?' get answers vector search alone can't reach. On a 240-page test corpus it hit P@5 49.1% and R@5 97.9%, about 31 points of precision over the graph-disabled variant.
What happens when it runs around the clock?Cron jobs ingest meetings, emails, tweets and voice calls while you sleep, enrich every person and company the agent encounters, and consolidate memory overnight — the author's production deployment holds 155,795 pages, 24,589 people, 5,340 companies and 66 autonomous cron jobs.
Can it pull in my existing Gmail, calendar, and contacts?Yes — the cold-start 'fill my brain' skill imports them one consented step at a time: via the native connector (gbrain google setup, tokens kept in a local credential vault, never held by the agent), via ClawVisor (a hosted OAuth gateway), or from offline archives like Google Takeout.
How much does the always-on setup cost to run?The Codex and Claude Code paths run on the ChatGPT or Claude subscription you already have, with nothing deployed. OpenClaw/Hermes is the costly path: a server with 8GB+ RAM (one-click deploys exist for Render and Railway) plus API token usage that scales with how hard the agent runs.
Creator
garrytan
Size
660.7 MB
Stars
33.8K
Age
7mo
Commits · 90 Days