Repository navigation
feat(mcp): allow an App's tool calls while its view stays open - #164496
Conversation
Keep requester-bound approvals for an exact MCP server/tool pair on the current App view lease. Retire grants with the view, retain current policy checks, and leave model-driven approvals and persistent allowlists unchanged. Render plugin decision labels in Control UI approval cards and document the in-memory scope. Prove both App call paths through the registered handler, real approval manager, broadcaster, and persistence boundary.
|
🦞👀 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. Reviewed October 3, 2026, 6:11 PM ET / 22:11 UTC (Revision 4). ClawSweeper reviewWhat this changesAdds temporary approval for repeated calls to one MCP server/tool from the same requester’s open App view, displays its scoped label, and preserves authority checks through HTTP preparation. Merge readiness✅ Ready for maintainer review This PR remains useful: current main lacks view-scoped approval, and the merged related work explicitly deferred it. No actionable introduced defect was found. Likely related people: steipete, with high-confidence routing from prior merged MCP Apps work. Priority: P2 Review scores
Verification
How this fits togetherMCP Apps are server-provided interactive views hosted by OpenClaw. Their tool requests pass through Gateway approval and session policy before reaching the managed or native MCP transport. flowchart TD
A[App tool request] --> B[Current requester and view]
B --> C[Server and session policy]
C --> D[View grant or approval prompt]
D --> E[Final authority check]
E --> F[MCP transport]
F --> G[Tool result]
B --> H[Lease retirement clears grants]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +70, Tests +769, Docs +8. Total +847 across 12 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep temporary approval owned by the current view lease, with exact requester/tool scope and live policy enforcement at transport dispatch. Do we have a high-confidence way to reproduce the issue? Not applicable as a new approval capability; current-main source confirms that App calls requiring approval receive only once/deny. Is this the best way to solve the issue? Yes. Reusing the view lease and existing approval contract avoids a competing permission store, while current policy remains authoritative before execution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6acc2539b3cb. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Carry the existing current-authority assertion through the guarded-fetch owner so asynchronous SDK and HTTP preparation cannot dispatch a revoked App tool call. Preserve the pre-SDK check and native writer admission. Prove grant reuse, requester rejection, and revocation during DNS preparation through the registered route and real managed HTTP transport. Move the unchanged method-not-found classifier to the existing MCP error owner to preserve the runtime module's line cap.
Finish board source preflight before holding the worker FIFO. Queue the revocation and destination read before the real widget write, preserve all authority assertions, and replace polling with explicit completion gates. The board-worker read migration made the old fixture deadlock before store admission. Reproduced all four CI failures on main, then verified the repaired fixture on both main and the PR branch. Use canonical agents.entries in the new App-grant fixture after the authored roster type retired agents.list.
|
Merged via squash.
|
…law#164496) * feat(mcp): allow an App's tool calls while its view stays open Keep requester-bound approvals for an exact MCP server/tool pair on the current App view lease. Retire grants with the view, retain current policy checks, and leave model-driven approvals and persistent allowlists unchanged. Render plugin decision labels in Control UI approval cards and document the in-memory scope. Prove both App call paths through the registered handler, real approval manager, broadcaster, and persistence boundary. * fix(mcp): retain App authority through HTTP preparation Carry the existing current-authority assertion through the guarded-fetch owner so asynchronous SDK and HTTP preparation cannot dispatch a revoked App tool call. Preserve the pre-SDK check and native writer admission. Prove grant reuse, requester rejection, and revocation during DNS preparation through the registered route and real managed HTTP transport. Move the unchanged method-not-found classifier to the existing MCP error owner to preserve the runtime module's line cap. * test(mcp): align App fixtures with current main contracts Finish board source preflight before holding the worker FIFO. Queue the revocation and destination read before the real widget write, preserve all authority assertions, and replace polling with explicit completion gates. The board-worker read migration made the old fixture deadlock before store admission. Reproduced all four CI failures on main, then verified the repaired fixture on both main and the PR branch. Use canonical agents.entries in the new App-grant fixture after the authored roster type retired agents.list.
Related: #164277
What Problem This Solves
Fixes: every App-initiated call of an app-only MCP tool prompts "Allow once?", so an App whose search box calls a tool per keystroke asks for approval on every keystroke. Changing the server-wide approval policy also affects model-driven calls.
User Impact
User impact: the approval card for an App-initiated tool call now offers Allow while this App is open next to Allow once and Deny. Choosing it lets the same requester call that exact server/tool pair again from the same App view without another prompt, for as long as the view's ten-minute lease lives. The grant is in memory only: it ends when the lease is released, expires, or is replaced; relaunching or reconstructing a view, a different tool, view, session, or requester all prompt again; model-driven calls and the persistent tool allowlist are unchanged. iOS shows the existing "Allow Always" label for the same scoped decision; macOS keeps plugin approvals review-only, so nothing changes there.
Why This Change Was Made
The grant rides the existing plugin-approval contract (a custom action label on the standard
allow-alwaysdecision) rather than new vocabulary, and the view lease that already owns the App's authority owns the grant, so there is no new store and nothing to persist. Server and session policy are still re-checked before execution, and entrypoint launches that happen before a view exists keep only once/deny.Evidence
mcp.app.callToolthrough the real handler and the plugin approval manager, both the model-created and the Codex extension-runtime paths): first call prompts and the grant applies; the second call of the same tool creates no approval; a different tool, a released or expired lease, and a new view prompt again;allow-oncestill consumes once; no config or allowlist write happens (persistence traced through the plugin-approval, standing-grant, and exec-approval-result owners).check-changed, matched-base startup check pass; Codex autoreview at P1 found no actionable findings.Measured local cost:
node scripts/run-vitest.mjs src/gateway/server-methods/mcp-app.view-grant.test.ts --maxWorkers=1took 144.40s wall (including 51.23s worker preparation); its 18 real-route cases passed.node scripts/run-vitest.mjs ui/src/components/exec-approval-card.test.ts --maxWorkers=1took 4.86s wall, all 18 passed. Baseline proof failed in the 12 grant-dependent route cases and three mounted-label cases. After the transport follow-up, the full 19-case route file took 25.49s wall; the new real-HTTP case took 90ms. CI timings will follow the attached run.Existing limitations: calls before a view exists remain once/deny;
autoretains its risk-based policy. The standalone approval page retains its generic label. No native code changes.Final tool-I/O authority proof
ClawSweeper’s proof request exposed a managed HTTP race: the pre-SDK assertion did not cover awaited request preparation. The follow-up carries the existing assertion through the shared guarded-fetch authority owner, which checks immediately before every physical fetch. No new policy or store was added. The existing method-not-found classifier moved unchanged to the MCP error owner to keep the runtime module below its existing growth ratchet.
The registered-route regression now uses the real managed runtime and MCP SDK HTTP client/server. Approved calls and cached-grant reuse execute successfully; another requester emits no HTTP POST. When current tool policy is revoked while DNS preparation is paused, the original code sends an extra POST (8 instead of 7), while the fixed path sends none and denies the call. The session row is a controlled fixture; the production App policy assertion enforces its updated tool denial. No mocked runtime forwards that assertion.
Additional focused proof passed 115 tests across seven files, including the native adapter’s actual writer/retry authority matrix and request timing/preparation tests. Native revocation during overload backoff prevents a second request frame; revoked/expired authority during awaited preparation prevents a late first write.
One existing stdio retirement case hit its unchanged 8,000ms local deadline during a later sibling run (63 other runtime tests passed). The sole same-file/order replay passed 64/64; the case took 1,837ms. Its 1,000ms replacement-process startup deadline is a plausible timing sensitivity on the loaded host, but the stalled phase was not captured. This is recorded as an unresolved local timing failure, not a claimed flake fix; no timeout or assertion was weakened.
CI fixture repair
CI run 37152392846 failed four board admission cases inherited from main’s board-read migration in 9e32882. The exact two-file order passed 47/47 on the PR’s older base but reproduced the same four failures on main 120b436: the fixture held the writer FIFO before the source-authority read could finish.
The repaired fixture finishes real preflight first, then holds the writer and queues revocation, an ordered destination read, and the real pin write. It preserves all absence, grant, declaration, tool-effect, cancellation, and retirement assertions. The same bytes pass 47/47 on main; the branch’s MCP/board/view-grant sequence passes 66/66. The standalone four-case board file took 51.93s wall on the loaded main proof checkout. No production FIFO rule or timeout changed. The new view-grant fixture also uses canonical agents.entries to match main’s authored roster type.
CI run 37155566161 inherited the
checks-ui-e2e-real-gateway (1/2)failure inui/src/e2e/mcp-app-conformance.e2e.test.tsintroduced on main by #164493; this branch now merges the main fix from #164555 (6ef76750ed00f, including the related dashboard layout repair11515ce5b3da) so the next run uses a fresh merge ref instead of rerunning the stale one.After merging main at head
276cdbb5ef874, the requested four-file focused run passed 107/107 tests in 95.61s wall (--maxWorkers=1): the registered view-grant route, approval helper, mounted approval card, and MCP runtime;pnpm format:checkandgit diff --checkalso passed.Before/after (synthetic mounted-component fixture with the same proposed three-decision payload; the original server offered only once/deny):