In OpenClaw, what is the difference between openclaw mcp serve and openclaw mcp add, and which side is the MCP server in each?
answer
- two directions
- client-side registry versus server
- the client spawns the bridge
- Gateway over WebSocket
- routed conversations become tools
basics
~20 sopenclaw mcp add saves a third-party MCP server under mcp.servers so OpenClaw's agents can use its tools. openclaw mcp serve makes OpenClaw itself a stdio MCP server that another client spawns to read and reply to its channel conversations.
solid answer
~40 sThey point in opposite directions. `openclaw mcp add` (with `list`, `set`, `configure`, `doctor`, `probe`) manages OpenClaw's client-side registry: it saves a third-party server under `mcp.servers` and OpenClaw's own runtimes connect to it. `openclaw mcp serve` makes OpenClaw the server: an external MCP client spawns it over stdio, the bridge connects to the Gateway over WebSocket, and routed channel conversations appear as tools such as `conversations_list`, `messages_read`, `events_wait` and `messages_send`. A remote Gateway is reached with `--url` plus `--token-file` or `--password-file`. The bridge only exposes conversations the Gateway can already route; `messages_send` replies through a stored route, and sender allowlists and pairing stay in the channel config.
go deeper
Recall the direction of each: add saves someone else's server for OpenClaw to use; serve turns OpenClaw into a server other clients use to reach its chats.
Explain how serve runs: the client spawns it over stdio, it connects to the Gateway over WebSocket, and routed sessions become conversation and message tools.
Discuss what a serve client can do, replying on stored routes and answering approvals, and why its Gateway credential should be handled like an operator's.
Decide whether coding agents should reach the assistant's conversations at all, and if so through serve with file-based credentials or not at all.
## Two jobs under one command `openclaw mcp` has two jobs, and they face opposite ways: | | `openclaw mcp add` (and `set`, `configure`, `doctor`, `probe`) | `openclaw mcp serve` | |---|---|---| | OpenClaw's role | MCP **client-side registry** | MCP **server** | | What it handles | Third-party servers under `mcp.servers` | OpenClaw's own channel conversations | | Who connects to whom | OpenClaw's runtimes connect to the saved server | An external MCP client spawns OpenClaw | | Transport | stdio, `sse` or `streamable-http` to the third party | stdio between the client and the bridge | | Typical use | Give agents a database or issue-tracker toolset | Let a coding agent read and answer chats | The registry commands read and write OpenClaw config; apart from the probe `add` runs before saving, `probe`, `doctor --probe` and `login`, they do not connect to the target server. Settings → MCP in the Control UI edits the same registry. ## How `openclaw mcp serve` works 1. The MCP client starts `openclaw mcp serve` as a stdio child process and owns it. 2. The bridge connects to an OpenClaw **Gateway over WebSocket**: the local one by default, `gateway.remote.url` when configured, or `--url` with `--token-file` or `--password-file`. 3. Gateway sessions that already have **route metadata** (channel, recipient, optional account and thread) appear as MCP conversations. 4. Live events queue in memory while the bridge is connected; when the client disconnects, the bridge exits and the queue is gone. The tools it exposes: - `conversations_list`, `conversation_get` to find conversations - `messages_read` for recent transcript history (default 20 messages, at most 200) - `attachments_fetch` for media metadata on one message - `events_poll` and `events_wait` for the live queue (`events_wait` defaults to 30 seconds, at most 300) - `messages_send` to reply, text only, through the session's stored route - `permissions_list_open` and `permissions_respond` for exec and plugin approval requests seen while connected, answered with `allow-once`, `allow-always` or `deny` `--claude-channel-mode` adds Claude-specific push notifications; its default `auto` behaves the same as `on`, and generic clients can rely on the polling tools instead. ## The trust boundary of the bridge The bridge does not invent routing: `messages_send` can only reply on a route the Gateway already stored, and **sender allowlists, pairing and channel-level trust stay in the channel configuration**. But the client holds a Gateway token or password and can answer approval requests, so treat it as an operator of that Gateway, protected by the same token or password controls as any remote Gateway client. Prefer the `--token-file` and `--password-file` forms over secrets on the command line. ## Telling them apart in practice - "My agent should search our issue tracker" is `openclaw mcp add`. - "My coding agent should read what people sent the assistant and reply" is `openclaw mcp serve`. - Neither re-exports the other: `serve` does not hand your `mcp.servers` tools to the outside client, and `add` does not expose your conversations. - When OpenClaw should host a coding harness session itself, the docs point to `openclaw acp` instead. ## The live event queue and its limits The bridge queues these event types while it is connected: `message`, `exec_approval_requested`, `exec_approval_resolved`, `plugin_approval_requested`, `plugin_approval_resolved` and `claude_permission_request`. - The queue starts when the bridge starts and is bounded; it never replays older Gateway history. - When a poll result carries `gap`, read durable history with `messages_read` and resume with `after_cursor` one below `gap.oldest_available_cursor`. - `permissions_list_open` only shows approvals observed while the bridge was connected; it is not an approval history. - There are no edit or react tools, and replies are text only. - Conversation discovery depends on route metadata the Gateway already holds. These limits are why a client that needs a complete record reads transcripts with `messages_read` instead of relying on events alone.
- A client connected through openclaw mcp serve misses messages that arrived before it started. Why, and how do you catch up?The event queue is live-only: it starts when the bridge connects, is held in memory and is bounded. `events_poll` and `events_wait` do not replay older history. Read durable history with `messages_read`; if a result carries `gap`, resume with `after_cursor` set to one less than `gap.oldest_available_cursor`.
- conversations_list returns nothing although the assistant has chats. Where do you look?Usually not at MCP configuration. The bridge only lists Gateway sessions that already carry route metadata: channel, recipient and optional account and thread. Confirm those sessions are routable in the Gateway; until they are, they cannot appear and `messages_send` has no route to reply on.
- openclaw mcp serve shares my mcp.servers tools with other MCP clients.
- openclaw mcp serve is a daemon listening on a network port.
- messages_send can message any phone number or user the client names.
- A client using openclaw mcp serve bypasses channel allowlists and pairing.
- openclaw mcp add makes OpenClaw available as a server to other tools.