MCP Apps in the task window: design
Status: phase 1 (read-only viewer) is built behind CULLY_MCP_APPS=1; phases 2 to 5 are design only. Date: 2026-11-27.
What MCP Apps are
MCP Apps is an official extension (SEP-1865, id io.modelcontextprotocol/ui, spec dated 2026-01-26, marked stable; the flat ui/resourceUri key is deprecated). A tool declares _meta.ui.resourceUri pointing at a ui:// resource. The resource is HTML (text/html;profile=mcp-app), read with resources/read. The host renders it in a sandboxed iframe and talks to it with JSON-RPC over postMessage: ui/initialize, then the host pushes ui/notifications/tool-input and tool-result; the app may call tools/call and resources/read (proxied by the host, same server only, and only tools whose _meta.ui.visibility includes app), and may send ui/message, ui/open-link, ui/update-model-context. The resource's _meta.ui declares csp (connectDomains, resourceDomains, frameDomains, baseUriDomains), permissions (camera, microphone, geolocation, clipboardWrite) and prefersBorder. Omitted means no external access. Web hosts must serve the app through a sandbox proxy on a different origin. Claude, VS Code Copilot, Goose and others render apps today. The ext-apps SDK (@modelcontextprotocol/ext-apps) has an AppBridge for hosts.
What Cully can and cannot do
Cully supervises; the harness owns the model loop and the MCP connection. Cully sees only stream-json tool_use and tool_result events, not the server's tool definitions. So a new capability, mcp-app, is not "the harness supports it" but "Cully can reach the server itself".
| Capability | Claude | Codex | Cursor |
|---|---|---|---|
| See the tool call and result | yes (stream) | partial (transcript, afterwards) | partial |
| Tool name maps to a server | yes (mcp__server__tool) | yes (server and tool fields) | partial |
| Cully reads the server definition | yes, from .mcp.json / ~/.claude.json (already done for the Harness page) | from config.toml | from mcp.json |
Cully reads resources/read itself | yes if stdio or unauthenticated HTTP | same | same |
| Harness itself renders or forwards app calls | no | no | no |
Cully cannot make the harness accept ui/message or update-model-context; the model never hears from the app. Apps are therefore a viewing and direct-action surface for the user, not a channel to the model, unless the user presses "Send to task", which posts a normal user message.
Recommended minimal first step
Read-only viewer, Claude tasks, servers Cully can already start:
- When a
mcp__server__toolresult arrives, Cully looks up the tool's_meta.ui.resourceUriwithtools/listagainst that server (cached; reuses the probe's connection details inui_mcpdetail.go). - If present, Cully calls
resources/readfor theui://URI and keeps the HTML and_meta.uiin memory. - The tool row gets an "Open app" button. The app opens in a sandboxed frame, receives
tool-inputandtool-resultfrom the event, and nothing else. Itstools/callandresources/readrequests are answered with an error ("not enabled") in this step.
This needs an MCP client in Go (initialize, tools/list, resources/read over stdio and streamable HTTP, plus the server's auth). That is well over 150 lines with tests, and OAuth servers need token handling Cully avoids by design. Phase 1 implements it for stdio and unauthenticated HTTP servers (ui_mcpapp.go).
Security model
Risks, stated plainly:
- The HTML comes from a third-party server and is untrusted code in the user's browser, next to a UI that holds a bearer token for agents with write access to repositories.
- Token exposure: the app must never see the Cully token, cookies, or server credentials. Cully fetches the resource with its own connection; credentials never enter the page.
- Prompt injection: app text and
ui/messagecan carry instructions aimed at the model; apps can also spoof Cully UI (fake approval cards). - Exfiltration through
connectDomains, and clickjacking through large overlays.
Controls:
- Sandbox:
<iframe sandbox="allow-scripts">with noallow-same-origin, no top navigation, no popups, no forms. This gives a null origin, so no cookie or storage access to Cully. The existing diagram frame (ui_static/diagram/frame.html,uiDiagramCSP) is the pattern. Unlike the spec's same-origin-needed proxy for web hosts, a null origin plus a served frame path is enough for the first step; a distinct port is the later hardening. - CSP: served per app by a
/mcpapp/<id>route asdefault-src 'none'plus only the declaredresourceDomains;connect-srcis added only for declaredconnectDomainsafter the user approves each domain on a card. Default is no network. The page CSP (script-src 'self',style-src 'self') does not change; the app's inline script lives only inside the framed document. - Messages: the parent checks
event.sourceis that frame, validates the JSON-RPC shape and method allowlist, rate-limits, and logs each call. - App-initiated
tools/call: routed through the existing permission relay, shown as a card with the tool name and arguments, default deny, same server only,visibilitymust includeapp. Read-only calls may be allowed per server after one approval. ui/messageandupdate-model-contextare shown to the user as a draft, never sent automatically.ui/open-linkshows the URL for confirmation.- Resource hash pinned on first view; a changed hash asks again. Size cap on the HTML. Camera, microphone, geolocation are never granted.
- Off by default behind
CULLY_MCP_APPS=1, and per server.
UI
In the task window, the tool row shows "Open app" after a result; the app expands inline under the row, with a visible border and the server name. On the right side panel, an "Apps" tab lists apps from this task; selecting one gives a larger pane with the approval cards for its calls above it. A banner states "Content from server X, running sandboxed".
Phases
- Viewer: Go MCP client for stdio and unauthenticated HTTP,
tools/listandresources/read, frame route and CSP, event-to-app push, flag and tests. - Approved calls: proxy
tools/callandresources/readthrough the permission relay; log to the journal. - Declared domains with approval cards, hash pinning, and a separate-origin frame.
- Codex and Cursor transcripts (read afterwards), and "Send to task" drafts.
- Optional: use the ext-apps
AppBridgebundle vendored underui_staticinstead of a hand-written bridge.
Open questions
- Which servers does the user have that ship apps? Value depends on this.
- Can Cully reuse an OAuth session for HTTP servers without storing tokens? If not, those servers are excluded.
- Should an app state change (for example a form submit) be fed back to the model automatically, or always by an explicit user message?
- Does the harness list
_metain its init event, which would remove the need for a second connection?