OpenProgram Docs

MCP Apps

OpenProgram hosts the MCP Apps extension (io.modelcontextprotocol/ui, SEP-1865): a tool whose _meta.ui.resourceUri names a ui:// resource gets that HTML view drawn in its tool card in Web chat. The client side is in MCP client integration; the user page is MCP Apps.

From tool call to view

  1. Initializeclient advertises the extension
  2. Tool callmodel calls a tool with a view
  3. resources/readadapter fetches the view while the call runs
  4. Tool blockmcp_app as progress, then on the result
  5. Tool cardtwo sandboxed frames
  6. Call backtools, resources, messages, model context
StepWhere and how
CapabilityAppsClientSession (extensions/mcp/client.py) adds capabilities.extensions["io.modelcontextprotocol/ui"] = {"mimeTypes": ["text/html;profile=mcp-app"]} to initialize.
Tool listTools whose _meta.ui.visibility lacks "model" are not registered as Agent tools. ui:// resources are left out of list_resources and stay readable by URI.
FetchWhen a tool with a view is called, the adapter (extensions/mcp/adapter.py) reads the resource with app_view (extensions/mcp/apps.py) beside the call. If the view arrives first it goes out as a progress update, {server, tool, resource_uri, html, csp, prefers_border} on details["mcp_app"]; at the end with_result adds tool_result. HTML is capped at 2 MiB and the raw result at 512 KiB; a failed read leaves the plain result.
TransportWhile the call runs, event_parsing turns the progress update into a tool_view stream event, and stream_tap puts the view on the running tool block. At the end it rides the tool_execution_end event onto the live block and the call the turn tallies (turn_tally), so the reply's final write (turn_runtime/persistence.py) keeps it on the stored block; the transcript projection copies it onto the drawn block (one optional field, Block.mcp_app). A reload draws the view again.
CardMcpAppView replaces the step body; the card opens by default and folds like any step.
Bridgeapps/web/lib/chat/mcp-apps/bridge.ts speaks the spec's JSON-RPC: ui/initialize, then the tool input at once and the result (or tool-cancelled) when the call ends, then theme and width changes as host-context-changed.
Call backA view's tools/call goes to POST /api/mcp/apps/call and call_from_app; the answer returns to the view as the JSON-RPC result.
Resourcesresources/read goes to POST /api/mcp/apps/resource and read_for_app, always on the view's own server.
Messagesui/message text goes through the conversation's own send path (sendFromTranscript): sent now when idle, queued like the composer while a turn runs.
Model contextui/update-model-context goes to POST /api/mcp/apps/context. update_model_context stores the latest text per view on the session (runtime/conversation/view_context.py); the next turn takes it once as the view_context attachment of its turn context.

Decisions

DecisionChoiceBasis
Where the view sitsInside the tool card, sized to content, fallback 150 px, maximum 800 pxAntigravity draws an inline card with the same bounds; a view belongs to one call.
Advertising supportThe spec's client extension entryCodex advertises the same entry and reads _meta.ui.resourceUri; servers send views only to hosts that declare it.
Network policyDeny everything; add only the origins the resource declares in _meta.ui.cspZCode builds its policy from the declared origins (csp.ts); Antigravity's default is deny.
What a view may callTools of its own server marked "app" in visibility, 4 at a timeZCode limits calls to the owning server's app-visible tools; Antigravity scopes them to the server and allows 4 concurrent.
ApprovalThe conversation's existing permission decision. A call that needs asking opens a live wait on its own execution in the conversation's session, so the conversation shows the same approval card a turn shows and answers it through the same command; Auto mode asks too.ZCode sends app calls through its existing permission chain. Auto's reviewer judges a call against the turn that made it, and a view's call has no turn.
Showing while runningSend the view and the tool input as soon as the view is read; the result when it landsThe spec sends tool-input before tool-result; Antigravity mounts the view at the call.
MessagesThe ordinary send path, text blocks only, 32 KiB; one waiting message per viewZCode turns ui/message into a composer follow-up (pluginUiFollowUp.ts).
Model contextLatest text per tool call, redacted, 16 KiB, handed to the next turn onceZCode keeps one context per tool call with the same 16 KiB cap (pluginUiModelContext.ts).
Display modesInline onlyZCode's fullscreen is its own side pane, which would need a new layout here; Antigravity draws inline.
ui:// in resource listsHidden, still readableClaude Code skips ui:// resources in its lists and reads them by URI.
Terminal UINothing; the text result is shownCodex's TUI and the Antigravity CLI render nothing either.
Where the HTML loadsA server route, /mcp-app-frame, that relays to an inner srcdoc frameA srcdoc frame in the App page would inherit the App's script policy; the route sets the view's own policy as a header, like /visual-frame, and follows the spec's sandbox-proxy messages.

Security model

Two frames

FrameSettings
Proxy (/mcp-app-frame)sandbox="allow-scripts", referrerpolicy="no-referrer". No allow-same-origin, so it runs in an opaque origin though served by the App. Response headers: the view's CSP (with its own sandbox allow-scripts), Permissions-Policy denying camera, microphone, geolocation, display capture, payment, USB and clipboard, nosniff, no-referrer, no-store. The opaque-origin request carries no owner cookie, so owner auth lets this one GET through (owner_auth.MCP_APP_FRAME_PATH) without the App shell's headers: the page holds no data and the view arrives by postMessage.
View (inner srcdoc)sandbox="allow-scripts", created once on the first sandbox-resource-ready; inherits the proxy's CSP. No forms, pop-ups, top navigation, downloads or modals. If it navigates itself, the proxy removes it.

Content Security Policy

sandbox allow-scripts; default-src 'none';
script-src 'unsafe-inline' blob: data: <resourceDomains>;
style-src 'unsafe-inline' <resourceDomains>;
img-src / media-src data: blob: <resourceDomains>; font-src data: <resourceDomains>;
connect-src <connectDomains> | 'none'; frame-src <frameDomains> | 'none';
base-uri <baseUriDomains> | 'none'; worker-src blob:;
object-src 'none'; form-action 'none'; frame-ancestors 'self'
  • Declared origins must be https or wss with an optional *. prefix and port; http and ws only for localhost, 127.0.0.1 and [::1]. Anything else is dropped.
  • 'self' never appears, so a view cannot reach the App's API. frame-src 'none' also blocks the view from navigating its own frame to the App.

Message validation

CheckRule
SenderThe card accepts a message only when event.source is its own proxy window; the proxy relays only between its parent and its inner frame.
ShapeJSON-RPC 2.0 objects only; anything else is ignored.
OrderThe resource is sent once; requests before ui/initialize get -32002.
tools/callName must be a string and arguments an object (-32602); a fifth concurrent call is refused. The view names only the tool; the card adds the server from the payload.
resources/readThe URI must be a non-empty string (-32602); the server comes from the payload, and a failed read is -32603.
Messages and contextA message needs role user and text (-32602); while the view's last message still waits, the next gets isError. Context needs an array or object (-32602).
Other requestsui/open-link accepts http and https and opens with noopener; ui/request-display-mode always answers inline; size changes are clamped; every other method gets -32601.

Call-back checks

call_from_app refuses, in order:

  1. an unknown conversation (404 at the route)
  2. a server that is not connected
  3. a tool not on that server
  4. a tool without "app" visibility
  5. a deny verdict
  6. an ask or auto verdict the user declines, or leaves for 5 minutes

The verdict comes from permission_decision with the conversation's mode and merged rules, the same function model calls use; a session or always answer is saved as a rule the same way. A refusal returns an isError result naming the reason. read_for_app reads only from the view's server and refuses an empty or over-long URI and contents over 2 MiB.

Verified in Chrome

tests/support/mcp_apps/hostile.html, served by the fixture server with --hostile, tries each escape. In Chrome all fail:

  • localStorage, cookies, top.document and parent.document raise SecurityError; top navigation is refused.
  • fetch of another site and of /api/mcp/servers is blocked by connect-src.
  • Calls to filesystem__read_file and read_file are refused as not on the server; reads of file:///etc/hosts and filesystem://etc/hosts fail on the view's server; a direct top.postMessage gets no answer.

Tests

FileCovers
tests/unit/programs/mcp/test_mcp_apps.pyURI and visibility parsing, origin filtering, CSP, frame route headers, payload and caps, event and block transport, the view during the call, call-back gating, ask and auto outcomes, reads limited to the server, bounded redacted context taken once by the next turn
tests/integration/programs/test_mcp_apps.pyAgainst tests/support/mcp_apps/counter_server.py: capability negotiation, app-only tools unregistered, view payload, ui:// hidden but readable, a call and a read back, the view before a slow result, a real approval card answered through the wait command
tests/component/agent/turns/test_mcp_app_turn.pyA real turn that loads the deferred tool with tool_search and calls it inside a task step: the view on the live result, on the stored block beside the task stamps, and on the block a reload draws
apps/web/tests/chat/mcp-apps/bridge.test.mjsHandshake, call gating, malformed messages, concurrency, links, resources, messages and the queue, model context, result after a running start, unsupported methods, height clamping, context changes

Implementation status

ItemState
Inline views while running, tool input and result, theme, sizing, links, call back, resources, messages, model context, approvalImplemented in Web and desktop chat
Fullscreen and picture-in-pictureNot offered; the host always answers inline (see Decisions)
Partial tool inputThe view gets the whole input once the call starts, not argument deltas while the model writes it
View permissionsCamera, microphone and the like stay denied; _meta.ui.permissions is ignored
Terminal UIShows nothing

MCP client integration

Last updated · 2026-11-30