gbrain README

项目的 README,来自 github.com/garrytan/gbrain。合并为一个 markdown 文件: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 over MCP or the CLI. The default keyless brain retrieves and cites with keyword search and a typed knowledge graph; synthesis needs a connected agent or a chat API key.

MIT-licensed and free to self-host, or managed at gbrain.io.

Status: 0.x with frequent releases; #stable tracks soaked builds with a 14-day / 2-release deprecation window for documented CLI, MCP, and page contracts (stability); the opt-in Rust engine is experimental and off by default.

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?"

Your agent retrieves linked pages across Alice, Acme, and past meetings—returning cited answers that flag gaps:

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 retrieval, or your own Postgres Always-on memory across Claude, ChatGPT, Codex, and Cursor with nothing to host
Engine & keys Local PGLite (default, zero keys: keyword + typed graph) or Postgres + pgvector; add an embedding key for hybrid search on either, or a chat key for CLI think Managed Postgres + pgvector (hybrid keyword + vector search and typed graph included; paid plans)
Access Local stdio MCP + CLI, 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 embeddings), search it, and inspect graph edges
gbrain import <path-to-markdown-folder> --no-embed
gbrain search "pricing"
gbrain backlinks <slug>    # typed incoming links from [[wikilinks]] & frontmatter (e.g. companies/acme)

The default keyless brain retrieves and cites (search, backlinks, get); synthesis needs a connected agent over MCP (uses its own model) or a chat key (ANTHROPIC_API_KEY / OPENAI_API_KEY) for standalone CLI 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
Memory products (Mem0, Zep, Letta) Managed APIs and SDKs for conversational agent memory Plain Markdown on disk (Git-diffable, rebuildable), keyless local PGLite, and per-page permissions; published LongMemEval scores aren't comparable across vendors (different readers, judges, and budgets, self-reported—see docs/proof.md)

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

Builds & caveats: Measured across separate builds—row 1 on v0.60.613.0 (one person's private brain), row 2 on v0.60.95.0 (LongMemEval-S was a development set, not held-out), row 3 on 51f865d78, row 4 on v0.60.110.0, row 5 on v0.60.748.0, and row 6 on v0.60.138.0 (LoCoMo also informed tuning). Full dates, judges, and 95% intervals live in docs/proof.md.

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)

正在搜索数据库…

这是什么东西?GBrain 是给 AI 编程助手用的记忆和知识层:它不返回原始的搜索结果,而是给出经过整理、引用清晰的答案,覆盖你的页面、联系人、公司和想法,还会自动构建一张知识图谱,并明确告诉你它目前还不知道什么。它是 Garry Tan(YC 的 CEO)为自己运行 OpenClaw 和 Hermes 助手而开发的。
它是一个我打开的应用,还是给我的编程助手用的东西?它是给你的编程助手用的一个层,不是你打开的应用:一个用 bun 安装的 CLI,通过 MCP 接入,运行在本地数据库上——或者作为常驻后台服务跑在你自己的服务器上。还有一种更轻量的两命令模式,可以给任何编程助手加上一套只有七个动词的记忆协议(recall、remember 等)。
我该怎么把它跑起来?先用 bun install -g github:garrytan/gbrain 安装,然后在一个新的空文件夹里打开 Codex 或 Claude Code,粘贴安装代码块。大约 15 分钟后,你会完成一次简短的问答,生成身份文件,2 秒内就绪一个本地大脑(无需服务器),完成 MCP 接线,并得到一个私有的 GitHub 仓库。常驻的 OpenClaw/Hermes 方案大约需要 30 分钟。
不配任何 API 密钥也能用吗?可以——无密钥模式提供关键词搜索,加上助手自己写下的记忆。可选的密钥能增强功能:OpenAI 提供语义搜索和自动事实提取,Voyage 提供语义搜索,Anthropic 提供事实提取。
安装时最大的坑是什么?npm 上那个叫 gbrain 的包和本项目无关,装了它可能会在 PATH 上遮蔽真正的命令。只走 GitHub 这条安装路径;如果你已经踩了坑,gbrain doctor 能检测出来并打印修复方法。
我的大脑数据是存在本地,还是存在别人的云上?存在你自己的硬件、你自己的数据库、你自己的密钥上:大脑就是一个本地数据库,每条记忆都是你自己私有 GitHub 仓库里的一个 markdown 文件,你可以随时克隆或删除。公司大脑模式会按登录名划定每个人的可见范围,所有读取路径都经过模糊测试,零泄露。
和普通搜索相比,知识图谱能多带来什么?每次写入页面都会提取实体引用并建立带类型的边——attended、worksat、investedin、founded、advises——而且完全不用调用 LLM,所以像'谁在 Acme AI 工作?'这类问题能得到纯向量搜索给不出的答案。在一个 240 页的测试语料上,它的 P@5 达到 49.1%,R@5 达到 97.9%,精确率比关闭图谱的版本高出约 31 个百分点。
让它全天候运行会发生什么?定时任务会在你睡觉时吸收会议、邮件、推文和语音通话,为助手遇到的每个人和每家公司补充信息,并在夜间整理记忆——作者的生产环境里存有 155,795 个页面、24,589 个人、5,340 家公司和 66 个自主运行的定时任务。
它能导入我现有的 Gmail、日历和通讯录吗?可以——冷启动的'fill my brain'技能会一步一个确认地把它们导入:可以通过原生连接器(gbrain google setup,令牌保存在本地凭据库中,助手本身不会持有),可以通过 ClawVisor(一个托管式 OAuth 网关),也可以从 Google Takeout 这类离线归档导入。
常驻方案运行起来要花多少钱?Codex 和 Claude Code 这两条路用的是你已有的 ChatGPT 或 Claude 订阅,不需要部署任何东西。OpenClaw/Hermes 才是花钱的路:需要一台 8GB 以上内存的服务器(Render 和 Railway 有一键部署),外加随助手运行强度增长的 API 令牌费用。
作者
garrytan
大小
681.3 MB
星标
34K
时长
8个月
提交 · 90 天