Metadata for the MCP Apps extension (io.modelcontextprotocol/ui).
MCP Apps allow servers to deliver interactive HTML user interfaces that render inside MCP hosts as sandboxed iframes. This module encapsulates the UI metadata for both tools (linking to a UI resource) and resources (CSP, permissions, sandbox configuration).
Summary
Functions
Build a %Phantom.UI{} from a keyword list or map.
Returns true if the tool should appear in tools/list (visible to the model).
Produce the _meta map for a resource's JSON representation.
Produce the _meta map for a tool's JSON representation.
Types
@type t() :: %Phantom.UI{ base_uri_domains: [String.t()] | nil, connect_domains: [String.t()] | nil, domain: String.t() | nil, frame_domains: [String.t()] | nil, permissions: [atom()] | nil, prefers_border: boolean() | nil, resource_domains: [String.t()] | nil, resource_uri: String.t() | nil, visibility: [visibility()] }
@type visibility() :: :model | :app
Functions
Build a %Phantom.UI{} from a keyword list or map.
Returns nil if no UI-related attributes are present.
Raises ArgumentError if visibility contains unknown values.
Valid visibility values are :model and :app.
@spec model_visible?(Phantom.Tool.t()) :: boolean()
Returns true if the tool should appear in tools/list (visible to the model).
Tools without UI metadata are always visible. Tools with UI are visible
when their visibility list includes :model.
Produce the _meta map for a resource's JSON representation.
Includes CSP domains, permissions, domain, and border preference.
Returns nil when no resource-side metadata is present.
Produce the _meta map for a tool's JSON representation.
Returns nil when no UI is configured, which gets stripped by remove_nils.
Visibility atoms are serialized to strings for the JSON wire format.