Skip to content

feat(mcp): allow an App's tool calls while its view stays open - #164496

Merged
steipete merged 4 commits into
mainfrom
steipete/mcp-app-view-grant
Oct 3, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/mcp-app-view-grant

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

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-always decision) 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

  • Registered-route regressions (mcp.app.callTool through 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-once still consumes once; no config or allowlist write happens (persistence traced through the plugin-approval, standing-grant, and exec-approval-result owners).
  • 212 focused tests green; format, diff-check, type-aware lint, tsgo lanes, Knip, madge, full 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=1 took 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=1 took 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; auto retains 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 in ui/src/e2e/mcp-app-conformance.e2e.test.ts introduced on main by #164493; this branch now merges the main fix from #164555 (6ef76750ed00f, including the related dashboard layout repair 11515ce5b3da) 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:check and git diff --check also passed.

Before/after (synthetic mounted-component fixture with the same proposed three-decision payload; the original server offered only once/deny):

Before After
before after

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.
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 6:11 PM ET / 22:11 UTC (Revision 4).

ClawSweeper review

What this changes

Adds 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
Reviewed head: 276cdbb5ef87464df860be82d590300b954a4ee9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with strong final-I/O authority evidence and no remaining actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The recorded registered-route scenario exercises the production managed runtime with real MCP SDK HTTP transport: approved calls and cached reuse succeed, another requester emits no POST, and revocation during DNS preparation prevents dispatch. Native writer/retry evidence covers stale authority before request frames. Inspected screenshots separately show the scoped label. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The recorded registered-route scenario exercises the production managed runtime with real MCP SDK HTTP transport: approved calls and cached reuse succeed, another requester emits no POST, and revocation during DNS preparation prevents dispatch. Native writer/retry evidence covers stale authority before request frames. Inspected screenshots separately show the scoped label. No stored-data contract changes.
Evidence reviewed 10 items Pinned change and review continuity: Reviewed the introduced delta from the pinned base to the exact original head. A targeted comparison against the previous reviewed head showed no changes to the approval, operation, extension-runtime, managed-runtime, or view-grant proof files. The stale test merge was not used to infer removal of main behavior.
Still necessary on current main: Current main offers only allow-once and deny and consumes approval for each call. The supplied merged #164277 explicitly deferred per-view grants; the other related merged PRs address message confirmations and their conformance fixture. No supplied merged replacement implements this capability.
Grant ownership and persistence: The grant lookup uses requester identity and an exact server/tool key on the current lease. Lease deletion clears grants; preparation rechecks current policy. Approval payloads omit mcpTool and standing-grant scope, so the existing persistence owner does not mint a durable tool grant. No stored-data schema or configuration contract changes.
Findings None None.
Security None None.

How this fits together

MCP 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +70, Tests +769, Docs +8. Total +847 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 8 107 37 +70
Tests 3 789 20 +769
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 904 57 +847

Review metrics

Metric Value Why it matters
Production versus test growth production +70 net lines; tests +769 net lines Production growth supports lease-owned grants and final dispatch checks; most added coverage exercises approval scope and authority boundaries.
Configuration and storage surface 0 new config options; 0 schema changes The capability reuses the existing approval decision contract and stores grants only in the current in-memory lease.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This improves repeated App interactions without evidence of an urgent core outage or regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The recorded registered-route scenario exercises the production managed runtime with real MCP SDK HTTP transport: approved calls and cached reuse succeed, another requester emits no POST, and revocation during DNS preparation prevents dispatch. Native writer/retry evidence covers stale authority before request frames. Inspected screenshots separately show the scoped label. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The recorded registered-route scenario exercises the production managed runtime with real MCP SDK HTTP transport: approved calls and cached reuse succeed, another requester emits no POST, and revocation during DNS preparation prevents dispatch. Native writer/retry evidence covers stale authority before request frames. Inspected screenshots separately show the scoped label. No stored-data contract changes.

Evidence

What I checked:

  • Pinned change and review continuity: Reviewed the introduced delta from the pinned base to the exact original head. A targeted comparison against the previous reviewed head showed no changes to the approval, operation, extension-runtime, managed-runtime, or view-grant proof files. The stale test merge was not used to infer removal of main behavior. (276cdbb5ef87)
  • Still necessary on current main: Current main offers only allow-once and deny and consumes approval for each call. The supplied merged fix(mcp): keep app forms, file updates and context in sync after live testing #164277 explicitly deferred per-view grants; the other related merged PRs address message confirmations and their conformance fixture. No supplied merged replacement implements this capability. (src/gateway/mcp-app-tool-approval.ts:60, 6acc2539b3cb)
  • Grant ownership and persistence: The grant lookup uses requester identity and an exact server/tool key on the current lease. Lease deletion clears grants; preparation rechecks current policy. Approval payloads omit mcpTool and standing-grant scope, so the existing persistence owner does not mint a durable tool grant. No stored-data schema or configuration contract changes. (src/gateway/mcp-app-tool-approval.ts:28, 276cdbb5ef87)
  • Final-effect authority proof: The captured PR body reports successful real managed-runtime and MCP SDK HTTP execution, cached reuse, zero POSTs for another requester, and zero additional POSTs after policy revocation during paused DNS preparation; the original path emitted an additional POST. Inspection confirms the registered-route scenario uses the production runtime and real HTTP client/server, with controlled session facts and injected DNS timing. Native adapter proof separately exercises actual client writes and denies retries after revocation. These observations were contributor-recorded; this read-only review did not execute tests. (src/gateway/server-methods/mcp-app.view-grant.test.ts:547, 276cdbb5ef87)
  • Physical HTTP dispatch fence: Managed tool execution carries the prepared assertion through the existing guarded-fetch authority owner. The fetch guard invokes it after awaited preparation and immediately before physical request dispatch; the native adapter passes the same assertion to its request writer and retry boundary. (src/agents/agent-bundle-mcp-runtime.ts:971, 276cdbb5ef87)
  • Inspected visual evidence: Inspected both prepared screenshots linked in the captured body: the synthetic mounted fixture changes the generic Always allow label to Allow while this App is open. The images prove the visible label only; authority sufficiency rests on the final-I/O scenario above. (ui/src/components/exec-approval-card.ts:210, 276cdbb5ef87)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-03T19:51:31.731Z sha acd6596 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-03T20:47:33.292Z sha 576ba6b :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T21:41:10.932Z sha 3f6be2e :: needs maintainer review before merge. :: none

@steipete steipete self-assigned this Oct 3, 2026
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.
@steipete
steipete marked this pull request as ready for review October 3, 2026 20:40
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Oct 3, 2026
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.
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Oct 3, 2026
@steipete
steipete merged commit 695fdbf into main Oct 3, 2026
126 of 128 checks passed
@steipete
steipete deleted the steipete/mcp-app-view-grant branch October 3, 2026 22:19
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant