Skip to content
mentoor

Topic 1 of 4 · 5 min read

Interactive MCP Apps inside chat hosts

Goal: Decide whether a feature needs an MCP App view and trace how a tool call turns into a rendered interface the user can act on.

An MCP App is a tool that points at an HTML page; the host renders that page inside the conversation, and the page can call the server's tools back. It is two ordinary MCP pieces joined by one metadata field.

Check yourself · 1 of 3

How does a host know a tool has an interactive view?

Choose one answer

Why it matters

Text answers stop working when the user has to choose, explore or approve. "Show me sales by region" as a list of 40 numbers is hard to use. The same data as a map you can click is easy. A link to a separate web app works, but the user leaves the chat, loses context, and the app needs its own login and API. An MCP App stays in the thread, and the host can push fresh tool results into it.

How it works

  1. The tool declares a UI in its definition: _meta.ui.resourceUri set to a ui:// address.
  2. The server also registers that address as a resource. Its mime type is text/html;profile=mcp-app, and its body is a bundled HTML page.
  3. The host can fetch the page early. When the model calls the tool, the host renders the page in a sandboxed iframe and sends it the tool result.
  4. The page talks to the host over a postMessage JSON-RPC channel (ui/initialize and similar). When the user clicks, the page asks the host to call a tool, and the host forwards it to the server.
registerAppTool(server, "sales-by-region", {
  description: "Show sales by region as an interactive map",
  inputSchema: { quarter: z.string() },
  _meta: { ui: { resourceUri: "ui://sales/map.html" } },
}, async ({ quarter }) => ({
  content: [{ type: "text", text: await summary(quarter) }],
  structuredContent: await salesByRegion(quarter),
}));

The tool result still carries a text summary. That text is what the model, or a host without app support, reads.

Before and after

Weak: a configure_deployment tool that makes the model ask "which region?", "which size?", "autoscaling?" over six turns, each answer typed and each typo retried.

Better: one tool call opens a form showing every option with defaults and validation. The user submits once, and the page calls a create_deployment tool with the result.

What to build as an app

Good fits are data exploration, forms with many linked options, rich media viewers, live dashboards and multi-step approvals. A one-value answer such as "the build passed" needs no UI.

What goes wrong

  • UI for its own sake. A chart that adds nothing over one sentence costs build time and review effort.
  • No text fallback. If the result only works as HTML, the model cannot read it, and hosts without the extension show nothing useful.
  • Hidden state in the page. The model does not see what the user clicked unless the page sends a message or a context update. Decisions made only inside the iframe never reach the conversation.

Examples

A form instead of six questions

A deploy server exposes open_deploy_form with _meta.ui.resourceUri set to ui://deploy/form.html. The model calls it once. The host shows region, instance size and autoscaling together, with defaults. On submit the page calls the app-only create_deployment tool. The model sees the outcome instead of six clarifying turns.

When text is enough

A get_build_status tool returns passed, 214 tests, 3m12s. A dashboard view would repeat one line of text in a bigger box. Keep it text, and spend the effort where users must choose or explore, such as triaging a list of failing builds.

Key points

  • An MCP App is a tool whose metadata names a ui:// resource that the host renders in a sandboxed iframe in the conversation.
  • The UI resource is served with the mime type text/html;profile=mcp-app and is an ordinary MCP resource.
  • The page can request tool calls through the host, so interaction does not need a separate API or login.
  • Build a view when users must explore, configure many options or approve items; a short fact needs only text.
  • Always return a text summary from the tool so the model and hosts without app support still get an answer.

Common mistakes

  • Building an app view for an answer one sentence would carry.
  • Returning only HTML-bound data, so the model and non-app hosts get nothing readable.
  • Assuming the model sees clicks inside the iframe without the page reporting them.
  • Treating the app as a full website with its own backend instead of calling the server's tools through the host.

Check yourself · 2 of 3

Which request is the best fit for an MCP App view?

Choose one answer

Check yourself · 3 of 3

A user clicks Approve inside an MCP App. What is the normal way that click reaches the server?

Choose one answer

Practice items, not counted towards your mastery.

Start here