Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path →
MCP
apps.
Assistants have mostly spoken in text. MCP Apps change that: a tool can now render a real interactive UI — a form, a chart, a booking widget — right inside Claude or ChatGPT. But an interactive surface shipped by a third party, running inside your trusted assistant, is a security problem wearing a friendly face. The answer is an old, well-understood pattern: put it in a sandboxed iframe, and make every request it wants to send cross a single bridge the host controls.
UI, not just text
An MCP server gives a model tools and data. An MCP App adds the missing layer: a rendered, interactive UI the human sees and clicks, displayed by the host assistant. Proposed on November 21, 2025 as SEP-1865, written by MCP core maintainers at Anthropic and OpenAI together with the creators of the community MCP-UI project, and launched as an official MCP extension on January 26, 2026, it lets a tool return a control panel instead of a paragraph.
That's a genuine capability jump, and a genuine trust problem. The UI is third-party code you didn't write, running inside an app that holds the user's conversation, credentials, and context. You can't just drop it into the page. Everything about how MCP Apps are built is shaped by that one fact — the UI is untrusted, and the host is not.
The sandbox: a locked room with one door
MCP App UIs render in a sandboxed iframe. By construction, a sandboxed iframe cannot reach into the host page's DOM, read its storage, or make network calls on the host's behalf. It's isolated — a locked room. The only way anything gets in or out is a message channel the host explicitly wires up.
conversation, creds
the ONLY door
3rd-party UI (untrusted)
This is sandboxing applied to UI: assume the code inside is hostile, give it no ambient authority, and force every request through a single, inspectable channel. The isolation isn't a nice-to-have — it's the entire reason it's safe to render someone else's UI inside your assistant.
The bridge speaks JSON-RPC
The door between iframe and host is postMessage, and the language spoken across it is JSON-RPC — the same structured request/response protocol MCP itself uses. The iframe posts a message naming a method and params with an id; the host posts back a response carrying the same id and either a result or an error.
host → iframe: { "jsonrpc":"2.0", "id":7, "result":{…} } // same id
Structured, typed, correlated by id. Nothing free-form crosses the boundary — just named method calls the host knows how to reason about.
Using a real RPC protocol rather than ad-hoc messages is what makes the boundary auditable. The host isn't parsing arbitrary strings from untrusted code; it's receiving discrete, named requests it can accept or reject one at a time.
The host mediates every request
Here's where the security actually lives. The host doesn't execute whatever the iframe asks — it checks each method against an allowlist of capabilities it has chosen to expose. Method on the list? Execute and return a result. Method not on the list? Return an error and do nothing. The iframe cannot reach a capability the host didn't deliberately hand it, because the sandbox gives it no other path.
Least privilege at the UI boundary: the app gets exactly the capabilities the host exposes, and a request for anything else — including host internals — is refused by default.
Sandbox + bridge + allowlist is the whole model. The sandbox removes ambient authority; the JSON-RPC bridge makes every request explicit; the allowlist decides which requests are honored. An MCP App is powerful because it can ask the host to do things — and safe because the host, not the app, decides what "things" means.
The runnable host below is that mediator: it round-trips an allowlisted call, refuses everything else with a structured error, and shows that even a host-internal method name can't be reached through the bridge.
Build one: a tool, a ui:// resource and a View
An MCP App is two registrations on an ordinary MCP server, tied together by one URI. The tool does the work and points at its UI through _meta.ui.resourceUri. The resource serves the UI itself: one HTML document at a ui:// URI, with the MIME type text/html;profile=mcp-app. Here is the shape of the official quickstart, using the @modelcontextprotocol/ext-apps SDK:
registerAppTool(server, "get-time", {
description: "Returns the current server time.",
inputSchema: z.object({}),
_meta: { ui: { resourceUri } }, // links the tool to its UI
}, async () => ({ content: [{ type: "text", text: new Date().toISOString() }] }));
registerAppResource(server, resourceUri, resourceUri, { mimeType: RESOURCE_MIME_TYPE },
async () => ({ contents: [{ uri: resourceUri, mimeType: RESOURCE_MIME_TYPE, text: html }] }));
Server side, condensed from the ext-apps quickstart. html is the View, bundled into a single file (the quickstart uses Vite with a single-file plugin).
The View is a plain web page. It creates an App, registers its handlers and connects. app.connect() runs the handshake described in the next section, and callServerTool sends a tools/call through the host.
app.ontoolresult = (result) => render(result); // set before connect()
button.onclick = async () =>
render(await app.callServerTool({ name: "get-time", arguments: {} }));
app.connect();
If the View needs the network, the resource says so in its own metadata, _meta.ui.csp: connectDomains for fetch and WebSocket origins, resourceDomains for scripts, styles, images and fonts, and frameDomains for nested iframes. The host builds the iframe's Content-Security-Policy from those lists and, in the spec's words, "MUST NOT allow undeclared domains." Declare nothing and you get the restrictive default, which includes connect-src 'none': the View can't call out at all. Declaring domains up front also lets the host warn the user, and log, where a UI can reach before it renders.
The real message flow, from tools/list to teardown
The bridge example above and the runnable below use a stand-in method, getWeather. On the wire, the View (the spec's name for the app's iframe) speaks a small, fixed vocabulary: a set of ui/ methods plus a few standard MCP messages. Here is one render, in order, per the 2026-01-26 specification:
host → server tools/call get-time // in parallel with rendering the View
view → host ui/initialize // host replies with its context and capabilities
view → host ui/notifications/initialized
host → view ui/notifications/tool-input-partial (0..n), then ui/notifications/tool-input
host → view ui/notifications/tool-result // or ui/notifications/tool-cancelled
view → host tools/call, ui/message, ui/open-link, ui/update-model-context
host → view ui/resource-teardown
| Message | Direction | What the host does |
|---|---|---|
| ui/initialize | View → host | The handshake. It replaces MCP-UI's old iframe-ready message, and the View confirms with ui/notifications/initialized. |
| tool-input, tool-result | host → View | Pushes the arguments the model chose and the tool's result, so the View renders data it never fetched. |
| tools/call | View → host → server | Proxied to the View's own server. The host MUST reject calls to tools whose visibility lacks "app", and cross-server calls to app-only tools are always blocked. |
| ui/message | View → host | Adds a message to the conversation. The host MAY ask the user first. |
| ui/open-link | View → host | Opens a URL in the user's browser, or returns an error such as "Link opening denied by user". |
| ui/update-model-context | View → host | Overwrites what the model is told about the View's current state. |
Two details carry the security model. First, on a web host the View never shares an origin with the host. The host renders a sandbox proxy on a different origin, which signals ui/notifications/sandbox-proxy-ready, receives the HTML in ui/notifications/sandbox-resource-ready, and loads it in an inner iframe under the declared CSP. Second, this page's "allowlist" has a concrete form: a tool's visibility, which defaults to ["model", "app"], decides who may call it. A tool marked ["app"] never appears in the model's tool list, and one marked ["model"] can't be called from the View. On top of that, the spec lets hosts require explicit user approval for UI-initiated tool calls.
Where it runs, and what it unified
MCP Apps went live as an official extension on January 26, 2026, with support in Claude (web and desktop), Goose and VS Code Insiders, and ChatGPT starting that week. It unified two earlier approaches: the community MCP-UI project, whose adopters included Postman, Hugging Face, Shopify, Goose and ElevenLabs, and OpenAI's Apps SDK, which already used MCP as its backbone. One server can now ship one UI to every host that negotiates the extension (io.modelcontextprotocol/ui), and a host that doesn't support it still gets a working, text-only tool.
It also sharpens the map of the MCP world. The MCP server is the capability backend; the MCP App is the interactive frontend; and the untrusted-component discipline from agent supply-chain security applies to both — an app you install is another dependency whose blast radius the host's allowlist is there to bound.
The protocol underneath: MCP. The isolation pattern: Sandboxing. The trust discipline: Agent Supply-Chain Security.
The host as gatekeeper: mediate every iframe request
This is the entire MCP App security model in one function. A sandboxed iframe posts JSON-RPC requests; the host handles each by checking the method against an allowlist of capabilities it chose to expose. An allowlisted call round-trips (same id, a result); anything else — including a made-up destructive method or a host-internal name — comes back as a structured error and never executes. Change the allowlist and the requests, and watch what does and doesn't get through the door.
Worked example: one get-time render, message by message
Take the quickstart’s get-time app. Its resource declares no _meta.ui.csp. Say the same server also has a reset-cache tool marked visibility: ["model"]. Here is everything that crosses a boundary, and what the host decides at each step.
| Step | Message | Direction | What the host decides |
|---|---|---|---|
| 1 | tools/list | host ⇄ server | get-time carries _meta.ui.resourceUri = ui://get-time/mcp-app.html, so it has a View. reset-cache is offered to the model only. |
| 2 | resources/read | host ⇄ server | Gets one HTML file, text/html;profile=mcp-app. No CSP lists, so the iframe gets the default, including connect-src 'none'. |
| 3 | tools/call get-time | host → server | Sent while the View loads. The result is an ISO timestamp in content. |
| 4 | ui/initialize, then ui/notifications/initialized | View → host | The handshake. The host answers with its context and capabilities. |
| 5 | ui/notifications/tool-input, then tool-result | host → View | Pushes the arguments ({}) and the result. The View renders a time it never fetched. |
| 6 | User clicks “refresh”: tools/call get-time | View → host → server | Visibility defaults to ["model", "app"], so the call is proxied. The host may ask the user first. |
| 7 | fetch("https://api.example.com") | View → network | Never leaves the iframe. That origin was not declared, so the CSP blocks it. |
| 8 | tools/call reset-cache | View → host | Rejected. Its visibility lacks "app". The server never sees the call. |
| 9 | ui/resource-teardown | host → View | The View is told to clean up before it is removed. |
Steps 7 and 8 are the security model doing its job. The View is the same code in both, but a request only works if the host was told about it in advance: an origin in the CSP lists, or "app" in a tool’s visibility. Everything the View legitimately needed arrived as a push (step 5) or a mediated call (step 6). The host can log both.
Trade-offs: what each design choice costs
Here Time is the latency or friction a choice adds. Space is the reach it gives the View, or the model context it uses.
| Case | Time | Space | Why |
|---|---|---|---|
| Declare no network domains | Every piece of data is a push or a host round trip | Smallest possible reach: connect-src 'none' | The right default. Data comes from your server through the host, which sees every call. |
Declare connectDomains | The View fetches directly, with no host hop | Each declared origin is somewhere the View can send data | The host can show and log these origins before render. Keep the list short and specific. |
Tool visibility ["model", "app"] (default) | None | Both the model and the View can call it | Fine for read-only tools. Too broad for anything that changes state. |
Visibility ["app"] | None | Not in the model’s tool list, so it costs no model context | For UI-only actions like paging a table or sorting a list. |
Visibility ["model"] | None | The View cannot call it at all | For actions a click inside third-party UI should never trigger. |
| User approval for UI-initiated calls | One confirmation per call | No change in reach; adds a human check | The strongest control, and the most friction. Use it for writes. |
ui/message vs ui/update-model-context | A message may wait for user approval | A message adds to the conversation; a context update overwrites | Use the update for state the model should know, like the current selection. Use a message for something the user should see. |
Common mistakes
- Fetching from the View by default
Without declared domains,
fetchfails underconnect-src 'none'. Teams then declare a wide list to make it work. Usually the data should come from a tool instead: in the tool result, or throughcallServerTool, which the host mediates and can log. - Attaching handlers after connect()
The quickstart sets
app.ontoolresultbeforeapp.connect()for a reason. The host can pushtool-resultas soon as the handshake completes. A handler attached later can miss it, and the View sits empty. - Leaving a write tool at the default visibility
With the default
["model", "app"], any View from that server can trigger the tool with a click. Mark state-changing tools["model"], or keep them app-callable only behind user approval. - Putting secrets in the HTML resource
The
ui://resource is a document the host renders for the user. An API key or internal URL inside it is shipped to every client that opens it. Keep credentials on the server and expose actions as tools. - An empty text fallback
A host that does not negotiate
io.modelcontextprotocol/uishows only the tool’scontent. If that says “see the UI”, the tool is useless there. Return real text, likeget-time’s timestamp, so every host gets an answer.
Where this shows up in production and interviews
- One server, many assistants
Claude, ChatGPT, Goose and VS Code Insiders all render the same View, because the UI is a standard resource rather than a per-host plugin. The server ships one HTML file and still works as a plain tool everywhere else.
- Inputs text is bad at
Picking a date range, choosing a seat or reviewing a table of 40 rows takes many turns as chat and one interaction as a View. The View then uses
ui/update-model-contextto tell the model what the user chose. - Security review of an app
The declared CSP lists and each tool’s visibility are the review surface. A reviewer can see where the View can reach and which tools it can trigger before it ever renders. Ask for those first, as you would for a browser extension’s permissions.
- The interview version
“How would you let third parties render UI inside a chat product?” Cover the four layers: a sandboxed iframe on a separate origin, one
postMessagechannel speaking JSON-RPC, a host allowlist per method, and a CSP built from declared origins. Then say where a human confirms.
Check yourself
Your View declares no CSP and calls fetch() on your own API. What happens, and what are your two fixes?
It is blocked: with nothing declared, the default includes connect-src 'none'. Either add your API’s origin to connectDomains, or, usually better, move the call into a tool and use callServerTool, so it goes through the host.
An export-csv tool has visibility ["app"]. A user asks the model to export the table. Can the model call it?
No. An ["app"] tool never appears in the model’s tool list. Only the View can call it, for example from an Export button. If the model should also be able to export, use the default ["model", "app"].
In the runnable, the View sends id 9 with method "__host_secrets__". What comes back?
A response with "id": 9 and an error with code -32601, JSON-RPC’s “method not found”. Nothing runs. The id still matches, so the View can pair the refusal with its request. The name does not matter; only membership in the allowlist does.
A host that does not support MCP Apps calls your tool. What does the user see?
Only the tool result’s content, because the host never negotiated io.modelcontextprotocol/ui and never reads the ui:// resource. That is why the text result must stand on its own.
Quick answers
What are MCP Apps?
Interactive UIs that render inside an assistant like Claude or ChatGPT instead of plain text — a form, chart, or control panel shipped by an MCP server and shown in a sandboxed iframe. The first official UI extension to the Model Context Protocol.
How is the app isolated?
It runs in a sandboxed iframe that can't touch the host page, its DOM, storage, or network directly. The only way out is a message channel — a locked room with a single monitored door.
How does it talk to the host?
Via postMessage carrying JSON-RPC: the iframe sends a method + params + id, the host checks the method against an allowlist, executes if permitted, and returns a response with the same id. Everything crosses this one mediated bridge.
How is it different from an MCP server?
The server is the capability backend (tools/data over JSON-RPC); the app is the interactive frontend (the UI the human clicks, sandboxed). They compose, but the app adds presentation plus a new untrusted-code boundary to mediate.
How do you build an MCP App?
Register two things on an MCP server: a tool whose _meta.ui.resourceUri points at a ui:// resource, and that resource, which returns a single HTML document with the MIME type text/html;profile=mcp-app. Inside the HTML, the View creates an App from the @modelcontextprotocol/ext-apps SDK and connects. It then receives the tool's input and result as notifications, and can call its own server's tools back through the host. Declare any network origins the View needs in the resource's CSP metadata, or the host blocks them.
Explore the topic
See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.
More Handbooks
- The Agentic AI Interview HandbookTwenty topics every senior AI engineer should be able to reason about live — from eval pipelines to reliability patterns for generative systems.Read →
- The Agent Evaluations HandbookA self-contained handbook on evaluating AI agents — theory, interactive widgets, and practical guidance. Trajectory evals, tool-use scoring, LLM-as-judge, observability, and reliability for PMs, engineers, and founders.Read →
- The Agent Patterns HandbookThe design patterns behind every LLM agent — the ReAct Thought–Action–Observation loop, tool/function calling, plan-and-execute, reflection, memory, multi-agent orchestration, and the failure modes (loops, hallucinated tools, recovery, human-in-the-loop) that break agents in production.Read →
- The Model Context Protocol (MCP) HandbookThe open standard connecting AI agents to the outside world — why M×N bespoke integrations collapse to M+N, the host/client/server roles over JSON-RPC, the three primitives (tools, resources, prompts), the connect→discover→call session lifecycle, when MCP earns its keep, and the security sharp edges (a server's output is untrusted input).Read →
- The Loop Engineering HandbookStop prompting your agents — design the system that prompts them for you. The inner vs outer loop, the four loop types (heartbeat, cron, hook, goal), the six building blocks (automations, worktrees, skills, MCP connectors, subagents, external memory), stopping conditions and the verification split, state across runs, cost engineering, and the six failure modes that burn tokens at 3am.Read →
- The Context Engineering HandbookThe discipline that replaced prompt-tweaking: curating everything the model sees under a finite attention budget. The anatomy of a production context window, the three taxes on an overstuffed one (context rot, cost, behavioral drift), the four operations (write, select, compress, isolate), agent-specific patterns like compaction and just-in-time retrieval, six production habits, and where it sits in the prompt → context → loop → harness stack.Read →