Skip to content

feat(ui): complete Control UI MCP App bridge - #109807

Merged
fuller-stack-dev merged 28 commits into
mainfrom
codex/control-ui-mcp-app-bridge
Jul 18, 2026
Merged

fuller-stack-dev merged 28 commits into
mainfrom
codex/control-ui-mcp-app-bridge

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Jul 17, 2026 •

Copy link
Copy Markdown
Member

AI-assisted: yes (Codex). I understand the implementation and completed fresh autoreview passes with no accepted/actionable findings. No agent transcript is included because separate approval was not provided.

Summary

  • Complete the existing Control UI MCP App host bridge with safe, text-only ui/message support routed through the normal visible chat-send path.
  • Advertise messaging only for fresh, authorized app views; reconstructed views remain explicitly read-only.
  • Propagate live theme and iframe dimensions through the official MCP Apps host-context bridge without remounting, with observer/listener cleanup on teardown.

What Problem This Solves

The Control UI could render MCP App resources and service app tool/resource requests, but an app could not safely ask the user to send plain text through the host chat, and mounted apps did not receive live theme or size changes.

Why This Change Was Made

This extends the already-present iframe/resource reconstruction architecture. It reuses the existing widget-prompt validation and WIDGET_PROMPT_EVENT send seam, adds host-owned exact-text confirmation for MCP App requests, and uses the official AppBridge.setHostContext lifecycle. It does not add a second send route, config/env surface, protocol version, or privileged approval path.

The implementation adds a small explicit readOnly lease marker because a fresh app may legitimately have zero app-callable tools, while a transcript-reconstructed preview must remain resource-only. Tool-count inference could not represent both states safely.

User Impact

When MCP Apps are already enabled, a visible and focused fresh app can request that the user send one plain-text message. The host shows the exact text for confirmation, then sends through the existing chat composer path. Hidden/background frames, empty or oversized text, slash commands, and rate-limit excesses are rejected. Apps also receive current theme and dimensions as they change.

Independent landing and backward safety

  • The gateway response field is additive. Older Control UIs ignore it; a newer UI talking to an older gateway sees the field absent and installs/advertises no message handler.
  • Existing widget prompts use the same extracted validation/send helper without the MCP App confirmation callback; their existing behavior is covered by the widget-prompt and tool-card regression suites.
  • App tool/resource handlers, app-only policy, sandbox origins, inner opaque iframe isolation, routes, config, and protocol versions are unchanged.
  • Fresh views with an explicit authority set may advertise messaging even when that set is empty. Legacy views without authority and reconstructed readOnly views fail closed.
  • No behavior enabled by this PR requires a later MCP Apps PR.

Exact dormant/additive boundary: all behavior remains behind the existing mcp.apps.enabled gate. Within that gate, message.text is advertised only when a fresh view has explicit current-run authority and the host handler is installed. Reconstructed views can still render/read resources but cannot message or call tools. Rich or multi-block ui/message content is intentionally unsupported.

Evidence

  • Genuine browser flow: a browser-bundled App from @modelcontextprotocol/ext-apps ran through the real Control UI Vite app, dedicated sandbox HTTP server, and nested iframe bridge. The official initialize handshake advertised message.text; exact host consent was required; accepted text produced the normal chat.send request (deliver: false); the app received its response; live light-theme and container-dimension changes propagated without remounting.
  • Focused exact-head proof: 89/89 assertions passed across MCP view leases, transcript reconstruction, gateway authorization, text/focus/visibility/size/rate/slash boundaries, existing widget prompts, host-context updates, and cleanup.
  • Production build passed, including the Control UI lazy chunk (mcp-app-view-registration, 63.26 kB) and Control UI performance limits.
  • Changed-surface checks passed through formatting, duplicate coverage, dependency pins, and related policy gates. An earlier Plugin SDK baseline mismatch was independently reproduced on untouched canonical main; the current canonical base includes its unrelated generated/declaration repairs.
  • A first CI run exposed a production lint suppression for the SDK's request-style onmessage setter. The handler now registers through that documented public setter via a typed wrapper, without a suppression or private schema import; the component and suppression-ratchet tests pass, followed by two clean fresh autoreviews.
  • Two fresh autoreviews after the final safety fixes reported no actionable findings (confidence 0.98 and 0.94). Canonical-base updates preserved the exact nine-file product diff.

Verification

  • pnpm test src/agents/mcp-ui-resource.test.ts src/gateway/mcp-app-reconstruction.test.ts src/gateway/server-methods/mcp-app.test.ts ui/src/components/mcp-app-security.test.ts ui/src/components/mcp-app-view.test.ts ui/src/pages/chat/components/chat-tool-cards.node.test.ts ui/src/pages/chat/components/chat-tool-cards.test.ts ui/src/pages/chat/components/chat-tool-cards.widget-prompts.test.ts
  • Exact-head pnpm tsgo:prod and pnpm lint
  • pnpm build
  • Fresh $autoreview passes before and after simplification/final safety edits

Simplification and scope

The PR changes five production files and four focused test files. Net production growth is +60 LOC: the message handler/host-context lifecycle and explicit read-only authority marker are offset by deleting the duplicated widget-prompt policy/send implementation. No additional abstraction module, route, config, or compatibility shim was added.

Known gaps

  • This does not enable MCP Apps globally or implement later rollout work.
  • Only one plain text content block is accepted; rich content remains rejected.
  • Transcript-reconstructed previews intentionally remain read-only until a fresh run grants current authority.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Jul 17, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Jul 17, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 18, 2026, 1:18 AM ET / 05:18 UTC.

Summary
The PR extends the Control UI MCP App bridge with consent-gated plain-text ui/message requests, live host-context updates, and explicit read-only reconstruction leases.

PR surface: Source +60, Tests +257. Total +317 across 9 files.

Reproducibility: yes. from source: submit a focused, visible MCP App message.text request with bang-prefixed text and accept the exact-text confirmation; the current resolver rejects / but not ! before the normal chat-send path.

Review metrics: 1 noteworthy metric.

  • Command-prefix coverage: 1 blocked (/), 1 unblocked (!). The new sandbox-to-chat send boundary must reject every command syntax interpreted by the existing composer, not only slash commands.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🌊 off-meta tidepool
Patch quality: 🦐 gold shrimp
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Reject bang-prefixed input in the shared resolver and add a focused regression test.
  • Provide refreshed redacted browser or terminal proof showing the MCP App request is rejected before chat dispatch.

Mantis proof suggestion
A redacted Control UI chat transcript can materially verify that accepted plain text dispatches normally and command-like MCP App text is rejected before delivery. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: verify that a focused MCP App can send confirmed plain text but that both / and ! command-like message requests are rejected before chat delivery.

Risk before merge

  • [P1] Merging with only / rejected can allow a confirmed sandboxed MCP App request to reach host-only ! command handling through the regular chat-send path.
  • [P1] The PR changes an MCP App-to-host authority boundary; maintainers need to confirm whether all command syntaxes must be rejected or whether any bang command is intentionally safe for sandbox-originated text.

Maintainer options:

  1. Close the bang-command gap (recommended)
    Extend the shared resolver to reject ! command text, add a regression test through the MCP App message handler, and refresh real browser proof without sensitive details.
  2. Define an explicit command contract
    Pause for an owner-approved allowlist and tests if any bang command is intentionally permitted from a sandboxed app.
  3. Defer host messaging
    Keep the existing read-only/resource bridge and remove the new message capability if command authority cannot be bounded clearly.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Reject bang-prefixed MCP App message text before consent/dispatch; add focused MCP App and existing widget-prompt regression coverage, then provide redacted browser or terminal evidence that the command is rejected.

Next step before merge

  • [P2] A one-line code repair is clear, but the protected maintainer label and the permanent sandbox-to-chat command-authority contract require an explicit owner decision before merge.

Maintainer decision needed

  • Question: Should sandboxed MCP App ui/message requests be categorically unable to invoke both slash and bang command syntax through the chat-send path?
  • Rationale: The implementation currently blocks slash commands but not the previously identified host-only bang-command path; choosing an exception would define a durable command-authority contract rather than a mechanical bug fix.
  • Likely owner: fuller-stack-dev — They own the proposed bridge behavior and described its intended command-safety contract in the PR.
  • Options:
    • Reject all command prefixes (recommended): Reject both / and ! before showing consent or dispatching text, preserving the PR's stated plain-text-only boundary.
    • Allow a defined bang subset: Document and test an explicit safe allowlist only if maintainers intentionally want MCP Apps to reach specific bang commands.

Security
Needs attention: The consent flow is a useful safeguard, but the new sandbox-to-host text bridge has an incomplete command filter that can reach bang-command handling.

Review findings

  • [P1] Reject bang commands before dispatch — ui/src/components/mcp-app-security.ts:22
Review details

Best possible solution:

Treat MCP App ui/message as plain conversational text only: reject every host command prefix, including !, before confirmation and dispatch, then retain the existing consent, focus, visibility, size, and rate-limit checks.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: submit a focused, visible MCP App message.text request with bang-prefixed text and accept the exact-text confirmation; the current resolver rejects / but not ! before the normal chat-send path.

Is this the best way to solve the issue?

No. The PR correctly reuses the existing prompt-send seam, but plain-text-only enforcement is incomplete until it rejects bang-command syntax as well as slash commands.

Full review comments:

  • [P1] Reject bang commands before dispatch — ui/src/components/mcp-app-security.ts:22
    The resolver only rejects text beginning with /, but this text is later sent through the normal chat path, where host-only ! commands are also interpreted. A sandboxed MCP App can therefore get a user to confirm a bang command that bypasses the intended plain-text-only boundary. Reject ! here as well and cover it through the MCP App handler; this is the prior P1 blocker still present on the current head.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 330f36fb32ea.

Label changes

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: The PR can expose host command execution semantics through a user-facing MCP App path when the feature is enabled.
  • merge-risk: 🚨 security-boundary: A sandboxed iframe gains a consent-mediated path into the host chat dispatcher, and the command filter is incomplete.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless describes a real browser-flow run, but the remaining blocker is source-visible command filtering rather than missing proof.
Evidence reviewed

PR surface:

Source +60, Tests +257. Total +317 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 6 152 92 +60
Tests 3 264 7 +257
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 416 99 +317

Security concerns:

  • [high] Sandboxed app text can reach bang commands — ui/src/components/mcp-app-security.ts:22
    The new MCP App message handler relies on resolveWidgetPromptText, which blocks slash syntax but leaves bang-prefixed command text eligible for the host chat dispatcher after consent.
    Confidence: 0.98

What I checked:

  • Current command filter: The shared prompt resolver rejects text beginning with / but does not reject !, leaving a second command prefix eligible for the normal chat-send dispatch after an MCP App request is confirmed. (ui/src/components/mcp-app-security.ts:22, 3a3ad613cd7e)
  • Prior review continuity: The immediately preceding ClawSweeper review identified the same P1 bang-command problem at ff000ef; subsequent commits listed in the PR context are main-merge commits, and the current patch still shows only the slash-prefix rejection. (ui/src/components/mcp-app-security.ts:22, ff000ef7d02c)
  • Host authority boundary: The MCP App view installs a message.text handler that dispatches validated text into the existing widget/chat prompt path, so input validation is the boundary preventing an untrusted app from invoking host command syntax. (ui/src/components/mcp-app-view.ts:1, 3a3ad613cd7e)
  • Gateway capability gate: The additive messageSupported response correctly limits this host capability to fresh, non-read-only views; it does not constrain command syntax after a message is accepted. (src/gateway/server-methods/mcp-app.ts:171, 3a3ad613cd7e)

Likely related people:

  • fuller-stack-dev: They authored the current MCP App bridge branch, supplied the intended consent and command-safety rationale, and are assigned on the PR. (role: current feature author and assigned decision participant; confidence: medium; commits: 1e32a39004b8, 3a3ad613cd7e; files: ui/src/components/mcp-app-security.ts, ui/src/components/mcp-app-view.ts, src/gateway/server-methods/mcp-app.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-17T08:54:18.969Z sha 715289b :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T09:49:57.958Z sha d747e17 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T10:05:42.471Z sha 967520a :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T10:16:10.063Z sha 562fde0 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T10:33:33.816Z sha 6679969 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T10:48:23.155Z sha 0bd5334 :: found issues before merge. :: [P1] Reject host-only bang commands before dispatch
  • reviewed 2026-07-17T11:29:48.715Z sha 0bd5334 :: found issues before merge. :: [P1] Reject bang commands before dispatch
  • reviewed 2026-07-18T04:42:25.416Z sha ff000ef :: found issues before merge. :: [P1] Reject bang commands before dispatch

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 17, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. P1 High-priority user-facing bug, regression, or broken workflow. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. P2 Normal backlog priority with limited blast radius. labels Jul 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 923d92b into main Jul 18, 2026
124 of 126 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the codex/control-ui-mcp-app-bridge branch July 18, 2026 05:21
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
* feat(ui): complete MCP App message bridge

* fix(ui): gate reconstructed MCP App messaging

* fix(ui): register MCP message handler without suppression

* fix(ui): use public MCP Apps message schema export

* chore: realign PR branch with canonical main

* fix(ui): register MCP messages through public bridge API
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* feat(ui): complete MCP App message bridge

* fix(ui): gate reconstructed MCP App messaging

* fix(ui): register MCP message handler without suppression

* fix(ui): use public MCP Apps message schema export

* chore: realign PR branch with canonical main

* fix(ui): register MCP messages through public bridge API
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 feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant