Skip to content

garrytan/gbrain

⭐ 14,336  ·  TypeScript  ·  GitHub Repo

Garry's Opinionated OpenClaw/Hermes Agent Brain

1-Sentence Summary

Self-wiring knowledge graph for AI agents that eliminates forgetfulness with zero-LLM entity extraction.

🔥 Key Capabilities & USP

  • Zero-LLM-Call Entity Extraction — The crown jewel. Automatically creates typed links (attended, works_at, invested_in, founded, advises) during every page write without a single LLM call. This eliminates the latency, cost, and hallucination risks of LLM-based extraction while achieving 49.1% P@5 and 97.9% R@5 — beating vector-only and BM25 approaches by over 31 points.

  • Self-Wiring Knowledge Graph with Hybrid Search — Combines vector search with graph-based backlink-boosted ranking. Solves the fundamental pain point of agent forgetfulness by enabling structured queries like "who works at Acme AI?" or "what did Bob invest in this quarter?" — queries that pure vector search fundamentally cannot answer.

  • 34 Pre-Built Agent Skills — Ships organized skill files including 9 research-flavored skills like book-mirror. This dramatically reduces the time from concept to working agent, providing a turnkey cognitive architecture rather than just a retrieval library.

  • Production-Grade MCP Server with OAuth 2.1 — Exposes 30+ MCP tools via stdio or HTTP with full OAuth 2.1 support (client credentials, authorization code + PKCE, refresh token rotation), scoped operations, and an embedded React admin dashboard. This is enterprise-ready out of the box.

  • Built-in Evaluation Framework (BrainBench-Real) — Opt-in session capture and replay system with mean Jaccard@k, top-1 stability, and latency delta metrics. You can benchmark every retrieval change with LongMemEval support, running at 25.9ms p50 per question on Apple Silicon.

Technical Architecture

ComponentTechnologyWhy It Matters
DatabasePGLite (in-browser PostgreSQL)No server needed, ready in 2 seconds, zero ops overhead
RuntimeBunBlazing fast JavaScript/TypeScript execution
SearchHybrid (vector + graph backlink-boosted ranking)Combines semantic similarity with structured graph traversal
Entity ExtractionZero-LLM-call typed link system97.9% R@5 without latency or cost of LLM calls
MCP Transportstdio + HTTP with OAuth 2.1Production-grade auth, supports both local and remote deployments
EvaluationLongMemEval + BrainBench-Real25.9ms p50 per question, built-in benchmarking

Quick Start Guide

bash
git clone https://github.com/garrytan/gbrain.git && cd gbrain && bun install && bun link
gbrain init                     # local brain, ready in 2 seconds
gbrain import ~/notes/          # index your markdown
gbrain query "what themes show up across my notes?"

MCP server configuration:

json
{
  "mcpServers": {
    "gbrain": { "command": "gbrain", "args": ["serve"] }
  }
}

HTTP server with OAuth:

bash
gbrain serve --http --port 3131
open http://localhost:3131/admin

Code lookup commands:

bash
gbrain code-callers searchKeyword
gbrain code-callees searchKeyword
gbrain code-def BrainEngine
gbrain code-refs BrainEngine
gbrain query "how does N+1 handling work" --near-symbol BrainEngine.searchKeyword --walk-depth 2

Pros, Cons & Use Cases

Pros

  • Blazing fast setup — Fully working brain in ~30 minutes, PGLite ready in 2 seconds
  • Autonomous memory consolidation — No manual tagging or schema design needed
  • Production-proven — 17,888 pages, 4,383 people, 723 companies indexed
  • Built-in evaluation — Benchmark every change with BrainBench-Real
  • Zero LLM cost for entity extraction — massive savings at scale

Cons

  • No npm/bun install — Cannot install via bun install -g due to postinstall hook issues and package name squatting; requires git clone + bun install && bun link
  • Package name squatting — npm registry has an unrelated package squatting the gbrain name, causing confusion
  • Bun dependency — Requires Bun runtime, not compatible with Node.js or Deno without adaptation

Who should NOT use this?

  • Teams without Bun in their stack — If you're locked into Node.js or Deno and cannot introduce Bun, the installation friction and runtime mismatch will outweigh the benefits.
  • Projects needing simple vector search only — If your use case is basic semantic search over documents without structured relationships, the graph complexity is overkill.
  • Teams allergic to CLI-first tools — While there's an admin dashboard, the primary interface is command-line; teams expecting a GUI-first experience will be frustrated.

Ideal Use Cases

  • AI agent developers running OpenClaw or Hermes Agent who need persistent, structured memory
  • Engineering teams using GStack for code lookup and analysis across large codebases
  • Knowledge workers who want to autonomously index meetings, emails, tweets, and calls into a queryable brain
  • Research teams needing to track entities, relationships, and temporal queries across heterogeneous data sources

Community & Activity

With 14,336 stars and a last update on May 10, 2026, GBrain is clearly a project with serious momentum and active maintenance. This isn't a weekend experiment — it's a production-grade tool with a thriving community and a creator (Garry Tan) who is deeply invested in the AI agent ecosystem. The combination of a large star count and recent commits signals both widespread adoption and ongoing development. If you're building agents that need to remember, this is the project to watch.

Project data from GitHub API, updated in real-time