A UI resource for MCP Apps (Model Context Protocol Apps extension).
UI resources serve HTML that is rendered in sandboxed iframes by MCP hosts
(like Claude Desktop). They are linked to tools via _meta.ui.resourceUri and provide
interactive interfaces for tool results.
Example
mcp_resources do
mcp_ui_resource :estimates_list, "ui://estimates/list.html",
html_path: "priv/mcp_apps/estimates.html"
mcp_ui_resource :dashboard, "ui://dashboard.html",
html_path: "priv/mcp_apps/dashboard.html",
csp: [connect_domains: ["api.example.com"]],
permissions: [camera: true]
endConfigure exactly one of html_path or html. The file at html_path is read
at request time. Alternatively, html: {MyApp.Widget, :render, []} invokes an
MFA at request time. It must return an HTML string or {:error, message} with
a string error message. Request parameters are not passed to the callback.
Both sources are returned with MIME type text/html;profile=mcp-app.
See MCP Apps spec.
Summary
Functions
Returns the fixed MIME type for MCP App UI resources.
Types
@type t() :: %AshAi.McpUiResource{ __spark_metadata__: term(), csp: keyword() | nil, description: String.t() | nil, domain: :auto | String.t() | nil, html: mfa() | nil, html_path: String.t() | nil, name: atom(), permissions: keyword() | nil, prefers_border: boolean() | nil, title: String.t() | nil, uri: String.t() }