Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/python-sdk-pages.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
"python-sdk/fastmcp-apps",
"python-sdk/fastmcp-cli",
"python-sdk/fastmcp-client",
"python-sdk/fastmcp-decorators",
Expand All @@ -13,6 +12,19 @@
"python-sdk/fastmcp-telemetry",
"python-sdk/fastmcp-tools",
"python-sdk/fastmcp-types",
{
"group": "fastmcp.apps",
"pages": [
"python-sdk/fastmcp-apps-__init__",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the existing apps SDK reference slug

Replacing the former python-sdk/fastmcp-apps page with only python-sdk/fastmcp-apps-__init__ means the already-published /python-sdk/fastmcp-apps URL no longer has a backing MDX file or redirect; I searched the docs config for fastmcp-apps and only the new slug remains. Any external links or bookmarks to the package reference will 404 unless the old page is kept or a redirect is added.

Useful? React with 👍 / 👎.

"python-sdk/fastmcp-apps-app",
"python-sdk/fastmcp-apps-approval",
"python-sdk/fastmcp-apps-choice",
"python-sdk/fastmcp-apps-config",
"python-sdk/fastmcp-apps-file_upload",
"python-sdk/fastmcp-apps-form",
"python-sdk/fastmcp-apps-generative"
]
},
{
"group": "fastmcp.experimental",
"pages": [
Expand All @@ -39,6 +51,7 @@
"python-sdk/fastmcp-utilities-__init__",
"python-sdk/fastmcp-utilities-async_utils",
"python-sdk/fastmcp-utilities-auth",
"python-sdk/fastmcp-utilities-authorization",
"python-sdk/fastmcp-utilities-cli",
"python-sdk/fastmcp-utilities-components",
"python-sdk/fastmcp-utilities-docstring_parsing",
Expand Down Expand Up @@ -82,6 +95,7 @@
"python-sdk/fastmcp-utilities-openapi",
"python-sdk/fastmcp-utilities-pagination",
"python-sdk/fastmcp-utilities-skills",
"python-sdk/fastmcp-utilities-tasks",
"python-sdk/fastmcp-utilities-tests",
"python-sdk/fastmcp-utilities-timeout",
"python-sdk/fastmcp-utilities-token_cache",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: apps
sidebarTitle: apps
title: __init__
sidebarTitle: __init__
---

# `fastmcp.apps`
Expand Down
146 changes: 146 additions & 0 deletions docs/python-sdk/fastmcp-apps-app.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
title: app
sidebarTitle: app
---

# `fastmcp.apps.app`


FastMCPApp — a Provider that represents a composable MCP application.

FastMCPApp binds entry-point tools (model calls these) together with backend
tools (the UI calls these via CallTool). Backend tools are tagged with
``meta["fastmcp"]["app"]`` so they can be found through the provider chain
even when transforms (namespace, visibility, etc.) have renamed or hidden
them — the server sets a context var that tells ``Provider.get_tool`` to
fall back to a direct lookup for app-visible tools.

Usage::

from fastmcp import FastMCP, FastMCPApp

app = FastMCPApp("Dashboard")

@app.ui()
def show_dashboard() -> Component:
return Column(...)

@app.tool()
def save_contact(name: str, email: str) -> str:
return name

server = FastMCP("Platform")
server.add_provider(app)


## Classes

### `FastMCPApp` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py#L144" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


A Provider that represents an MCP application.

Binds together entry-point tools (``@app.ui``), backend tools
(``@app.tool``), and the Prefab renderer resource. Backend tools
are tagged with ``meta["fastmcp"]["app"]`` so ``Provider.get_tool``
can find them by original name even when transforms have been applied.


**Methods:**

#### `tool` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py#L168" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
tool(self, name_or_fn: F) -> F
```

#### `tool` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py#L180" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
tool(self, name_or_fn: str | None = None) -> Callable[[F], F]
```

#### `tool` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py#L191" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
tool(self, name_or_fn: str | AnyFunction | None = None) -> Any
```

Register a backend tool that the UI calls via CallTool.

Backend tools default to ``visibility=["app"]``. Pass ``model=True``
to also expose the tool to the model (``visibility=["app", "model"]``).

Supports multiple calling patterns::

@app.tool
def save(name: str): ...

@app.tool()
def save(name: str): ...

@app.tool("custom_name")
def save(name: str): ...


#### `ui` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py#L258" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
ui(self, name_or_fn: F) -> F
```

#### `ui` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py#L273" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
ui(self, name_or_fn: str | None = None) -> Callable[[F], F]
```

#### `ui` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py#L287" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
ui(self, name_or_fn: str | AnyFunction | None = None) -> Any
```

Register a UI entry-point tool that the model calls.

Entry-point tools default to ``visibility=["model"]`` and auto-wire
the Prefab renderer resource and CSP. They are tagged with the app
name so structured content includes ``_meta.fastmcp.app``.

Supports multiple calling patterns::

@app.ui
def dashboard() -> Component: ...

@app.ui()
def dashboard() -> Component: ...

@app.ui("my_dashboard")
def dashboard() -> Component: ...


#### `add_tool` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py#L362" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
add_tool(self, tool: Tool | Callable[..., Any]) -> Tool
```

Add a tool to this app programmatically.

The tool is tagged with this app's name for routing.


#### `lifespan` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py#L418" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
lifespan(self) -> AsyncIterator[None]
```

#### `run` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/app.py#L426" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
run(self, transport: Literal['stdio', 'http', 'sse', 'streamable-http'] | None = None, **kwargs: Any) -> None
```

Create a temporary FastMCP server and run this app standalone.

58 changes: 58 additions & 0 deletions docs/python-sdk/fastmcp-apps-approval.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: approval
sidebarTitle: approval
---

# `fastmcp.apps.approval`


Approval — a Provider that adds human-in-the-loop approval to any server.

The LLM presents a summary of what it's about to do, and the user
approves or rejects via buttons. The result is sent back into the
conversation as a message, prompting the LLM's next turn.

Requires ``fastmcp[apps]`` (prefab-ui).

Usage::

from fastmcp import FastMCP
from fastmcp.apps.approval import Approval

mcp = FastMCP("My Server")
mcp.add_provider(Approval())


## Classes

### `Approval` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/approval.py#L49" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


A Provider that adds human-in-the-loop approval to a server.

The LLM calls the ``request_approval`` tool with a summary and
optional details. The user sees an approval card with Approve and
Reject buttons. Clicking either sends a message back into the
conversation (via ``SendMessage``), triggering the LLM's next turn.

The message appears as if the user sent it, so the LLM sees
something like ``'"Deploy v3.2 to production" is APPROVED'``.

Example::

from fastmcp import FastMCP
from fastmcp.apps.approval import Approval

mcp = FastMCP("My Server")
mcp.add_provider(Approval())

Customized::

Approval(
title="Deploy Gate",
approve_text="Ship it",
approve_variant="default",
reject_text="Abort",
reject_variant="destructive",
)

44 changes: 44 additions & 0 deletions docs/python-sdk/fastmcp-apps-choice.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: choice
sidebarTitle: choice
---

# `fastmcp.apps.choice`


Choice — a Provider that lets the user pick from a set of options.

The LLM presents options, the user clicks one, and the selection
flows back into the conversation as a message.

Requires ``fastmcp[apps]`` (prefab-ui).

Usage::

from fastmcp import FastMCP
from fastmcp.apps.choice import Choice

mcp = FastMCP("My Server")
mcp.add_provider(Choice())


## Classes

### `Choice` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/choice.py#L46" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


A Provider that lets the user choose from a set of options.

The LLM calls ``choose`` with a prompt and a list of options.
The user sees a card with one button per option. Clicking a button
sends the selection back into the conversation via ``SendMessage``,
triggering the LLM's next turn.

Example::

from fastmcp import FastMCP
from fastmcp.apps.choice import Choice

mcp = FastMCP("My Server")
mcp.add_provider(Choice())

90 changes: 90 additions & 0 deletions docs/python-sdk/fastmcp-apps-config.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: config
sidebarTitle: 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 carry
UI 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#L173" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
app_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"]``.


## Classes

### `ResourceCSP` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/config.py#L20" 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 or
load 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#L52" 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 host
grant the corresponding Permission Policy feature to the sandboxed
iframe. Hosts MAY honour these; apps should use JS feature detection
as a fallback.


### `AppConfig` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/apps/config.py#L79" 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 resource
to render and where the tool appears. On resources, those fields must
be left unset (the resource itself is the UI).

All fields use ``exclude_none`` serialization so only explicitly-set
values 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#L117" 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 renderer
URI and merges the renderer's CSP with any additional domains you
specify. 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#L133" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
model_post_init(self, __context: Any) -> None
```
Loading
Loading