Connect ModusBrain to Claude Code
New to this? The Give your coding agent a memory tutorial walks both paths (local-from-nothing and connect-to-an-existing-brain) end to end, plus the brain-first protocol that makes it worth it. This page is the connection reference.
Option 1: Local (recommended, zero server needed)
modusbrain serve as a stdio subprocess. No server, no
tunnel, no token needed. Works with both PGLite and Supabase engines.
Option 2: Remote, one command (fastest from a bearer token)
If ModusBrain is running somewhere as an HTTP server (modusbrain serve --http, see the
ngrok-tunnel recipe) and you have a bearer token,
let modusbrain connect generate the wire-up for you.
On the host (or anywhere modusbrain is installed), mint a token and print the block:
modusbrain connect prints a short, copy-paste block. Paste it into Claude Code — it
runs the claude mcp add for you and tells the agent to call get_brain_identity
and list_skills so it immediately knows what the brain can do.
Already on the machine you want to wire up? Skip the copy-paste and let connect
do it directly, with a built-in token smoke-test:
--install runs claude mcp add, then verifies the token by calling
get_brain_identity — so a wrong or expired token fails now, not silently on the
agent’s first request. The URL is normalized: a bare host without /mcp gets it
appended; pass an explicit https:// scheme.)
Pipe-friendly machine output (token redacted unless --show-token):
Option 3: Remote, manual claude mcp add
Equivalent to what modusbrain connect generates, if you’d rather run it yourself:
YOUR-DOMAIN with your ngrok domain and YOUR_TOKEN with a token from
modusbrain auth create "claude-code".
Amodusbrain auth createtoken is a long-lived, full-access secret. Keep it private (it lands in~/.claude.json), and prefer a scoped/short-lived token where your host supports one.
Verify
In Claude Code, try:list_skillsreturns nothing? Skill discovery is gated bymcp.publish_skillson the host. New brains frommodusbrain initdefault it ON; brains upgraded from an older release stay OFF until you opt in. Enable it on the host withmodusbrain config set mcp.publish_skills true. The core tools (search, query, get_page, put_page, think, find_experts) work regardless. Note:captureis a CLI-only command, not an MCP tool — the agent writes over MCP withput_page.