Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122---title: configsidebarTitle: config---
# `fastmcp.apps.config`
MCP Apps support — extension negotiation and typed UI metadata models.
Provides constants and Pydantic models for the MCP Apps extension(io.modelcontextprotocol/ui), enabling tools and resources to carryUI metadata for clients that support interactive app rendering.
## Functions
### `app_config_to_meta_dict` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/config.py#L190" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonapp_config_to_meta_dict(app: AppConfig | dict[str, Any]) -> dict[str, Any]```
Convert an AppConfig or dict to the wire-format dict for ``meta["ui"]``.
### `is_model_visible` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/config.py#L197" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonis_model_visible(component: FastMCPComponent) -> bool```
Whether a component belongs on model-facing discovery and proxy surfaces.
This is audience filtering, not authorization. Direct MCP calls do notuse this predicate and cannot identify model versus app callers.
Visibility is a declaration, and the MCP Apps spec puts the filtering onthe host — so ``tools/list`` carries app-only tools and the host keepsthem from the model. That division only works where a host stands betweenthe server and the model.
It does not hold for surfaces a server drives itself. A search result ora code-mode catalog reaches the model as ordinary tool output, and acall-tool proxy invokes on a name the model supplies; nothing downstreamcan filter either. Those surfaces have to apply the declaration here.
A component with no ``visibility`` is visible: the field marks theexception, and the spec's default is both audiences.
## Classes
### `ResourceCSP` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/config.py#L21" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
Content Security Policy for MCP App resources.
Declares which external origins the app is allowed to connect to orload resources from. Hosts use these declarations to build the``Content-Security-Policy`` header for the sandboxed iframe.
### `ResourcePermissions` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/config.py#L57" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
Iframe sandbox permissions for MCP App resources.
Each field, when set (typically to ``{}``), requests that the hostgrant the corresponding Permission Policy feature to the sandboxediframe. Hosts MAY honour these; apps should use JS feature detectionas a fallback.
### `AppConfig` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/config.py#L85" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
Configuration for MCP App tools and resources.
Controls how a tool or resource participates in the MCP Apps extension.On tools, ``resource_uri`` and ``visibility`` specify which UI resourceto render and where the tool appears. On resources, those fields mustbe left unset (the resource itself is the UI).
`visibility` declares the intended audience; it is not a security boundary.Direct MCP calls remain subject to authentication and authorization,regardless of visibility. The server cannot distinguish model and appcallers on the same connection.
All fields use ``exclude_none`` serialization so only explicitly-setvalues appear on the wire. Aliases match the MCP Apps wire format(camelCase).
### `PrefabAppConfig` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/config.py#L134" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
App configuration for Prefab tools with sensible defaults.
Like ``app=True`` but customizable. Auto-wires the Prefab rendererURI and merges the renderer's CSP with any additional domains youspecify. The renderer resource is registered automatically.
Example::
@mcp.tool(app=PrefabAppConfig()) # same as app=True
@mcp.tool(app=PrefabAppConfig( csp=ResourceCSP(frame_domains=["https://example.com"]), ))
**Methods:**
#### `model_post_init` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/config.py#L150" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonmodel_post_init(self, __context: Any) -> None```