Snodo.Apps (snodo v0.5.0)

Copy Markdown View Source

Shapes for the MCP Apps extension (io.modelcontextprotocol/ui, specification 2026-01-26). MCP Apps is Stable. See Extension maturity.

MCP Apps links a tool to a ui:// resource holding an HTML document that the host renders. The extension adds no methods: the server declares it, links tools through _meta, and serves the resource. These functions return the plain values the existing options take:

use Snodo.Server,
  name: "weather",
  version: "1.0.0",
  extensions: [Snodo.Apps.extension()]

tool "forecast", metadata: Snodo.Apps.tool_metadata("ui://weather/forecast") do
  @impl true
  def call(_arguments, _context), do: {:ok, "Sunny, 21 C"}
end

resource "forecast_view",
  uri: "ui://weather/forecast",
  mime_type: "text/html;profile=mcp-app" do
  @impl true
  def read(_params, _context) do
    {:ok,
     Snodo.Result.resource_read(
       Snodo.Apps.html("ui://weather/forecast", @html,
         csp: [connect_domains: ["https://api.example.com"]],
         prefers_border: true
       )
     )}
  end
end

A host without MCP Apps ignores _meta.ui and shows the tool's content, so a tool's result stays meaningful as text. supported?/1 tells a handler whether the client declared the extension, for a handler that returns something different to such a client.

The extension is negotiated through capabilities["extensions"] on 2026-07-28 and 2025-11-25. On 2025-06-18, supported?/1 returns false.

Summary

Functions

The client side of the declaration, for Snodo.Client's :client_capabilities: the extension with mimeTypes listing mime_type/0.

The declared extension for use Snodo.Server, extensions: [...].

A resources/read content map for the HTML document html at the ui:// URI uri, with mime_type/0 and the _meta from resource_metadata/1, which takes the same options.

The extension id, "io.modelcontextprotocol/ui".

The MIME type of an MCP Apps HTML resource, "text/html;profile=mcp-app".

The _meta of a UI resource: its Content Security Policy, permissions, sandbox domain, and border preference. Returns %{} when no option is given.

Returns whether the client declared the extension with mime_type/0 in its mimeTypes.

The tool _meta that links a tool to the UI resource at resource_uri.

Types

permission()

@type permission() :: :camera | :microphone | :geolocation | :clipboard_write

visibility()

@type visibility() :: :model | :app

Functions

client_capabilities()

@spec client_capabilities() :: map()

The client side of the declaration, for Snodo.Client's :client_capabilities: the extension with mimeTypes listing mime_type/0.

extension()

@spec extension() :: {:declared, String.t(), map()}

The declared extension for use Snodo.Server, extensions: [...].

html(uri, html, opts \\ [])

@spec html(String.t(), String.t(), keyword()) :: map()

A resources/read content map for the HTML document html at the ui:// URI uri, with mime_type/0 and the _meta from resource_metadata/1, which takes the same options.

id()

@spec id() :: String.t()

The extension id, "io.modelcontextprotocol/ui".

mime_type()

@spec mime_type() :: String.t()

The MIME type of an MCP Apps HTML resource, "text/html;profile=mcp-app".

resource_metadata(opts \\ [])

@spec resource_metadata(keyword()) :: map()

The _meta of a UI resource: its Content Security Policy, permissions, sandbox domain, and border preference. Returns %{} when no option is given.

Options

  • :csp - keyword list of origin lists: :connect_domains (fetch, XHR, WebSocket), :resource_domains (scripts, images, styles, fonts), :frame_domains (nested iframes), and :base_uri_domains. Without it the host allows no external origins.
  • :permissions - list of :camera, :microphone, :geolocation, and :clipboard_write.
  • :domain - a dedicated sandbox origin, in the format the host documents.
  • :prefers_border - whether the host should draw a border and background.

supported?(context)

@spec supported?(Snodo.Context.t()) :: boolean()

Returns whether the client declared the extension with mime_type/0 in its mimeTypes.

tool_metadata(resource_uri, opts \\ [])

@spec tool_metadata(String.t(), keyword()) :: map()

The tool _meta that links a tool to the UI resource at resource_uri.

Options

  • :visibility - who may call the tool, a non-empty list of :model and :app. A tool with [:app] is hidden from the model and callable only from the UI. Omitted, hosts treat it as [:model, :app].