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

# Show an interactive view from an MCP tool in the chat

> Agent builder: make an MCP tool display an interactive view (MCP Apps) under its call in the conversation, with its actions governed by the agent's tool permissions.

Use this procedure to make a tool of your MCP server display an interactive view in the chat, following the [MCP Apps](https://modelcontextprotocol.io/seps/1865-mcp-apps-interactive-user-interfaces-for-mcp) standard. When it succeeds, the view appears under the tool call in the conversation, and the actions the user takes in it call your server through the agent.

```mermaid theme={null}
flowchart LR
  T["Tool result with _meta.ui.resourceUri"] --> C["Chat reads the ui:// view"]
  C --> F["Sandboxed iframe"]
  F -->|"tools/call"| R["Agent relay: tool permissions, approval, audit"]
  R -->|"MCP"| S["Your MCP server"]
```

The view runs in an isolated frame: it has no cookie, no session and no network access. Every call it makes goes through the agent, under the same [tool permissions](https://docs.prisme.ai/products/agent-factory/tool-permissions.md) as the calls of the model.

## Before you begin

* **Who:** an agent builder who can edit the agent, and the owner of the MCP server code.
* **Where:** your MCP server, then Agent Factory.
* **Requires:** an MCP server attached to the agent as a tool (see [Capabilities](https://docs.prisme.ai/products/agent-factory/capabilities.md#tools)). A server hosted in a workspace of the platform works as is. An external server must be listed by a platform administrator in `config.mcpApps.allowedServers` of the Agent Factory workspace (URL prefixes), editable in Builder with **Edit Workspace YAML** (`index.yml`).
* **Impact:** every conversation of the agent that calls the tool shows the view.

## Declare the view on your server

**1. Point the tool to a view**

In the tool definition returned by `tools/list`, add `_meta.ui.resourceUri` with a `ui://` URI of your server, for example `ui://notes/board`. URIs under `ui://agent-factory/` are reserved to the platform and ignored.

**2. Serve the view**

Answer `resources/read` for that URI with one content of mime type `text/html;profile=mcp-app` whose `text` is the HTML page of the view (at most 2,000,000 characters). The page talks to the chat over `postMessage`, as defined by MCP Apps.

**3. Choose who can call each tool**

Set `_meta.ui.visibility` on each tool: `["model", "app"]` (the default) lets both the model and the view call it; `["app"]` keeps it for the view only, hidden from the model. A view can only call tools whose visibility lists `app`.

**4. Declare the external origins the view needs**

Optional: the view cannot load scripts, images or fonts from other origins, nor fetch anything, unless the resource declares them in `_meta.ui.csp` (`resourceDomains`, `connectDomains`, `frameDomains`).

> [!NOTE]
>
> The view runs without the user's session: it cannot download a private file, such as the view of a private isolated app stored as a workspace asset. Put the code in the page instead. A server hosted on the platform is called as the user who talks to the agent, so its `resources/read` can read the file with that user's rights and send it inline; a user who cannot open the app gets no view. The Builder starter's `mcp` automation does this for its `hello-card` view.

Ship the view as one HTML page: bundle React or any other library into it, or load it from an origin declared in `resourceDomains`.

The view declares where it can show in `ui/initialize` (`appCapabilities.availableDisplayModes`): `inline` (in the thread, the default) and `fullscreen` (in the side panel, which adds **Open alongside** under the view).

## Govern the actions of the view

In Agent Factory, set the [tool permissions](https://docs.prisme.ai/products/agent-factory/tool-permissions.md#per-tool-overrides) of the server's tools as for any tool. When a view calls a tool with `annotations.destructiveHint` and the agent has no rule for it, the call asks for approval (this applies to calls made by a view, not to the model's own calls). When a view calls a tool that needs approval, the approval card appears under the view and the call runs only after **Approve**.

The chat also asks the user before a view acts on the conversation:

| The view asks to | The user sees |
| - | - |
| Put text in the message box | **Message suggested by \<app>**, with **Insert** (fills the box without sending) or **Ignore** |
| Open a link | **Open this link?**, with **Open** or **Cancel** |

A view can keep values in the browser, per app, across reloads (at most 100 KB, 200 keys, 20 KB per value). They stay in that browser: they are not shared between devices.

## Verify the result

1. In the agent's playground, send a message that makes the agent call the tool. The view appears under the tool call, with **App: \<app> (via \<server>)**.
2. In the view, trigger an action that calls a tool marked `["app"]`. The view shows the result, and the tool does not appear in the tools the model can call.
3. Reload the conversation. The view appears again from the history.

## Troubleshooting

### `The app returned no view.`, `The app view is not a web page.`

**Cause:** `resources/read` returns no content, or a content that is not `text/html`.

**Owner:** the owner of the MCP server.

**Resolution:** return one content with mime type `text/html;profile=mcp-app` and the HTML in `text`, then reload the conversation.

### `The app did not answer in time. The action may still be running.`

**Cause:** the tool took longer than the request timeout. The tool may still finish on the server.

**Owner:** the owner of the MCP server.

**Resolution:** return quickly with an identifier, and give the view a tool marked `["app"]` that reports the progress. Do not let the user repeat the action blindly.

### `The app could not be displayed`

This title comes with every view that fails to load. The line under it tells the cause:

| Detail under the title | Cause | Owner | Resolution |
| - | - | - | - |
| `App server not allowed` | The server is not hosted on the platform and its URL is not in `config.mcpApps.allowedServers`, or its `tools/list` declares no tool with `_meta.ui.resourceUri` | Platform administrator (allowed servers), owner of the MCP server (tool definitions) | Add the server URL prefix to `config.mcpApps.allowedServers`, or declare the view on the tool, then select **Retry** |
| `The app is unreachable right now.` | The agent could not reach the MCP server | Owner of the MCP server | Check that the server answers, then select **Retry** |
| `Too many requests from this app. Try again in a moment.` | The view sent too many requests in a short time | Owner of the MCP server | Wait a moment, then select **Retry**; reduce the calls the view makes |
| `The app server returned an error.` | The server answered `resources/read` with an error | Owner of the MCP server | Fix the server's answer for that URI, then select **Retry** |
| `The app view is too large to display.` | The HTML of the view is over 2,000,000 characters | Owner of the MCP server | Load the code of the view from `resourceDomains` instead of inlining it |
| `The app view is empty.` | `resources/read` returned an empty page | Owner of the MCP server | Return the HTML of the view in `text` |

The entries above cover the other details: no view, not a web page, and a timeout.

### The tool result shows no view

**Cause:** the tool definition has no `_meta.ui.resourceUri`, or its URI is under the reserved `ui://agent-factory/` prefix.

**Owner:** the owner of the MCP server.

**Resolution:** fix the tool definition, then send the message again. The agent keeps the server's tool list for up to 5 minutes: save the agent to refresh it at once.


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