# `Snodo.Apps`
[🔗](https://github.com/joshrotenberg/snodo/blob/v0.5.0/lib/snodo/apps.ex#L1)

Shapes for the MCP Apps extension (`io.modelcontextprotocol/ui`,
specification 2026-01-26). MCP Apps is Stable. See
[Extension maturity](extensions.html#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`.

# `permission`

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

# `visibility`

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

# `client_capabilities`

```elixir
@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`

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

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

# `html`

```elixir
@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`

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

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

# `mime_type`

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

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

# `resource_metadata`

```elixir
@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?`

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

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

# `tool_metadata`

```elixir
@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]`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
