This page is the MCP-registration reference for Grok Build — xAI's official
grokCLI (early beta, subscriber-gated; not the communitysuperagent-ai/grok-cli, which ships a collidinggrokbinary — see Troubleshooting). For the full brain install — CLI, engine, skills, dream cycle — follow INSTALL_FOR_AGENTS.md first; this page wires the finished brain into Grok Build over stdio MCP. Thegbrain bootstrappersistent-personal-agent path is not yet supported for Grok (Claude Code and Codex only today) — brain-only install is what this page delivers.
Grok Build spawns gbrain serve as a local stdio subprocess. No server, no
tunnel, no token needed. Works with both PGLite and Supabase engines.
grok mcp add gbrain -e "GBRAIN_HOME=$HOME" -- gbrain serve --surface verbs--surface verbs exposes the seven-verb memory protocol (recall,
remember, entity, synthesize, forget, context_pack, delta —
MEMORY_VERBS v1) instead of the full
100+-op catalog — the recommended starting surface for coding agents.
Three facts about grok mcp add, all observed:
- The env flag is repeatable, one
KEY=valueper flag (-e A=1 -e B=2). Server argv goes after--. - Registration is lazy. The add writes config and exits 0 without
connecting — even for a nonexistent command. Verify with
grok mcp doctor(below), never with the add's exit code. - Scope: the default writes to
~/.grok/config.toml; add-s projectto write a committable./.grok/config.tomlinstead (reference secrets as${VAR}in project scope — values are stored verbatim).
The add command writes an [mcp_servers.gbrain] block into
~/.grok/config.toml (or ./.grok/config.toml with project scope; the
GROK_HOME env var relocates the user config dir). You can write it
yourself instead:
[mcp_servers.gbrain]
command = "gbrain"
args = ["serve", "--surface", "verbs"]
startup_timeout_sec = 60
enabled = true
[mcp_servers.gbrain.env]
GBRAIN_HOME = "/home/alice-example"startup_timeout_sec defaults to 30; raise it (or export
GROK_MCP_STARTUP_TIMEOUT_SECS) if gbrain runs from source via bun run,
which cold-transpiles on first spawn. To remove gbrain, delete the block (or
set enabled = false to disable without losing the config).
Grok Build also reads MCP registrations from ~/.claude.json, .cursor/mcp.json,
and a project .mcp.json — at lower priority than its own config, and only
for folders you have trusted in Grok (fresh folders report
folder untrusted until you accept the trust prompt). If you already
registered gbrain for Claude Code, Grok may pick it up with zero
configuration. grok mcp doctor --json reports every source it consulted
and which one each server came from — check the source field to see which
config won before assuming the native one did.
grok mcp list --json # entry: {"name":"gbrain","enabled":true,...}
grok mcp doctor gbrain # THE real probe: spawns the servergrok mcp doctor gbrain performs the actual handshake — expect the checks
command found, server started, handshake OK, and 7 tools discovered
(the seven verbs), exit 0. A broken registration exits 1 with a failing
check and a hint. Then one real round-trip:
grok -p "use the gbrain recall tool to answer: what did I import most recently?"grok -p (single-turn headless) prints the final answer on stdout.
For cron jobs, CI, or any non-TTY run:
-
Auth: export
XAI_API_KEY(from console.x.ai). Keyless headless runs exit 1 withNot signed in;grok login --device-codeis the interactive-terminal alternative,grok loginthe browser one. -
Model pin: pass
-m <model>per call, or set it in config:[models] default = "grok-4.5"
-
Updates: Grok self-updates by default. For pinned/reproducible environments, seed:
[cli] auto_update = false
Grok Build has no built-in cron; schedule headless one-shots with your system scheduler:
# crontab: brain maintenance every 4 hours
0 */4 * * * XAI_API_KEY=... grok -p "Run gbrain sync and report anything unusual" --output-format plainSee docs/guides/cron-schedule.md for the full brain maintenance protocol (sync, embed, dream cycle).
- Wrong
grokon PATH — the communitysuperagent-ai/grok-clialso installs agrokbinary. The official CLI answersgrok --versionwithgrok X.Y.Z (buildhash); anything else is the other tool. Install the official one vianpm install -g @xai-official/grokorcurl -fsSL https://x.ai/cli/install.sh | bash. - grok ≠ groq ≠ ngrok — Grok Build (xAI,
XAI_API_KEY) is not Groq (the inference provider,GROQ_API_KEY) and not ngrok (tunnels). A mis-set key produces auth errors against the wrong service. Not signed in(exit 1) — no auth in a headless run. ExportXAI_API_KEYor rungrok login --device-code.- Doctor says
folder untrusted— the registration came from a vendor config (.mcp.json/~/.claude.json) in a folder Grok hasn't been told to trust. Trust the folder in an interactive session, or register natively withgrok mcp add. - Doctor times out on
server started— raisestartup_timeout_sec(orGROK_MCP_STARTUP_TIMEOUT_SECS=90) if gbrain runs viabun run. - Skills note:
gbrain skillpack scaffoldwritesskills/<name>/SKILL.mdinto your workspace, which Grok does not auto-discover as Grok skills (it reads.grok/skills,~/.grok/skills,~/.agents/skills, plugins). gbrain's skills still work as reference documents the agent reads;grok inspectshows what Grok actually discovered. grok inspect— the config-discovery audit: version, cwd trust, instructions, permissions, skills, agents, MCP sources.
Verified against Grok Build v1.0.4 (early beta — expect churn; the pin is enforced in CI). Dev-facing observed-behavior notes (exact flag semantics, exit-code caveats, config schema, CI pin values) live in GROK-CLI-PIN.md.