Repository navigation
fix: openclaw mcp cannot authorize plugin-contributed MCP servers - #167090
xydigitLybnnnn wants to merge 4 commits into
Conversation
Read and OAuth `openclaw mcp` commands listed only `mcp.servers` from config, so MCP servers declared by enabled plugins (for example the official GitLab plugin's `gitlab` server) were invisible to the CLI and could not be authorized, even though agent runtimes already load them. Resolve the same effective server set as the runtime for `list`, `show`, `status`, `doctor`, `probe`, `login`, and `logout`: plugin declarations overlaid by `mcp.servers` overrides. Write commands keep operating on the config-only registry; disabled config entries stay visible so `status` and `doctor` can still report them.
|
🦞👀 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. |
|
Codex review: needs changes before merge. What this changesThe MCP CLI includes enabled plugins’ servers in read, diagnostic, and OAuth commands while keeping configuration writes separate. Example: An enabled GitLab plugin declares the OAuth MCP server gitlab.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains This PR fixes a real CLI discovery and authorization gap that remains on current main, but the previously reported Doctor preflight defect still blocks merge. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherPlugin manifests and operator configuration supply MCP server definitions; the CLI resolves them for inspection, transport probes, and OAuth credential management. flowchart LR
A[Enabled plugin manifests] --> C[Effective MCP inventory]
B[Operator configuration] --> C
C --> D[CLI inspection and Doctor]
C --> E[OAuth login]
E --> F[Credential store]
C --> G[MCP runtime probes]
F --> G
Technical reviewBest possible solution: Carry existing plugin data-directory ownership into Doctor’s static validation while preserving errors for missing operator-owned directories. Do we have a high-confidence way to reproduce the issue? Current-main source confirms the config-only CLI lookup, and the supplied before/after CLI trace demonstrates the reported failure; this read-only review executed no target code. Is this the best way to solve the issue? Resolving plugin declarations through existing inventory owners is appropriate, but Doctor must consume their launch-directory ownership before applying its existing cwd validation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f443e5272fa6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +121, Tests +81, Docs 0. Total +202 across 9 files. Added test files: 1. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label 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 HistoryReview history (4 earlier review cycles)
Reviewed October 13, 2026, 10:18 AM ET / 14:18 UTC (Revision 5). |
Review follow-up for the plugin-contributed MCP server fix: - Do not invent a working directory when the control plane deliberately resolves no workspace owner (multiple explicit agents, no system owner). Pass the omitted scope through so shared plugin inventory is used, as the existing workspace-resolution contract requires. - Probe and doctor runtimes no longer copy plugin-declared servers into `mcp.servers`, which relabelled them as operator-configured and dropped the plugin's `PLUGIN_DATA` launch-directory ownership. They now receive the resolved plugin inventory and scope the runtime with `includeServerNames`, so plugin stdio servers still get their launch directories prepared.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
The line-cap ratchet rejected src/cli/mcp-cli.ts growth (over-cap files may not gain lines). Move the plugin-aware effective-config loader and the probe/doctor runtime helpers into mcp-cli.plugin-servers.ts so the command module shrinks back below its inherited allowance; no behavior or coverage changes.
Resolve conflicts with upstream's mcp CLI refactor: keep the new offlineMcpAction state-owner wrappers and the extracted mcp-cli-oauth module, and adapt them to the plugin-aware effective server view so probe, doctor, login, and logout still reach plugin-contributed servers.
Closes #165951
What Problem This Solves
Fixes:
openclaw mcp login <name>fails with "No MCP server named ..." when the MCP server is contributed by an enabled plugin — for example the official@openclaw/gitlabplugin'sgitlabserver — instead of being saved undermcp.serversinopenclaw.json.User Impact
User impact: after installing a plugin that declares an MCP server,
openclaw mcp list,status,doctor, andprobenow show that server, andopenclaw mcp login <name>completes the OAuth flow the agent runtime already requires. Previously the server was invisible to the CLI even though the Control UI instructed the operator to run exactly that command.No breaking changes. Write commands (
add,set,configure,tools,unset) still read and write onlymcp.servers.Why This Change Was Made
Agent runtimes merge MCP servers from two sources: servers declared by enabled plugins, overlaid by the operator's
mcp.serversconfig. The CLI read onlymcp.servers, so plugin-declared servers were unreachable and could never be authorized.Read and OAuth commands (
list,show,status,doctor,probe,login,logout) now resolve the same effective set as the runtime — plugin declarations first, thenmcp.serversoverrides — while write commands keep operating on the config-only registry they own. Unlike the runtime merge, disabled config entries stay visible sostatusanddoctorcan still report them. Credentials keep using the existingoperatorMcpOAuthIdentity(name, url)key, so a CLI login is picked up by the runtime with no extra wiring.Review follow-ups (second commit)
resolvePluginControlPlaneWorkspaceintentionally returns an omitted scope. The CLI now preserves that omission instead of falling back toprocess.cwd(), so only shared plugin inventory is used, as the existing contract requires.loadEnabledBundleMcpConfig/loadEnabledBundleConfigaccept an omittedworkspaceDir.probeanddoctor --probeno longer copy plugin-declared servers intomcp.servers; doing so relabelled them as operator-configured and droppedprepareDataDirsByServer, so an Agent-bundle stdio server declaringcwd: "${PLUGIN_DATA}"failed to launch. They now receive the resolved plugin inventory and scope the runtime withincludeServerNames, so plugin stdio servers keep their launch-directory ownership.Docs updated to state the read/OAuth vs. write scope.
Evidence
Real behavior proof: shipped CLI, before vs. after
Both runs use the same fixture: a local, loopback-only OAuth 2.1 + MCP server (synthetic tokens and client id; no external endpoints) plus a temp
$HOMEcontaining one installed bundle plugin that declares{ "type": "http", "url": "http://127.0.0.1:8799/mcp", "auth": "oauth" }. The CLI is the shipped entry point (node scripts/run-node.mjs, the same onepnpm openclawruns).upstream/main@54bd6ecee18fd3b32c1ed0Before — the plugin server is invisible, so login is rejected:
After — discover, authorize, then reuse the credential from the runtime:
The authorization leg is a genuine loopback redirect: the fixture performs dynamic client registration, redirects to
http://127.0.0.1:8989/oauth/callbackwith an authorization code, and exchanges that code at its token endpoint. The finalprobeis the agent runtime's own MCP transport authenticating with the stored credential — it reaches the fixture and listsproof_echo, so credential reuse is demonstrated end to end rather than mocked.Checks
pnpm tsgo:core— pass.node scripts/run-oxlint.mjs --tsconfig tsconfig.core.json <changed files>— 0 warnings, 0 errors.oxfmt --checkandgit diff --check— clean.pnpm test src/cli/mcp-cli.plugin-servers.test.ts src/cli/mcp-cli.test.ts— the new regression test passes;mcp-cli.test.tsis 30 passed / 1 failed, and the single failure (requires initialize to finish within the configured probe timeout before saving) is a timing-sensitive test that also fails on a cleanupstream/maincheckout in this environment.Focused test output
AI involvement disclosure
Implemented by an AI agent with human direction and review. A human chose the approach (resolve the runtime's effective server set for read/OAuth commands rather than syncing plugin servers back into config) and reviewed the result; reproduction, coding, and verification were executed by the agent.
Rollback plan
Revert these commits. The change only alters how the CLI resolves and probes the MCP server set; no config, schema, or persisted state is migrated, so a revert restores the previous behavior immediately with no data cleanup.