CLI commands
Manage saved MCP servers
This page covers the OpenClaw MCP client-side registry: the subcommands that
read and write mcp.servers definitions, their Codex approval behavior, and
ready-made server recipes.
OpenClaw as an MCP client registry
This is the openclaw mcp list, show, status, doctor, probe, add, set,
configure, tools, login, logout, reload, and unset path.
These commands do not expose OpenClaw over MCP. They manage OpenClaw-managed MCP server definitions under mcp.servers in OpenClaw config. They do not read mcporter servers from config/mcporter.json.
Those saved definitions are for runtimes that OpenClaw launches or configures later, such as embedded OpenClaw and other runtime adapters. OpenClaw stores the definitions centrally so those runtimes do not need to keep their own duplicate MCP server lists.
Important behavior
- these commands only read or write OpenClaw config
status,list,show,doctorwithout--probe,set,configure,tools,logout,reload, andunsetdo not connect to the target MCP serverloginperforms the MCP OAuth network flow for the configured HTTP server and saves the resulting local credentialsstatus --verboseprints resolved transport, auth, timeout, filter, and parallel-tool-call hints without connectingdoctorchecks saved definitions for local setup problems such as missing stdio commands, invalid working directories, missing TLS files, disabled servers, literal sensitive header/env values, and incomplete OAuth authorizationdoctor --probeadds the same live connection proof asprobeafter static checks passprobeconnects to the selected server or all configured servers, lists tools, and reports capabilities/diagnosticsaddbuilds a definition from flags and probes before saving unless--no-probeis set or OAuth authorization is needed first- runtime adapters decide which transport shapes they actually support at execution time
enabled: falsekeeps a server saved but excludes it from embedded runtime discoveryrequestTimeoutMsandconnectionTimeoutMsset per-server request and connection timeouts in millisecondssupportsParallelToolCalls: truemarks servers that adapters can call concurrently- HTTP servers can use static headers, OAuth login, TLS verification control, and mTLS certificate/key paths
- embedded OpenClaw exposes configured MCP tools in normal
codingandmessagingtool profiles;minimalstill hides them, andtools.deny: ["bundle-mcp"]disables them explicitly - per-server
toolFilter.includeandtoolFilter.excludefilter discovered MCP tools before they become OpenClaw tools - servers that advertise resources or prompts also expose utility tools for listing/reading resources and listing/fetching prompts; those generated utility names (
resources_list,resources_read,prompts_list,prompts_get) use the same include/exclude filter - fetched prompts present their description and role-labeled messages to the agent, including native image blocks for vision-capable models; Code Mode keeps the original prompt JSON shape
- dynamic MCP tool-list changes invalidate the cached catalog for that session; the next discovery/use refreshes from the server
- repeated MCP tool request/protocol failures pause that server briefly so one broken server does not consume the whole turn
- session-scoped MCP runtimes stay alive between turns until session reset/deletion or compaction ID rollover, explicit Stop, a relevant server config change, or Gateway shutdown; owned stdio children terminate during cleanup
- detached one-shot runs without a surviving runtime session retire their MCP runtimes at run end; a retained transcript does not extend that lifetime
mcp.sessionIdleTtlMsis an opt-in idle timeout in milliseconds: unset or0keeps runtimes alive, and positive finite values enable idle eviction (fractions round down)- a Gateway admits at most 256 OpenClaw-managed runtimes with server connections across sessions and requester partitions; sessions without available servers and sign-in-only catalogs do not consume this limit. Reaching the limit rejects new admissions until you stop or reset unused sessions. See MCP configuration for details
Runtime adapters may normalize this shared registry into the shape their downstream client expects. For example, embedded OpenClaw consumes OpenClaw transport values directly, while Claude Code and Gemini receive CLI-native type values such as http, sse, or stdio.
Codex tool approvals
MCP tool approvals follow the effective Codex session permission posture unless
you explicitly override the server's approval mode. The default full-permission
posture does not prompt, including for tools without MCP safety annotations.
Stricter postures retain approval checks: workspace can use automatic review,
while guarded and read-only can prompt the operator for unannotated tools.
Interactive turns can approve those calls in the Control UI.
For a server you trust, set the mode while adding it:
openclaw mcp add memory \ --command npx \ --arg -y \ --arg @modelcontextprotocol/server-memory \ --approval approveFor an existing saved server, update only its approval mode:
openclaw mcp configure memory --approval approveThe flag writes codex.defaultToolsApprovalMode. An explicit
openclaw mcp configure <server> --approval approve|prompt|auto overrides the
posture-derived default for that server: approve bypasses per-call approval,
prompt asks for every call, and auto uses the tool's safety annotations.
Use approve only for trusted servers. mcp probe and mcp doctor --probe
warn when a server uses auto and none of its tools has safety annotations;
that warning describes calls under prompting postures.
When offered, Allow Always approves the tool, not just the current arguments.
For Gateway-hosted Codex runs on servers configured in mcp.servers, OpenClaw
saves a durable, per-agent server/tool grant in the host approvals document
when durable persistence is offered and the approval matches one live Gateway-owned
tool call unambiguously. Missing or ambiguous matches and requests
that permit only session persistence retain Codex's native/session behavior.
Codex apps, native plugin servers, and computer-use servers are excluded.
Stored grants apply under auto or an unspecified server mode. Explicit
prompt keeps asking, even with a grant; explicit approve already bypasses
approval. A new grant is picked up at the next thread configuration and hook
registration, such as a new session or restart. The current session continues
on Codex's remembered decision.
Use openclaw approvals get --gateway to inspect grants and
openclaw approvals set --gateway --file <file> to revoke them by editing
agents.<agentId>.mcpTools. Revocation also takes effect on the next
preparation/registration. Codex can additionally persist its own approval
when the server is saved in native config; revoke that separately if present.
See MCP tool grants for the document
shape and export/edit workflow.
For approval delivery through Slack buttons, see Native approvals in Slack.
When an operator denies an MCP tool approval, Codex reports only its generic "user rejected MCP tool call" to the model; the remedy is shown on the operator card, not to the model.
The optional codex block is OpenClaw projection metadata for Codex app-server
threads only; it does not change ACP sessions, generic Codex harness config, or
other runtime adapters. Use non-empty codex.agents to project a server only
into specific OpenClaw agent ids. Empty, blank, or invalid agent lists are
rejected by config validation and omitted by the runtime projection path
instead of becoming global. OpenClaw strips the codex metadata before handing
the native mcp_servers config to Codex.
Saved MCP server definitions
Commands:
openclaw mcp list [--json]openclaw mcp show [name] [--json]openclaw mcp status [--verbose] [--json]openclaw mcp doctor [name] [--probe] [--json]openclaw mcp probe [name] [--json]openclaw mcp add <name> [flags]openclaw mcp set <name> <json>openclaw mcp configure <name> [flags]openclaw mcp tools <name> [--include csv] [--exclude csv] [--clear]openclaw mcp login <name> [--code code]openclaw mcp logout <name>openclaw mcp reloadopenclaw mcp unset <name>
Notes:
listsorts server names.showwithout a name prints the full configured MCP server object.statusclassifies configured transports without connecting.--verboseincludes resolved launch, timeout, OAuth, filter, and parallel-call details, including when stored OAuth tokens require additional authorization. Credential-bearing stdio arguments are redacted in text and JSON output.doctorperforms static checks without connecting. Add--probewhen the command should also verify that enabled servers connect.probeconnects and reports tool counts, resources/prompts support, list-change support, and diagnostics.addaccepts stdio flags such as--command,--arg,--env, and--cwd, or HTTP flags such as--url,--transport,--header,--auth oauth, TLS, timeout, and tool-selection flags. Use--approval auto|prompt|approveto set the Codex tool approval mode.setexpects one JSON object value on the command line.configureupdates enablement, tool filters, timeouts, OAuth, TLS, Codex approval mode, and parallel-tool-call hints without replacing the whole server definition. Add--probeto verify the updated server before saving.toolsupdates per-server tool filters. Include/exclude entries are MCP tool names and simple*globs.loginruns the OAuth flow for HTTP servers configured withauth: "oauth". For a loopback redirect, OpenClaw listens for the browser callback and completes login automatically. The printed--codecommand remains the fallback for remote, headless, or unreachable callbacks.logoutclears stored OAuth credentials for the named server without removing the saved server definition.reloaddisposes cached in-process MCP runtimes for the current CLI process only. Gateway or agent processes in another process still need their own reload or restart path.- Use
transport: "streamable-http"for Streamable HTTP MCP servers.openclaw mcp setalso normalizes CLI-nativetype: "http"to the same canonical config shape for compatibility. unsetfails if the named server does not exist.
Examples:
openclaw mcp listopenclaw mcp show context7 --jsonopenclaw mcp status --verboseopenclaw mcp doctor --probeopenclaw mcp probe context7 --jsonopenclaw mcp add memory --command npx --arg -y --arg @modelcontextprotocol/server-memoryopenclaw mcp set context7 '{"command":"uvx","args":["context7-mcp"]}'openclaw mcp tools context7 --include 'resolve-library-id,get-library-docs'openclaw mcp set docs '{"url":"https://mcp.example.com","transport":"streamable-http"}'openclaw mcp configure docs --timeout 20 --connect-timeout 5 --include 'search,read_*'openclaw mcp configure docs --auth oauth --oauth-scope 'docs.read'openclaw mcp login docsopenclaw mcp logout docsopenclaw mcp unset context7Common server recipes
These examples save server definitions only. Run openclaw mcp doctor --probe afterward to prove that the server starts and exposes tools.
Filesystem
openclaw mcp add files \ --command npx \ --arg -y \ --arg @modelcontextprotocol/server-filesystem \ --arg "$HOME/Documents" \ --include 'read_file,list_directory,search_files'openclaw mcp doctor files --probeScope filesystem servers to the smallest directory tree that the agent should read or edit.
Memory
openclaw mcp add memory \ --command npx \ --arg -y \ --arg @modelcontextprotocol/server-memoryopenclaw mcp probe memory --jsonUse a tool filter if the server exposes write tools that should not be available to normal agents.
Local script
openclaw mcp add local-tools \ --command node \ --arg ./dist/mcp-server.js \ --cwd /srv/openclaw-tools \ --env API_BASE=https://internal.exampleopenclaw mcp status --verbosedoctor checks that cwd exists and that the command resolves from the configured environment.
Remote HTTP
openclaw mcp add docs \ --url https://mcp.example.com/mcp \ --transport streamable-http \ --auth oauth \ --oauth-scope docs.read \ --timeout 20 \ --connect-timeout 5 \ --include 'search,read_*'openclaw mcp doctor docs --probeUse OAuth when the remote server supports it. If the server requires static headers, avoid committing literal bearer tokens.
Desktop/CUA
openclaw mcp set cua-driver '{"command":"cua-driver","args":["mcp"]}'openclaw mcp tools cua-driver --include 'list_apps,get_window_state,click,type_text'openclaw mcp doctor cua-driver --probeDirect desktop-control servers inherit the permissions of the process they launch. Use narrow tool filters and OS-level permission prompts.