Reading and surfaces

MCP Apps view

@culmjs/surface/mcp-apps serves a surface as a view under MCP Apps (SEP-1865, "Stable (2026-01-26)"). The view is minimal: it draws patches and reports what the person does, and nothing else.

Export

What it is

Export

mcpAppsResource({ origin })

What it is

The UI resource: uri ui://culm/surface⁠, mimeType text/html;profile=mcp-app⁠, the frame document as text⁠, and _meta.ui.csp.resourceDomains: [origin]⁠. origin is where the surface's images and fonts load from (an https host, an optional port, and at most one leading *. before two or more labels; https://*⁠, https://*.com and values with ;⁠, , or spaces throw a TypeError⁠): without it the host's default policy allows images only from the frame itself and data:

Export

mcpAppsActionTool()

What it is

The one tool the view calls, with an input schema of one SurfaceEvent and _meta.ui.visibility: ['app']⁠, so the host keeps it out of the model's tool list

Export

MCP_APPS_ACTION_TOOL

What it is

Its name, culm_surface_event

What the view does:

  • It opens with ui/initialize (with appInfo⁠), then sends ui/notifications/initialized⁠, then ui/notifications/size-changed whenever its size changes.

  • It draws the patch in structuredContent of a ui/notifications/tool-result⁠, and of the result of its own tools/call⁠.

  • Every press, submit and link leaves as tools/call of the action tool, { event }⁠. An action name is never a tool name, and a link is never ui/open-link⁠. The product's server answers the call, and the patch in its result's structuredContent is drawn. The server must check the event argument itself, every value in it: a host may not enforce the tool's inputSchema⁠, and the view reports what the person did and trusts none of it.

  • It answers ping⁠, and ui/resource-teardown⁠, which also empties the view. Any other host request gets the error -32601⁠.

What the view does not do:

  • No live streaming from the host's model. The spec sends one tool-result per completed tool call, and partial tool input is best-effort, which a view must not rely on. The view does not handle tool-input⁠, tool-input-partial or tool-cancelled⁠.

  • No theme or display mode: host-context-changed is not handled.

  • No recovery from a missed patch. The view draws each patch on arrival and ignores the mount's false⁠, so the product sends full state: return surface.snapshot() as structuredContent of every result the view draws. A snapshot has from: 0⁠, so the mount always applies it, and ignores an older one from the same surface. A patch the mount refuses throws inside the view and is logged in the frame's console; the host is not told.

  • A failed tools/call is silent: the view drops an error answer, and the person sees nothing change.

  • Forms need allow-forms⁠. A host must grant allow-forms to the view frame and to the sandbox proxy frame for a form submit to reach the product: a nested frame keeps the restrictions of the frame around it. The reference host grants it to both. A press and a link do not need it.

A button outside a form is drawn without a border or padding: the base style gives only a form's own submit button a button look, so a product styles other buttons with setStyle⁠.

The view draws each patch as it arrives, with no frame drain. A browser does not paint a hidden frame, so a view the person cannot see shows its last state when it is shown.

A later path, not built: the view could poll an app-only tool for the next patches, to follow a stream while the model is still writing.

The view's exit test runs against the AppBridge of @modelcontextprotocol/ext-apps 2.0.4 in Chromium, with a test proxy frame:

packages/surface/__browser__/mcpApps.spec.ts

. No real host was tested.

Not built

  • Layout checks at run time (the owner's ruling 3). The comparison harness runs them through the browser instead.

  • A pending style for empty content (ruling 9): an empty column or text already matches :empty⁠.

  • An A2UI adapter (ruling 4). The mapping is recorded in the Stage 9 exit record.

Not tested

  • Safari and Firefox. The browser tests drive Chromium only.

  • A real MCP Apps host, and a host's own proxy frame.

  • A model's output: the tests use recorded streams written by hand.

  • A model writing the outline spelling: its tests use outlines encoded from recorded JSON lines.

Edit this page on GitHub