> ## Documentation Index
> Fetch the complete documentation index at: https://sunpeak.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Apps - Build Interactive UIs for AI Chat Hosts

> Learn how to build MCP Apps that render interactive UIs inside ChatGPT, Claude, and other AI hosts. Covers the App class, event handlers, styling, React hooks, and the MCP Apps protocol.

> [!NOTE]
>
> This API reference matches MCP Apps SDK v2.0.4, which current sunpeak releases use. The iframe
> wire protocol is compatible with 1.x Views and Hosts, but dependencies and some TypeScript APIs
> changed. See the [SDK 2.0 migration guide](https://sunpeak.ai/docs/mcp-apps/sdk-v2-migration.md) when upgrading an older
> standalone app or sunpeak integration.

## What are MCP Apps?

MCP Apps is an extension to the [Model Context Protocol](https://sunpeak.ai/docs/mcp-apps/mcp/overview.md) that enables MCP servers to deliver interactive user interfaces to hosts. It defines how servers declare UI resources, how hosts render them securely in iframes, and how the two communicate.

MCP allows servers to expose [tools](https://sunpeak.ai/docs/mcp-apps/mcp/tools.md) and [resources](https://sunpeak.ai/docs/mcp-apps/mcp/resources.md) to AI assistants, but responses are limited to text and structured data. Many use cases need more:

* **Data visualization** — Charts, graphs, dashboards that update as data changes
* **Rich media** — Video players, audio waveforms, 3D models
* **Interactive forms** — Multi-step wizards, configuration panels, approval workflows
* **Real-time displays** — Live logs, progress indicators, streaming content

MCP Apps standardizes this. Servers declare their UIs once; any compliant host can render them.

## How do plugins relate to ChatGPT Apps?

ChatGPT apps are now submitted and published as plugins. A plugin can contain an MCP-backed app, skills, or both. The app portion still uses MCP Apps or the OpenAI Apps SDK, so this is a packaging and distribution change rather than a protocol change.

When you build with sunpeak, you still create an MCP server, tools, and UI resources. For local ChatGPT development, enable Developer mode and add that MCP server from the `Plugins` page. For public release, submit the MCP server as a plugin through the OpenAI Platform. See the [deployment guide](https://sunpeak.ai/docs/app-framework/guides/deployment.md#publish-to-chatgpt) for both flows.

## How do MCP Apps work?

Three entities work together:

```mermaid theme={null}
flowchart LR
    subgraph Server ["MCP Server"]
        T[Tools]
        R[UI Resources]
    end

    subgraph Host ["Host (Chat Client)"]
        B[AppBridge]
    end

    subgraph View ["View (iframe)"]
        A[App]
    end

    Server <-->|MCP Protocol| Host
    Host <-->|postMessage| View
```

* **Server** — A standard MCP server that declares tools and UI resources. Defines what the UI looks like (HTML) and what tools it exposes.
* **Host** — The chat client (e.g., Claude, ChatGPT) that connects to servers, embeds Views in iframes, and proxies communication between them.
* **View** — The UI running inside a sandboxed iframe. Receives tool data from the Host and can call server tools or send messages back to the chat.

## What happens if a host doesn't support MCP Apps?

MCP Apps supports text fallbacks. Clients advertise UI support in capabilities during legacy MCP `initialize` or on each MCP `2026-07-28` request. A server can use those capabilities to tailor UI metadata, and every tool should return useful text in `content`. A host without MCP Apps support can use that text result without rendering the View.

See [Capability Detection](https://sunpeak.ai/docs/mcp-apps/server/capability-detection.md) for implementation details.

## How are MCP App UIs delivered?

UI resources are HTML templates that servers declare using the `ui://` URI scheme. Resources are declared upfront during [tool registration](https://sunpeak.ai/docs/mcp-apps/server/register-app-tool.md), enabling:

* **Prefetching** — Hosts can cache templates before tool execution
* **Separation of concerns** — Templates (presentation) are separate from tool results (data)
* **Review** — Hosts can inspect UI templates during connection setup

## How are tools linked to UIs?

Tools reference their UI templates through [tool metadata](https://sunpeak.ai/docs/mcp-apps/server/tool-meta.md):

```json theme={null}
"_meta": {
  "ui": { "resourceUri": "ui://weather/forecast" }
}
```

When a tool with UI metadata is called, the Host fetches the corresponding resource, renders it in a sandboxed iframe, and passes the tool arguments and results to the View.

## What can MCP Apps do at runtime?

Views communicate with Hosts using JSON-RPC over `postMessage`. From a View, you can:

* **[Call server tools](https://sunpeak.ai/docs/mcp-apps/app/requests/call-server-tool.md)** — Fetch fresh data or trigger server-side actions
* **[Send messages](https://sunpeak.ai/docs/mcp-apps/app/requests/send-message.md)** — Add messages to the conversation thread
* **[Update model context](https://sunpeak.ai/docs/mcp-apps/app/requests/update-model-context.md)** — Push structured data to the model's context
* **[Request LLM completions](https://sunpeak.ai/docs/mcp-apps/app/requests/create-sampling-message.md)** — Ask the host to run `sampling/createMessage`
* **[Open links](https://sunpeak.ai/docs/mcp-apps/app/requests/open-link.md)** — Request the host to open external URLs
* **[Download files](https://sunpeak.ai/docs/mcp-apps/app/requests/download-file.md)** — Trigger host-mediated file downloads
* **[Request display modes](https://sunpeak.ai/docs/mcp-apps/app/requests/request-display-mode.md)** — Switch between inline, fullscreen, and picture-in-picture

See the full [App lifecycle](https://sunpeak.ai/docs/mcp-apps/lifecycle.md), [Requests API](https://sunpeak.ai/docs/mcp-apps/app/requests.md), and [View API Guide](https://sunpeak.ai/docs/mcp-apps/app/view-api-guide.md) for details.

## How does tool visibility work?

Tools can be visible to the model, the app, or both. By default, tools are visible to both (`visibility: ["model", "app"]`).

App-only tools (`visibility: ["app"]`) are useful for UI interactions that shouldn't clutter the agent's context — things like refresh buttons, pagination controls, or form submissions. The model never sees these tools; they exist purely for the View to call.

Views can also register their **own** tools that the host (and the model) can call back into. See [App Tools](https://sunpeak.ai/docs/mcp-apps/app/app-tools.md) for the full bidirectional pattern.

## What display modes are available?

Views can be displayed in different modes:

* **inline** — Embedded in the chat flow (charts, previews, forms)
* **fullscreen** — Takes over the window (editors, games, dashboards)
* **pip** — Picture-in-picture overlay (music player, timer)

Views declare which modes they support; Hosts declare which they can provide. The Host always has final say over its own UI. See [Layout and Display](https://sunpeak.ai/docs/mcp-apps/layout.md) for sizing, auto-resize, and safe area guidance.

## How are MCP Apps secured?

All Views run in separate-origin sandboxed iframes with no access to the Host's DOM, cookies, or storage. The Host validates and mediates JSON-RPC messages sent through `postMessage`.

Servers declare which network domains their UI needs via [CSP metadata](https://sunpeak.ai/docs/mcp-apps/server/resource-meta.md#csp--content-security-policy). Hosts enforce these declarations — if no domains are declared, no external connections are allowed.

Start with the [MCP Apps Security Model](https://sunpeak.ai/docs/mcp-apps/security.md) for the trust boundaries, tool authorization rules, result-data audiences, and pre-ship checks. Use [CSP and CORS](https://sunpeak.ai/docs/mcp-apps/server/csp-cors.md) when configuring external origins.

## More questions?

The [Layout and Display](https://sunpeak.ai/docs/mcp-apps/layout.md) guide covers iframe sizing, display modes, and responsive View CSS. The [Patterns](https://sunpeak.ai/docs/mcp-apps/patterns.md) guide covers app-only tools, polling, large data, errors, and host adaptation. [State Persistence](https://sunpeak.ai/docs/mcp-apps/state-persistence.md) explains how to restore a View and share state with the model. If a tool runs but its View does not appear, follow [MCP Apps Troubleshooting](https://sunpeak.ai/docs/mcp-apps/troubleshooting.md). The [MCP Apps FAQ](https://sunpeak.ai/docs/mcp-apps/faq.md) answers common questions about hosts, UI delivery, display modes, theming, security, and testing.

If you are wiring the server side from scratch, start with [Build an MCP App Server](https://sunpeak.ai/docs/mcp-apps/server/build-server.md). If you already have a normal MCP tool and want to add an interactive View, use [Add a UI to an MCP Tool](https://sunpeak.ai/docs/mcp-apps/server/add-ui-to-tool.md). Before testing in a host, use the [MCP App Requirements Checklist](https://sunpeak.ai/docs/mcp-apps/server/requirements.md) to verify portability, fallback behavior, CSP, annotations, and result data. For a field-by-field check, use the [Tool and Resource Contract](https://sunpeak.ai/docs/mcp-apps/server/tool-resource-contract.md). For result payloads, use [Tool Results and Model Context](https://sunpeak.ai/docs/mcp-apps/server/tool-results-model-context.md) to decide what belongs in `content`, `structuredContent`, `_meta`, and `updateModelContext`.

If you already have OpenAI Apps SDK code, use [Migrate from OpenAI Apps SDK to MCP Apps](https://sunpeak.ai/docs/mcp-apps/server/migrate-openai-apps.md) to map `openai/outputTemplate`, `text/html+skybridge`, `widgetCSP`, and `window.openai` APIs to MCP Apps equivalents.

If you maintain a standalone MCP App on `@modelcontextprotocol/ext-apps` 1.x, use the [MCP Apps SDK 2.0 Migration Guide](https://sunpeak.ai/docs/mcp-apps/sdk-v2-migration.md) for package, schema, handler, and error changes. Current sunpeak releases already manage the split MCP 2.x packages for framework projects.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.