Repository navigation
Conversation
Both MCP App entry points (model-created App tool calls and the standalone App runtime) passed only the projected tool name to resolveSessionResourceToolPolicy, dropping the trusted bundle-mcp ownership recorded at catalog materialization. Profiles that allow tools by plugin ownership, such as the coding profile's bundle-mcp entry, then rejected or hid tools they permit. Pass the projected tool's registered metadata at both call sites. Fixes openclaw#186775 Fixes openclaw#186777
|
🦞👀 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 maintainer review before merge. What this changesThis PR preserves trusted bundle MCP ownership when standalone and model-created MCP Apps evaluate session tool policy. Example: An MCP App calls notes__write_note with tools.profile set to coding.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a verified ownership-loss bug that remains on current main, with no actionable correctness or security findings; exact-head CI is still pending. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway MCP App handlers combine authenticated requester and session authority with catalog projections, apply shared tool policy and approvals, and dispatch permitted calls through the session-owned MCP transport. flowchart TD
A[Authenticated App request] --> B[Session and requester authority]
B --> C[Standalone or model-created App owner]
D[Trusted MCP catalog projection] --> C
C --> E[Shared session tool policy]
E --> F[Approval and live authority checks]
F --> G[Session MCP transport]
Technical reviewBest possible solution: Keep the existing shared policy owner and pass registered projection metadata through both App callers while preserving their live authority and approval checks. Do we have a high-confidence way to reproduce the issue? Current-main source exposes both missing-metadata paths, and the contributor's inspected live A/B trace demonstrates the corresponding rejection and repaired MCP effects; no target code was executed during this review. Is this the best way to solve the issue? This is the smallest complete production repair: retain the existing projected tool identity and supply its metadata to the existing evaluator at both callers, without inferring ownership or weakening explicit denials. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4f21b50f669a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests +10. Total +14 across 4 files. Added test files: 0. 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:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (5 earlier review cycles)
Reviewed November 3, 2026, 5:24 AM ET / 10:24 UTC (Revision 6). |
|
Added live proof for both App entry points: a real Gateway and a real stdio MCP server whose @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Review follow-up: the case only asserted field forwarding into a mocked policy. The real evaluator test and the live Gateway runs in the PR cover ownership-dependent admission.
|
Follow-up for the remaining items:
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…standalone owner Review follow-up: the cross-requester rejection and in-flight revocation case over a real streamable-HTTP MCP server now runs for both the model-created and the standalone (extension runtime) entry points.
|
Added the standalone cross-requester proof over a real transport ( On the standalone (extension runtime) owner, @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Merged No source change: the merged tree is this PR's own diff plus The merge applied without conflicts. |
|
🦞👀 Re-review progress:
|
|
Live reproduction on 2026.11.3, in case it helps this land. Setup: Control UI with trusted-proxy sign-in and a non-admin user (default role What fails, both as described in #186775 and #186777:
Workaround that confirms the cause: add the exact projected names ( An AI coding agent found and reproduced this on a local bench, with invented data. I'm happy to test a build of this PR. |
|
Thanks for the detailed repro. Your workaround is a clean confirmation of the cause: adding the exact Mapping your two symptoms to the code:
To test, either fetch the PR ref (if you have git fetch origin pull/186790/head:pr-186790
git checkout pr-186790
pnpm install
pnpm build # build:runtime is enough for the Gateway aloneor the branch itself: Same config as your report, what I would expect on this build:
If discover is still empty, the useful detail is whether the call returns One limit of the proof in the body: the live run used a single token operator, so the non-admin trusted-proxy profile path is not covered live. The streamable-HTTP transport is covered by a real-transport test with requester identities injected at the handler boundary, and the policy check runs before any MCP I/O, so transport should not matter here — but a real second profile is the leg I could not build on this rig. |
Fixes #186775
Fixes #186777
What Problem This Solves
Both MCP App entry points evaluate session tool policy with only the projected tool name:
prepareModelCreatedAppToolCallinsrc/gateway/mcp-app-operations.ts;assertToolinsrc/gateway/mcp-app-extension-runtime.ts, whose name-only map also drives catalog filtering.Catalog materialization records these tools as owned by
bundle-mcp(getPluginToolMeta). Policy entries that allow tools by plugin ownership, such as thecodingprofile'sbundle-mcpentry, only match when that ownership is supplied. Without it, an App tool the session's policy permits is rejected, or hidden from the App's available catalog. The MCP server name is not the plugin id, so it cannot stand in.User Impact
With
tools.profile: "coding"and no other overrides, MCP Apps can call and list their bundle MCP tools again, as the policy intends. Deny rules, per-server overrides andmcpToolsDenykeep applying exactly as before.Why This Change Was Made
resolveSessionResourceToolPolicyalready acceptstoolMetaand forwards it toisConversationToolAllowed()(#172678). Both callers now pass the projected tool's registered metadata:mcp-app-operations.ts:toolMeta: getPluginToolMeta(projected).mcp-app-extension-runtime.ts: the(serverName, toolName)map keeps the projected tool instead of only its name, and passestoolMeta: getPluginToolMeta(projectedTool)withtoolName: projectedTool.name.Ownership comes from the trusted catalog projection only. Nothing is inferred from names.
Evidence
Tests
src/gateway/session-resource-tool-policy.test.tshas a new case, "admits a coding-profile MCP App tool only with its bundle MCP ownership". It uses the real policy evaluator withtools.profile: "coding":demo_showis rejected without ownership and admitted with{ pluginId: "bundle-mcp" }. This shows the harm and the contract the callers must meet. The file passes 16/16.mcp-app-extension-runtime.test.tswas removed after review (cd68ff7). It only asserted field forwarding into a mocked policy. The behavioral regression evidence for both entry points is the live A/B below: main denies, this branch allows, undertools.profile: "coding".server-methods/mcp-app-extensions.test.ts,server-methods/mcp-app.view-grant.test.ts,agents/agent-bundle-mcp-materialize.identity.test.ts, plus the two files above.Checks run locally: oxfmt, oxlint, core
tsgoandgit diff --checkare clean.Live run: both App entry points, real Gateway and real MCP server (Windows 11, Node 26.12.1)
This is a real
openclaw gateway runwith a real stdio MCP server (notes), built on the repo's@modelcontextprotocol/server. The setup:mcp.apps.enabled: true.launcheris an MCP App (ui://notes/app). Its global quick action targetswrite_note.write_note(destructiveHint: false,openWorldHint: false) appends one line to a log for every call the server receives. That log is the final MCP effect, counted below as "writes".openclaw gateway callwith token auth.mcp.app.launchquick action →prepareMcpAppExtensionRuntime→resolveSessionResourceToolPolicy.notes__launcher, which creates a real App view. Thenmcp.app.callTool(write_note)runs on thatviewId→prepareModelCreatedAppToolCall.tools.toolSearch: falseis set so that the model sees the MCP tools directly.openclaw.jsonwas rewritten while the Gateway was running. The Gateway logged[reload] config source revision 4 accepted (file), and the same call was then repeated.a74f408db7f321bc3af402profile: codingcoding, thendeny: ["bundle-mcp"]hot-reloadedcoding+deny: ["bundle-mcp"]from startprofile: codingnotes__write_notecoding, thendeny: ["notes__write_note"]hot-reloadedcoding+deny: ["notes__write_note"]from startSo on both entry points this change only restores the documented plugin allowance under
tools.profile: coding. An explicit deny still prevents the MCP write, both from the start and after a live revocation. When a call is denied, no request reaches the MCP server.Standalone path: revocation while the call awaits approval
In this variant
write_notehas no read-only annotations, so the standalone call waits on a plugin approval. A persistent Gateway client withoperator.approvalsand theapprovalscap holds the pending approval and resolves it withallow-onceon cue.321bc3af402,tools.profile: coding)mcp.app.launchallow-oncenote writtendeny: ["bundle-mcp"]hot-reloaded while the approval is pending ([reload] config source revision 4 accepted), then approveSo revocation during the awaited preparation stops the standalone call before any MCP I/O, through the real standalone owner and the real stdio transport.
Requester isolation
These checks run outside the lines this PR changes. They pass on this branch, and together with
mcp-app-extension-runtime.test.tsandsession-resource-tool-policy.test.tsthe six files passed 127/127 at321bc3af402(the commit before the mock test was removed):server-methods/mcp-app.view-grant.test.ts: "does not reuse another requester's grant, including on an unbound shared view", "rechecks policy after approval and before a granted call executes", "revalidates a cached App grant after HTTP transport preparation before writing".server-methods/mcp-app.test.ts: "isolates requester-bound views, including read and write operations", "withholds resource read results when widget authority is revoked in flight".mcp-app-tool-approval.test.ts: "rejects requester revocation during review".mcp-app-standalone.test.ts: "does not downgrade requester-bound views into bearer-only standalone authority".Requester binding (
resolveMcpAppActiveView→requireRequester) runs before policy and is unchanged. On the model-created path, the execution-timeassertPolicyinprepareModelCreatedAppToolCallre-runsresolveSessionResourceToolPolicyright before the effect. It now passes the sametoolMeta, and it still re-checks livemcpToolsDeny, server overrides and the catalog policy snapshot. That re-check is why the hot-reloaded deny above blocks the second call on an already-open view.Standalone cross-requester rejection over a real transport (
mcp-app.view-grant.test.ts,c64d942). The existing real-transport case, "revalidates a cached App grant after HTTP transport preparation before writing", now runs for both entry points (it.for(["model-created", "extension-runtime"])). It uses the realcreateSessionMcpRuntimeagainst a real streamable-HTTP MCP server, and the handlers inject requester identitiesaliceandbobthroughauthenticatedUserProfile. For the standalone (extension runtime) owner, the checks run in this order:allow-always, and the cached grant executes. The server receives 2tools/call.mcpToolsDeny) while that call is paused in HTTP transport preparation (DNS). The call is rejected, the POST count stays the same, andtools/callstays at 2.Both variants pass, and the file passes 20/20.
Not covered live: a second requester profile on a real Gateway connection. Gateway user profiles attach only to device-authorized connections, and the live rig has a single token operator. The real-transport test above injects the two requester identities at the handler boundary instead.