AshAi.McpUiResource (ash_ai v0.6.1)

Copy Markdown View Source

A UI resource for MCP Apps (Model Context Protocol Apps extension).

UI resources serve static HTML files that are 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]
end

The HTML file at html_path is read at request time and 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

t()

@type t() :: %AshAi.McpUiResource{
  __spark_metadata__: term(),
  csp: keyword() | nil,
  description: String.t() | nil,
  domain: :auto | String.t() | nil,
  html_path: String.t(),
  name: atom(),
  permissions: keyword() | nil,
  prefers_border: boolean() | nil,
  title: String.t() | nil,
  uri: String.t()
}

Functions

mime_type()

Returns the fixed MIME type for MCP App UI resources.