On this page
On this page
CLI commands
Transports and OAuth
These are the transport shapes a saved MCP server definition can use, and the OAuth workflow that HTTP transports can authenticate with.
When Codex owns the MCP connection, explicit connectionTimeoutMs values control
startup, including initialization and initial tool discovery, and
requestTimeoutMs values control tool calls. OpenClaw preserves millisecond
precision when converting these values to Codex's seconds-based settings; unset
values keep Codex's defaults. The supportsParallelToolCalls hint is also
forwarded. Codex can additionally run tools with a readOnlyHint annotation in
parallel.
Stdio transport
Launches a local child process and communicates over stdin/stdout.
| Field | Description |
|---|---|
command |
Executable to spawn (required) |
args |
Array of command-line arguments |
env |
Extra environment variables |
cwd / workingDirectory |
Working directory for the process |
Shutdown can force a slow anchor and relay to exit after their control, output, and lineage pipes close. A still-live anchor is killed and reaped through its relay. If the anchor group is already gone, the host can kill an unresponsive relay directly. The host then confirms actual exit and group disappearance. Confirmed cleanup completes normally; a later connection starts a fresh server. Unconfirmed cleanup still reports an error with the missing closure facts, elapsed time, and any failed signal delivery. The cleanup deadline does not change when shutdown escalates.
For a supported docker run command, OpenClaw assigns container ownership labels
and a temporary Docker CID file. Closing the connection sends the container's
configured stop signal with the existing two-second stdio grace, then removes
that exact container through the same Docker daemon, including when initialization
times out. On Gateway startup, OpenClaw also reclaims labeled containers from a previous
Gateway whose process is proven to have exited. Containers without this state
directory's ownership label are left alone; an unavailable daemon or an unknown
process identity produces a warning and preserves the container.
Connection deadlines stay unchanged. If Docker is still creating a container, cleanup retains its client and exclusive state ownership until Docker reports the container ID or the client exits. A warning identifies pending cleanup. Unconfirmed removal also retains state ownership; inspect Docker and restart the owning OpenClaw process before retrying.
This also supports a single literal sh -c 'exec docker run ...' wrapper.
Shell expansions, pipelines, additional commands, unknown Docker options, existing
CID files, and openclaw.mcp.* label conflicts disable automatic container custody
and produce a warning. The original command still runs. Use a direct docker run
argument array for predictable cleanup. Recovery inspects only Docker daemons
referenced by the current enabled MCP configuration, so retain the server definition
until any containers from an interrupted Gateway have been reclaimed.
SSE / HTTP transport
Connects to a remote MCP server over HTTP Server-Sent Events.
| Field | Description |
|---|---|
url |
HTTP or HTTPS URL of the remote server (required) |
headers |
Optional key-value map of HTTP headers (for example auth tokens) |
connectionTimeoutMs |
Per-server connection timeout in ms (optional) |
requestTimeoutMs |
Per-server MCP request timeout in milliseconds |
auth: "oauth" |
Use MCP OAuth credentials saved by openclaw mcp login |
sslVerify |
Set false only for explicitly trusted private HTTPS endpoints |
clientCert / clientKey |
mTLS client certificate and key paths |
supportsParallelToolCalls |
Hint that concurrent calls are safe for this server |
Example:
Sensitive values in url (userinfo) and headers are redacted in logs and status output. openclaw mcp doctor warns when sensitive-looking headers or env entries contain literal values, so operators can move those values out of committed config.
Doctor checks the authored values, including values from $include files, before environment substitution. References such as ${MCP_TOKEN} and Bearer ${MCP_TOKEN} do not trigger the literal-value warning when the variable is set. Nonempty literal fallbacks such as ${MCP_TOKEN:-literal-token}, escaped placeholders, and literal text around references still warn; Bearer and Basic auth scheme prefixes are allowed. Connection probes still use the resolved values.
If a legacy SSE message endpoint returns HTTP 404, or a stateful Streamable HTTP session expires, OpenClaw retires that connection and reconnects on the next discovery. The failed call is reported without replaying it, because a tool may have already changed state before the connection failed.
OAuth workflow
OAuth is for HTTP MCP servers that advertise the MCP OAuth flow. Static Authorization headers are ignored for a server while auth: "oauth" is enabled. By default, OAuth credentials are shared and operator-managed. Credentials saved by openclaw mcp login work with embedded MCP, CLI runners, and the local Codex app-server.
Native MCP OAuth sessions live in the owner-only shared SQLite database at <state-dir>/state/openclaw.sqlite (mcp_oauth_stores). The row can contain access and refresh tokens, dynamic client registration secrets, discovery metadata, and the temporary PKCE verifier. Refresh, login, and logout use the same SQLite lease, so parallel OpenClaw processes cannot consume one refresh token or resurrect a logged-out session.
Upgrades from the retired <state-dir>/mcp-oauth/*.json store are handled only by openclaw doctor --fix. Runtime code never reads, writes, or falls back to those files.
Until shared credentials are available, OpenClaw withholds that server's account tools instead of failing the agent turn. The owner can ask the agent to connect in a direct chat and receive a sign-in link in the same turn, or run openclaw mcp login <name> while the Gateway runs. After approval, send another message to use the server; no Gateway restart is needed. Shared sign-in links are not posted in group chats.
If a server rejects a token with insufficient_scope, OpenClaw preserves the requested scope and asks for openclaw mcp login <name> instead of repeating a refresh that cannot grant new scope. That login starts a new authorization request while keeping the previous token until replacement credentials are saved.
When a remote MCP service is already backed by a separate OpenClaw refresh-capable auth profile, you can optionally set oauth.authProfileId. OpenClaw refreshes either credential source before runtime projection and passes only the current access token to the downstream MCP client.
Set oauth.identity: "per-requester" when every authenticated sender should connect a separate account. Per-requester OAuth requires an HTTP server URL and cannot use oauth.authProfileId. Configure gateway.publicOrigin as the externally reachable HTTPS origin of the Gateway; HTTP is accepted only for literal loopback hosts (localhost, 127.0.0.1, or [::1]) during local development. The provider redirects to <gateway.publicOrigin>/oauth/mcp/callback after authorization.
The per-requester flow is sender-driven:
- The sender calls a tool from the server before connecting an account.
- OpenClaw returns a sign-in link for that sender instead of exposing another sender's credentials.
- The provider redirects through the Gateway callback. After the callback succeeds, the sender retries the tool call with their connected account.
In authenticated Control UI chat, ask the agent to connect the server to get an OAuth link for your current verified profile. Verified people using Gateway chat through a trusted proxy or calling the OpenAI-compatible APIs use the same personal account as MCP Apps. This does not change transport sender IDs or turn attribution. If you previously connected through a shared Gateway backend identity, sign in once as yourself; the existing backend credential is not copied or deleted.
Settings → MCP and the CLI still manage shared operator credentials, not personal connections. Scheduled work and subagents do not inherit a person's account. If several people steer the same ongoing browser turn, start a new turn before requesting personal access.
For per-requester accounts, missing gateway.publicOrigin is reported by the sign-in result and openclaw doctor. Shared operator sign-in instead falls back to the Gateway's loopback address. openclaw mcp login and openclaw mcp logout manage only shared credentials, not per-requester accounts.
Sign-in links are single-use bearer links: any chat participant who opens one connects their own account to the sender the link was issued for. Use per-requester OAuth only on mutually trusted chat surfaces or in a private session; a requester-private sign-in handoff is tracked as follow-up work.
The shared operator flow uses the following commands:
Save the server
Add or update the server with auth: "oauth" and any optional OAuth metadata.
For an auth-profile-backed bearer, save the profile binding:
Start login
Run login to create the authorization request.
With the Gateway running, login asks that Gateway to create the sign-in link and prints it. The provider redirects to <gateway.publicOrigin>/oauth/mcp/callback, or to http://127.0.0.1:<gateway-port>/oauth/mcp/callback without a public origin. Approve the request until the page says You're connected. The Gateway saves credentials in shared SQLite and the next agent turn can use them.
With the Gateway stopped, login keeps its local loopback flow: it starts a callback listener and waits for the browser to return. Offline login resolves configured mcp.servers; the running Gateway can also resolve plugin-declared servers.
If the OAuth server rejects dynamic client registration, offline login reports the HTTP status and any recognized OAuth error code instead of printing a sign-in URL. Check the provider's client registration settings before retrying.
Providers may register an HTTP loopback callback without a port, as allowed by RFC 8252. OpenClaw retains that registration for the same 127.0.0.1, [::1], or localhost callback while sending the listener's port in authorization and token requests. Other callback components must match; non-loopback callbacks still require an exact match.
Use the manual fallback when needed
With a running Gateway, if the browser is on another device and cannot load the loopback callback, copy the complete failed redirect address. Paste it into the direct chat that started sign-in, or pass it to the CLI:
Keep the entire URL, including state and any iss value. The code is single-use and bound to the original state and PKCE verifier.
For an offline CLI attempt only, use the returned code with --code. If the redirect includes iss, pass its exact decoded value with --issuer:
Check authorization
Use status or doctor to confirm that tokens are present and do not require additional authorization. If status reports authorization-required or doctor asks for additional authorization, run openclaw mcp login <name> again.
Clear credentials
Logout removes stored OAuth credentials but keeps the saved server definition.
If the provider rotates tokens or the authorization state gets stuck, run openclaw mcp logout <name>, then repeat login. logout can clear credentials for a saved HTTP server even after auth: "oauth" has been removed from config, as long as the server name and URL still identify the credential store entry.
Streamable HTTP transport
streamable-http is an additional transport option alongside sse and stdio. It uses HTTP streaming for bidirectional communication with remote MCP servers.
On each streamable-http connection, OpenClaw first sends server/discover. A server that offers 2026-07-28 can use that protocol. A legacy-only counteroffer can select the initialize handshake. OpenClaw also tries that handshake when an older server rejects or leaves the discovery probe unanswered. A version error that lists modern revisions with no modern overlap ends the attempt, including when it also lists an older revision. OpenClaw waits up to 5 seconds (or half of connectionTimeoutMs, if shorter) for that answer. A sign-in or token refresh that fails is not tried a second time. Ordinary session tools use the initialize handshake over stdio and sse.
Ordinary session tools return completed actions and server refusals on 2026-07-28. A server can defer work using only its request state. An embedded request for client input ends the call. Operations that require form confirmation remain refused even with the MCP Apps host enabled. Servers using the legacy handshake retain URL elicitation and can request forms when the Apps host is enabled.
| Field | Description |
|---|---|
url |
HTTP or HTTPS URL of the remote server (required) |
transport |
Set to "streamable-http" to select this transport; when omitted, OpenClaw uses sse |
headers |
Optional key-value map of HTTP headers (for example auth tokens) |
connectionTimeoutMs |
Per-server connection timeout in ms (optional) |
requestTimeoutMs |
Per-server MCP request timeout in milliseconds |
auth: "oauth" |
Use MCP OAuth credentials saved by openclaw mcp login |
sslVerify |
Set false only for explicitly trusted private HTTPS endpoints |
clientCert / clientKey |
mTLS client certificate and key paths |
supportsParallelToolCalls |
Hint that concurrent calls are safe for this server |
OpenClaw config uses transport: "streamable-http" as the current spelling. CLI-native MCP type: "http" values are accepted when saved through openclaw mcp set and repaired by openclaw doctor --fix in existing config, but transport is what embedded OpenClaw consumes directly.
Example: