Deploy ModusBrain Remote MCP Server
v0.26.0+:Access your brain from any device, any AI client. ModusBrain ships two transports:modusbrain serve --httpships full OAuth 2.1 (client credentials, auth code + PKCE, refresh rotation, optional DCR), an embedded React admin dashboard at/admin, scoped operations, and a live SSE activity feed. Pre-v0.26 legacy bearer tokens still work —verifyAccessTokenfalls back to theaccess_tokenstable and grandfathers tokens toread+write+admin. Postgres-only for the legacy fallback (theaccess_tokenstable is Postgres-only); OAuth tables work on both PGLite and Postgres. See SECURITY.md for env vars and tunable defaults.
modusbrain serve (stdio) for local agents, and modusbrain serve --http (v0.26.0+)
for remote clients over OAuth 2.1.
Three Paths
Local stdio (zero setup)
Remote over OAuth 2.1 (recommended, v0.26.0+)
/admin, and a live SSE activity feed. Zero external dependencies. This is
the only path that works with ChatGPT (OAuth 2.1 + PKCE is required by the
ChatGPT MCP connector). Pass --public-url whenever the server is reachable
at anything other than http://localhost:<port> so the OAuth issuer in
discovery metadata matches what clients hit (RFC 8414 §3.3).
Supported clients:
- ChatGPT — requires OAuth 2.1 + PKCE. Works natively with
--http. - Claude Desktop / Cowork — OAuth 2.1 or legacy bearer tokens.
- Perplexity — OAuth 2.1 client credentials grant.
- Claude Code, Cursor, Windsurf — can use OAuth or legacy bearer.
Remote with legacy bearer tokens (pre-v0.26 deployments) — Postgres only
- A Postgres-backed brain (the
access_tokenstable only exists on Postgres; runningmodusbrain serve --httpagainst a PGLite install fails fast at startup) - A machine running
modusbrain serve --http - A public tunnel (ngrok, Tailscale, or cloud host)
- A bearer token created via
modusbrain auth create <name>
read+write+admin scopes when you upgrade
to the HTTP server, so no migration is required.
OAuth 2.1 Setup (v0.26.0+)
1. Start the HTTP server
http://localhost:3131/admin and paste it to access the
dashboard. The dashboard shows live activity, registered clients, request logs,
and per-client config export.
v0.26.9+:mcp_request_log.paramsand the live SSE activity feed default to a redacted summary{redacted, kind, declared_keys, unknown_key_count, approx_bytes}. Declared param keys are kept (intersected against the operation’s spec); unknown keys are counted but never named, and byte sizes round up to 1KB so size-probe attacks can’t binary-search secret content. Operators on a personal laptop who want raw payloads back can passmodusbrain serve --http --log-full-params(loud stderr warning fires at startup). Multi-tenant deployments should leave it on the redacted default.
2. Register OAuth clients
Register clients from the/admin dashboard:
- Click Register client.
- Enter a name (e.g.
perplexity,chatgpt). - Pick scopes:
read,write,admin(checkboxes). - Pick grant type:
client_credentialsfor machine-to-machine (Perplexity, Claude Desktop bearer mode) orauthorization_codefor browser-based clients with PKCE (ChatGPT). - For
authorization_codeclients, paste the redirect URI. - Hit Register. The credential-reveal modal shows the
client_id(andclient_secretfor confidential clients) once. Copy or Download JSON immediately — secrets are hashed on storage and never shown again.
--source and --federated-read flags:
--source controls the write authority — put_page / add_link / etc only
land in dept-x. --federated-read controls the read axis independently;
queries return rows from any of the listed sources. Omit both flags for the
v0.33-compatible super-client shape. Pre-v0.34 clients are backfilled to
source_id='default' on modusbrain upgrade.
Host-repo wrappers can register programmatically:
--enable-dcr. DCR is off by default.
3. Expose the server
v0.34 — bind explicitly.modusbrain serve --http defaults to 127.0.0.1.
To accept connections from the ngrok tunnel (or any non-loopback source),
restart with --bind:
--public-url is set without --bind, a stderr WARN fires at
startup so the misconfiguration (“the tunnel is up but my agent gets
ECONNREFUSED”) is loud.
https://your-brain.ngrok.app. The MCP SDK’s
router exposes the spec-compliant discovery endpoint at
/.well-known/oauth-authorization-server.
4. Scopes and localOnly
Every operation is taggedread | write | admin. Four operations are
localOnly and rejected over HTTP regardless of scope: sync_brain,
file_upload, file_list, file_url. Remote agents cannot reach local
filesystem surface area.
Legacy Bearer Token Setup
Keep using pre-v0.26 bearer tokens if you aren’t ready to migrate. They grandfather toread+write+admin scopes on the HTTP server.
1. Set up the tunnel
See the ngrok-tunnel recipe for full setup. Quick version:2. Create access tokens
3. Connect your AI client
- ChatGPT: setup guide (OAuth 2.1 + PKCE, requires
modusbrain serve --http) - Claude Code: setup guide
- Claude Desktop: setup guide (must use GUI, not JSON config)
- Claude Cowork: setup guide
- Perplexity: setup guide
4. Verify
Operations
All 30 ModusBrain operations are available remotely, includingsync_brain and
file_upload (no timeout limits with self-hosted server).
Security note on file_upload: remote MCP callers are confined to the working
directory where modusbrain serve was launched. Symlinks, .. traversal, and absolute
paths outside cwd are rejected. Page slugs and filenames are allowlist-validated
(alphanumeric + hyphens; no control chars, RTL overrides, or backslashes). Local
CLI callers (modusbrain file upload ...) keep unrestricted filesystem access since
the user owns the machine.
Deployment Options
See ALTERNATIVES.md for a comparison of ngrok, Tailscale Funnel, and cloud hosts (Fly.io, Railway).Troubleshooting
“missing_auth” error Include the Authorization header:Authorization: Bearer YOUR_TOKEN
“invalid_token” error
Run modusbrain auth list to see active tokens.
“service_unavailable” error
Database connection failed. Check your Supabase dashboard for outages.
Claude Desktop doesn’t connect
Remote servers must be added via Settings > Integrations, NOT
claude_desktop_config.json. See CLAUDE_DESKTOP.md.
Expected Latencies
Note:
modusbrain serve --http shipped in v0.26.0 with OAuth 2.1 + admin
dashboard baked into the binary. The custom HTTP wrapper pattern (see
voice recipe) is still supported for
teams that need bespoke middleware, but for most remote deployments the
built-in server is the recommended path.