Repository navigation
fix: change saved MCP servers from the CLI without stopping the Gateway - #200582
Conversation
- openclaw mcp set/tools/unset, configure without --probe, and add without a probe route to the running Gateway via the config owner instead of refusing. - add's default probe and configure --probe keep load, probe, and save in one offline custody scope (Docker launches need it) and name --no-probe when the Gateway runs. - The Gateway clears credentials of replaced or removed OAuth servers on every accepted config change, including agent writes and hand edits; restarts clear nothing.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
- configure applies its flags to the server the write is bound to, so an edit that lands after the command reads config is kept, not overwritten. - Removing an emptied override checks it still matches what was read.
|
Codex review: blocked before merge. What this changesThis PR routes saved MCP server changes through the running Gateway and reconciles retired OAuth credentials when config changes are accepted. Example: Run
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it completes a useful, maintainer-approved CLI workflow while preserving Gateway-owned writes; no definite introduced code defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherMCP CLI commands prepare server definitions, the existing config-owner route sends changes to the Gateway, and config acceptance applies them and retires obsolete credentials. flowchart TD
A[MCP CLI] --> B[Config owner binding]
B --> C[Gateway config patch]
C --> D[Config acceptance]
D --> E[MCP runtime]
D --> F[OAuth credential cleanup]
A --> G[Offline probe custody]
Technical reviewBest possible solution: Use existing config-owner routing for unprobed saves and Gateway config acceptance for credential cleanup, while retaining offline probe custody. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically refuses saved-server CLI mutations under a running Gateway owner; no target code was executed during this review. Is this the best way to solve the issue? The change uses the existing config writer and credential lifecycle policy, preserves probe custody, and applies configure flags to the revision-bound definition without unnecessary new machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 176f2ff9652e. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +79, Tests +171, Docs +2. Total +252 across 9 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 17, 2026, 8:02 AM ET / 13:02 UTC. |
|
Maintainer override:
Exact-head proof: local ClawSweeper review |
|
Landed in 6e38d6d.
|
…ay (openclaw#200582) Related: openclaw#200538 ## What Problem This Solves `openclaw mcp add`, `set`, `unset`, `configure` and `tools` refuse to run while the Gateway is running and tell you to stop it first. That blocks an operator, or an agent with shell access, from adding an MCP server to a live Gateway, even though the same change through `openclaw config set` already works online. ## User Impact User impact: you can add or change saved MCP servers with `openclaw mcp …` while the Gateway runs; changes apply without a restart. Commands that probe a server first (`mcp add` by default for non-OAuth servers, and `mcp configure --probe`) still need the Gateway stopped, and now say so with the next step: save without probing (`--no-probe`). OAuth servers skip the probe, so `openclaw mcp add linear --url … --auth oauth` followed by `openclaw mcp login linear` works end to end on a running Gateway. With the Gateway stopped, every command behaves as before. Replacing or removing an OAuth server now clears its old saved sign-in no matter how the change was made: CLI, agent, Settings editor, or a hand edit of `openclaw.json`. Previously only the offline CLI did this, so an online change could leave a stale account attached to a new URL. A Gateway restart alone clears nothing. ## Why This Change Was Made The running Gateway is the one config writer. The MCP CLI prepares the same normalized change it would write offline and hands it to the Gateway with the existing config-owner binding, the path `openclaw config set` already uses. Probes are different: they launch the server (Docker launches need exclusive state custody) and can refresh credentials, so the probing path keeps loading, probing and saving inside one offline custody scope, as on main. Credential cleanup moves to the owner that sees every committed change: when the Gateway accepts a new source config, it compares the previous and next MCP servers and clears OAuth credentials for servers whose definition changed or disappeared, using the existing per-server lifecycle lease and the same rule the offline CLI already applied. The offline facade skips its own cleanup when a running Gateway owns config writes, so nothing is cleared twice. No schema, protocol, or config-option change. ## Evidence - **Online routing (process test with a real Gateway owner):** `mcp set`, `configure`, `tools`, `unset` and `add --no-probe` each go through the running Gateway and the Gateway stays up; `mcp add` with its default probe refuses with "Probing a server needs the Gateway stopped" and saves nothing. On main every one of these refuses. - **Credential cleanup (same harness):** an online URL replacement, a removal, and an in-process agent write each clear the stored OAuth credentials; an unchanged OAuth identity keeps them. On main the online cases keep stale credentials. - **Probe custody regression:** a probing `mcp add` runs its probe while holding state ownership, which is what Docker launches require. This is the defect the review caught in the earlier attempt (openclaw#200538). - Focused suites, typecheck, lint, line-cap and test-line ratchets pass; the full build with declarations and the packed Bun install smoke pass. <details><summary>Known local-only flake</summary> `src/cli/mcp-cli.test.ts` "requires initialize to finish within the configured probe timeout" fails on the development host under heavy load on unmodified main as well, and passes in CI. This PR does not change that path. </details> Co-authored-by: Ayaan Zaidi <[email protected]>
…ay (#200582) Related: #200538 `openclaw mcp add`, `set`, `unset`, `configure` and `tools` refuse to run while the Gateway is running and tell you to stop it first. That blocks an operator, or an agent with shell access, from adding an MCP server to a live Gateway, even though the same change through `openclaw config set` already works online. User impact: you can add or change saved MCP servers with `openclaw mcp …` while the Gateway runs; changes apply without a restart. Commands that probe a server first (`mcp add` by default for non-OAuth servers, and `mcp configure --probe`) still need the Gateway stopped, and now say so with the next step: save without probing (`--no-probe`). OAuth servers skip the probe, so `openclaw mcp add linear --url … --auth oauth` followed by `openclaw mcp login linear` works end to end on a running Gateway. With the Gateway stopped, every command behaves as before. Replacing or removing an OAuth server now clears its old saved sign-in no matter how the change was made: CLI, agent, Settings editor, or a hand edit of `openclaw.json`. Previously only the offline CLI did this, so an online change could leave a stale account attached to a new URL. A Gateway restart alone clears nothing. The running Gateway is the one config writer. The MCP CLI prepares the same normalized change it would write offline and hands it to the Gateway with the existing config-owner binding, the path `openclaw config set` already uses. Probes are different: they launch the server (Docker launches need exclusive state custody) and can refresh credentials, so the probing path keeps loading, probing and saving inside one offline custody scope, as on main. Credential cleanup moves to the owner that sees every committed change: when the Gateway accepts a new source config, it compares the previous and next MCP servers and clears OAuth credentials for servers whose definition changed or disappeared, using the existing per-server lifecycle lease and the same rule the offline CLI already applied. The offline facade skips its own cleanup when a running Gateway owns config writes, so nothing is cleared twice. No schema, protocol, or config-option change. - **Online routing (process test with a real Gateway owner):** `mcp set`, `configure`, `tools`, `unset` and `add --no-probe` each go through the running Gateway and the Gateway stays up; `mcp add` with its default probe refuses with "Probing a server needs the Gateway stopped" and saves nothing. On main every one of these refuses. - **Credential cleanup (same harness):** an online URL replacement, a removal, and an in-process agent write each clear the stored OAuth credentials; an unchanged OAuth identity keeps them. On main the online cases keep stale credentials. - **Probe custody regression:** a probing `mcp add` runs its probe while holding state ownership, which is what Docker launches require. This is the defect the review caught in the earlier attempt (#200538). - Focused suites, typecheck, lint, line-cap and test-line ratchets pass; the full build with declarations and the packed Bun install smoke pass. <details><summary>Known local-only flake</summary> `src/cli/mcp-cli.test.ts` "requires initialize to finish within the configured probe timeout" fails on the development host under heavy load on unmodified main as well, and passes in CI. This PR does not change that path. </details> Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 6e38d6d) Release adaptation: retain the release baseline inline MCP control helpers and OAuth registration; apply online routing and revision-bound configure callbacks without restoring the later extracted controls module. Companion #200538 is superseded by this complete fix. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 4038419d371c8d583a010a152b4b957b8931c66b)
Related: #200538
What Problem This Solves
openclaw mcp add,set,unset,configureandtoolsrefuse to run while the Gateway is running and tell you to stop it first. That blocks an operator, or an agent with shell access, from adding an MCP server to a live Gateway, even though the same change throughopenclaw config setalready works online.User Impact
User impact: you can add or change saved MCP servers with
openclaw mcp …while the Gateway runs; changes apply without a restart. Commands that probe a server first (mcp addby default for non-OAuth servers, andmcp configure --probe) still need the Gateway stopped, and now say so with the next step: save without probing (--no-probe). OAuth servers skip the probe, soopenclaw mcp add linear --url … --auth oauthfollowed byopenclaw mcp login linearworks end to end on a running Gateway. With the Gateway stopped, every command behaves as before.Replacing or removing an OAuth server now clears its old saved sign-in no matter how the change was made: CLI, agent, Settings editor, or a hand edit of
openclaw.json. Previously only the offline CLI did this, so an online change could leave a stale account attached to a new URL. A Gateway restart alone clears nothing.Why This Change Was Made
The running Gateway is the one config writer. The MCP CLI prepares the same normalized change it would write offline and hands it to the Gateway with the existing config-owner binding, the path
openclaw config setalready uses. Probes are different: they launch the server (Docker launches need exclusive state custody) and can refresh credentials, so the probing path keeps loading, probing and saving inside one offline custody scope, as on main.Credential cleanup moves to the owner that sees every committed change: when the Gateway accepts a new source config, it compares the previous and next MCP servers and clears OAuth credentials for servers whose definition changed or disappeared, using the existing per-server lifecycle lease and the same rule the offline CLI already applied. The offline facade skips its own cleanup when a running Gateway owns config writes, so nothing is cleared twice.
No schema, protocol, or config-option change.
Evidence
mcp set,configure,tools,unsetandadd --no-probeeach go through the running Gateway and the Gateway stays up;mcp addwith its default probe refuses with "Probing a server needs the Gateway stopped" and saves nothing. On main every one of these refuses.mcp addruns its probe while holding state ownership, which is what Docker launches require. This is the defect the review caught in the earlier attempt (fix: connect OAuth MCP servers from chat without stopping the Gateway #200538).Known local-only flake
src/cli/mcp-cli.test.ts"requires initialize to finish within the configured probe timeout" fails on the development host under heavy load on unmodified main as well, and passes in CI. This PR does not change that path.