Deploy GBrain

GBrain: Garry Tan's agent memory on Postgres, over MCP for Claude and Codex

Deploy GBrain

Just deployed

Deploy and Host GBrain on Railway

GBrain is the agent memory Garry Tan built for his own OpenClaw and Hermes agents: pages for people, companies and ideas, a knowledge graph between them, and hybrid keyword plus semantic search, served to your AI clients over MCP. This template runs GBrain 0.60.311.0 on Railway with Postgres and pgvector, the HTTP MCP server (OAuth 2.1 and an admin dashboard) and the jobs worker, so Claude Code, Codex, ChatGPT and Claude Desktop share one brain from any machine.

About Hosting GBrain

GBrain defaults to PGLite, a Postgres that runs inside the process. Upstream recommends real Postgres with pgvector for a brain that several clients or machines use, so that's what this template sets up: gbrain init runs on the first start against the Postgres service, and the brain's markdown lives in a git repo on the volume at /data/brain.

The server runs gbrain serve --http. Nothing on it is open without a credential: /mcp needs a bearer token or an OAuth client, and the admin dashboard at /admin takes the owner credential, GBRAIN_ADMIN_BOOTSTRAP_TOKEN, generated per deploy. Upstream hides that credential from logs on headless starts, so read it from the variable. In the dashboard you mint an API key per client (API keys, then + API Key) and connect:

claude mcp add gbrain -t http https:///mcp -H "Authorization: Bearer "

Codex takes codex mcp add gbrain --url https:///mcp --bearer-token-env-var GBRAIN_REMOTE_TOKEN. ChatGPT and Claude Desktop use OAuth; register the client on the dashboard's Agents page.

Semantic search needs an embedding key. Set OPENROUTER_API_KEY (or OPENAI_API_KEY, or VOYAGE_API_KEY for GBrain's default Voyage embeddings) before the first start, and GBrain picks the provider from it; with no key, search is keyword-only. The jobs worker (gbrain jobs supervisor) runs in the same container and handles embedding, sync and agent jobs. GBRAIN_AUTOPILOT=true runs autopilot instead, the maintenance loop that also extracts facts and enriches pages overnight. It's off by default because it spends model tokens on every cycle.

Before publishing I tested it on Railway. /health answered, /mcp returned 401 without a token, and the admin login refused a wrong credential. I signed in to the dashboard with the generated owner credential, minted an API key and connected over MCP. I wrote two pages with put_page, one about a rooftop saffron garden and one about a billing calendar, then asked "What flower ends up in the employees lunch?", which shares no word with either page. The garden page came back first, and "When are the tax filings due?" put the billing page first. GBrain picked OpenRouter's text-embedding-3-small from the key without being told. After restarting GBrain and Postgres, the owner credential still worked and both pages came back for both questions, in the same order.

Idle, GBrain (server and worker together) used about 0.25 GB of RAM and Postgres under 0.1 GB. Embeddings are cheap next to chat: text-embedding-3-small through OpenRouter is listed at $0.02 per million tokens.

Common Use Cases

  • One memory shared by Claude Code, Codex and ChatGPT, so a fact saved in one is there in the others
  • A brain for a Hermes or OpenClaw agent running on a server, reachable while your laptop is closed
  • A small team's notes on customers and projects, with scoped API keys per person or agent

Dependencies for GBrain Hosting

An OpenRouter, OpenAI or Voyage key for semantic search (optional), and an MCP client.

Deployment Dependencies

Implementation Details

GBRAIN_MCP_URL                 # https:///mcp, for your clients
GBRAIN_ADMIN_URL               # the dashboard
GBRAIN_ADMIN_BOOTSTRAP_TOKEN   # owner credential for the dashboard (generated)
/data                          # volume: config, logs and the brain's markdown (git) in /data/brain

If you add a custom domain, set GBRAIN_PUBLIC_URL to it and redeploy, since OAuth clients check the issuer URL. GBrain is pinned in the wrapper's Dockerfile (GBRAIN_REF); upstream ships several releases a day, and migrations run on every start.

Why Deploy GBrain on Railway?

The brain, its Postgres and the worker run in one project with HTTPS in front, so your agents reach the same memory from anywhere. Railway bills the RAM and CPU they use, not a fixed machine.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
117
View Template
NEW
Möbius v0.1 Personal AI OS
Self-hosted AI agent that builds and runs apps for you, with memory.

bento
1
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
7