Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Align client, Apps, and integration docs (#4261)

Bill Easton3041aa241e96
diff --git a/docs/apps/architecture.mdx b/docs/apps/architecture.mdx
index 7ecab2aa3..4eaad9023 100644
--- a/docs/apps/architecture.mdx
+++ b/docs/apps/architecture.mdx
@@ -29,11 +29,9 @@ When you mark a tool with `app=True` or `@app.ui()`, FastMCP wires up the metada
### The `app=True` flag
-`app` on `@mcp.tool` accepts `True`, an `AppConfig`, or a dict. When you pass `True`, FastMCP checks whether the tool's return type is a Prefab type (`PrefabApp`, `Component`, or unions containing them). If it qualifies, FastMCP expands `True` into a full `AppConfig` β€” setting the renderer URI, CSP headers, and visibility β€” and stores it in the tool's `meta["ui"]` dict.
+`app` on `@mcp.tool` accepts `True`, an `AppConfig`, or a dict. When you pass `True`, FastMCP explicitly marks the tool as a Prefab UI tool and stamps placeholder UI metadata so the provider can synthesize the correct renderer resource later. When you omit `app`, FastMCP only applies this automatically if the tool's return type is a Prefab type (`PrefabApp`, `Component`, or unions containing them).
-This expansion also registers the shared Prefab renderer resource (below). The tool and the renderer are linked through a `resourceUri` field in the metadata: the tool says "render me with `ui://prefab/renderer.html`" and the host fetches that resource when it displays the result.
-
-Type inference works the same way. If the return type is a Prefab type and you haven't set `app` explicitly, FastMCP auto-wires the metadata as if you'd written `app=True`.
+The tool and renderer are linked through a `resourceUri` field in the metadata. Internally, registration uses the placeholder URI `ui://prefab/renderer.html`; when tools and resources are listed or read, FastMCP rewrites that placeholder to a per-tool URI like `ui://prefab/tool/<hash>/renderer.html` and synthesizes the matching renderer resource on demand.
### FastMCPApp registration
@@ -49,13 +47,13 @@ When a Prefab tool runs, its return value β€” a `PrefabApp` or a bare `Component
The entry point is `PrefabApp.to_json()`. It walks the component tree and produces a JSON object with three top-level keys: `view` (the component tree), `state` (initial state values), and `_meta` (routing metadata).
-FastMCP passes a `tool_resolver` callback to `to_json()`. Whenever the tree contains a `CallTool` action that references a function (not a string), the resolver converts it to a `ResolvedTool` with the function's registered name. This is how `CallTool(save_contact)` becomes `CallTool("save_contact")` on the wire. The resolver also handles `unwrap_result` β€” a flag telling the renderer to unwrap single-value results from the `{"result": value}` envelope FastMCP uses for schema compliance.
+FastMCP passes a `tool_resolver` callback to `to_json()`. Whenever the tree contains a `CallTool` action that references a function (not a string), the resolver converts it to a `ResolvedTool` with the function's registered name. For `FastMCPApp` backend tools, that registered name is then wrapped in the deterministic hashed format described below. The resolver also handles `unwrap_result` β€” a flag telling the renderer to unwrap single-value results from the `{"result": value}` envelope FastMCP uses for schema compliance.
-### The `_meta.fastmcp.app` tag
+### Hashed backend tool references
-After `to_json()` produces the tree, FastMCP injects `_meta.fastmcp.app` with the app's name (if the tool belongs to a `FastMCPApp`). This tag rides along inside `structuredContent` all the way to the renderer.
+FastMCP still tags app tools with `meta["fastmcp"]["app"]`, but backend routing no longer depends on sending the app name through each tool call. During serialization, FastMCP passes a resolver to `PrefabApp.to_json()`. When the tree contains `CallTool(save_contact)`, the resolver turns it into a deterministic hashed name such as `<hash>_save_contact`, where the hash is derived from the app name and backend tool name.
-When the renderer calls a backend tool, it includes `_meta.fastmcp.app` in the `CallTool` request. The server sees this tag and routes the call through a special path that bypasses transforms (below).
+That hashed name rides along inside `structuredContent` all the way to the renderer. When the renderer calls the backend tool, it sends the hashed tool name in the normal MCP `tools/call` request. The server recognizes that format and routes through the app-tool lookup path described below.
### ToolResult assembly
@@ -65,27 +63,27 @@ The final tool result has two parts: `content` (a list of `TextContent` blocks f
Normal tool calls go through the provider chain, which applies transforms (namespace prefixes, visibility filters) before resolving by name. App UI calls need a different path.
-### The `get_app_tool` bypass
+### The hashed lookup bypass
-Backend tools are typically hidden from the model (`visibility=["app"]`). Visibility transforms would filter them out of normal resolution. And namespace transforms might rename them β€” `save_contact` becomes `contacts_save_contact` β€” while the renderer still uses the original name.
+Backend tools are typically hidden from the model (`visibility=["app"]`). Visibility transforms would filter them out of normal resolution. And namespace transforms might rename them β€” `save_contact` becomes `contacts_save_contact` β€” while the renderer needs a stable way to call the original backend.
-`get_app_tool` solves both problems. When the server sees `_meta.fastmcp.app` on an incoming `CallTool` request, it calls `get_app_tool(app_name, tool_name)` instead of the normal `get_tool(name)`. This walks the provider tree directly, skipping transforms. It finds the tool by its original registered name and verifies that its `meta["fastmcp"]["app"]` matches the expected app.
+Hashed lookup solves both problems. FastMCP first tries normal tool resolution. If no visible tool matches and the requested name looks like `<hash>_<local_name>`, FastMCP calls `get_tool_by_hash(hash, local_name)`. That lookup walks the provider tree directly, skipping transforms. It finds an app-visible tool by its original registered name and verifies that its stored `meta["fastmcp"]["_tool_hash"]` matches the requested hash.
-That's why `CallTool("save_contact")` keeps working when the server is mounted under a namespace. The renderer sends the original name plus the app identity; the server uses `get_app_tool` to find it without transforms in the way.
+That's why `CallTool(save_contact)` keeps working when the server is mounted under a namespace. The renderer sends a deterministic hashed backend name; the server uses `get_tool_by_hash` to find the original tool without transforms in the way.
-Authorization still applies. `get_app_tool` bypasses transforms but runs auth checks against the tool's `auth` config before executing.
+Authorization still applies. The hashed bypass skips name and visibility transforms, but auth checks still run against the tool's `auth` config before execution.
### Provider delegation
-`get_app_tool` is defined on the `Provider` base class and overridden by aggregate and wrapped providers. Aggregate providers fan out the lookup across child providers in parallel. Wrapped providers (like `FastMCPProvider`, which wraps a nested `FastMCP` server) delegate to the inner server's `get_app_tool`. Backend tools are reachable through any depth of composition.
+`get_tool_by_hash` is defined on the `Provider` base class and overridden by aggregate and wrapped providers. Aggregate providers fan out the lookup across child providers in parallel. Wrapped providers (like `FastMCPProvider`, which wraps a nested `FastMCP` server) delegate to the inner server's hashed lookup. Backend tools are reachable through any depth of composition.
## The renderer
The Prefab renderer is a self-contained JavaScript application that interprets the JSON component tree and renders it as a React UI.
-### The shared resource
+### Renderer resources
-FastMCP registers the renderer as a `ui://prefab/renderer.html` resource with MIME type `text/html;profile=mcp-app`. The HTML is bundled inside the `prefab-ui` Python package; `get_renderer_html()` returns it as a string. All Prefab tools on a server share this single resource.
+FastMCP exposes the renderer through per-tool resources such as `ui://prefab/tool/<hash>/renderer.html`, each with MIME type `text/html;profile=mcp-app`. The HTML is bundled inside the `prefab-ui` Python package; `get_renderer_html()` returns it as a string. The resources are synthesized on demand from each tool's UI metadata, so CSP and permissions can differ per tool even though they use the same Prefab renderer.
The resource also carries CSP metadata (via `get_renderer_csp()`) declaring the CDN domains the renderer needs. Hosts use this to configure the iframe's Content Security Policy.
@@ -93,7 +91,7 @@ The resource also carries CSP metadata (via `get_renderer_csp()`) declaring the
The renderer lives in a sandboxed iframe and communicates with the host using `postMessage`. The protocol follows the [MCP Apps extension](https://modelcontextprotocol.io/docs/extensions/apps) spec:
-The host pushes the tool result (with `structuredContent`) into the iframe. The renderer parses the component tree, initializes state, and renders the UI. When the user interacts β€” submitting a form, clicking a button β€” and the interaction triggers a `CallTool` action, the renderer sends a `callServerTool` message back to the host via `postMessage`. The host forwards it as a regular MCP `tools/call` request to the server, including `_meta.fastmcp.app` for routing.
+The host pushes the tool result (with `structuredContent`) into the iframe. The renderer parses the component tree, initializes state, and renders the UI. When the user interacts β€” submitting a form, clicking a button β€” and the interaction triggers a `CallTool` action, the renderer sends a `callServerTool` message back to the host via `postMessage`. The host forwards it as a regular MCP `tools/call` request to the server, using the hashed backend name that FastMCP serialized into the action.
The response flows back the same way: server β†’ host β†’ iframe via `postMessage`, and the renderer updates state with the result.
diff --git a/docs/apps/development.mdx b/docs/apps/development.mdx
index 0d3a71ac7..f5c683d14 100644
--- a/docs/apps/development.mdx
+++ b/docs/apps/development.mdx
@@ -54,6 +54,8 @@ fastmcp dev apps server.py:mcp --mcp-port 9000 --dev-port 9090 --no-reload
| MCP Port | `--mcp-port` | `8000` | Port for your MCP server |
| Dev Port | `--dev-port` | `8080` | Port for the dev UI |
| Auto-Reload | `--reload` / `--no-reload` | On | Watch files and restart the server on changes |
+| Host | `--host` | `127.0.0.1` | Interface for both local servers to bind |
+| Log Panel | `--log-panel` / `--no-log-panel` | On | Show or hide the log panel in the dev UI |
## Multiple tools
diff --git a/docs/clients/client.mdx b/docs/clients/client.mdx
index a4141b71d..3d93b13ec 100644
--- a/docs/clients/client.mdx
+++ b/docs/clients/client.mdx
@@ -67,16 +67,21 @@ server = FastMCP("TestServer")
client = Client(server) # In-memory, no network or subprocess
```
-**STDIO transport** launches a server as a subprocess and communicates through stdin/stdout pipes. This is the standard mechanism used by desktop clients like Claude Desktop. The subprocess runs in an isolated environment, so you must explicitly pass any environment variables the server needs.
+**STDIO transport** launches a server as a subprocess and communicates through stdin/stdout pipes. This is the standard mechanism used by desktop clients like Claude Desktop. By default, the subprocess receives the MCP SDK's default environment; pass an explicit transport when you need to add environment variables, set a working directory, or control process reuse.
```python
from fastmcp import Client
+from fastmcp.client.transports import PythonStdioTransport
# Simple inference from file path
client = Client("my_server.py")
# With explicit environment configuration
-client = Client("my_server.py", env={"API_KEY": "secret"})
+transport = PythonStdioTransport(
+ "my_server.py",
+ env={"API_KEY": "secret"},
+)
+client = Client(transport)
```
**HTTP transport** connects to servers running as web services. Use this for production deployments where the server runs independently and manages its own lifecycle.
diff --git a/docs/clients/elicitation.mdx b/docs/clients/elicitation.mdx
index 840e426d2..06a6a4c57 100644
--- a/docs/clients/elicitation.mdx
+++ b/docs/clients/elicitation.mdx
@@ -30,8 +30,8 @@ async def elicitation_handler(
Args:
message: The prompt to display to the user
- response_type: Python dataclass type for the response (None if no data expected)
- params: Original MCP elicitation parameters including raw JSON schema
+ response_type: Python dataclass type for form responses (None for URL requests or empty schemas)
+ params: Original MCP elicitation parameters
context: Request context with metadata
Returns:
@@ -44,6 +44,11 @@ async def elicitation_handler(
if not user_input:
return ElicitResult(action="decline")
+ # URL requests and empty-object schemas have no response type to construct,
+ # so accepting is the whole response.
+ if response_type is None:
+ return ElicitResult(action="accept")
+
# Create response using the provided dataclass type
return response_type(value=user_input)
@@ -55,7 +60,7 @@ client = Client(
## How It Works
-When a server needs user input, it sends an elicitation request with a message prompt and a JSON schema describing the expected response structure. FastMCP automatically converts this schema into a Python dataclass type, making it easy to construct properly typed responses without manually parsing JSON schemas.
+When a server needs user input, it sends an elicitation request with a message prompt. Form elicitation requests include a JSON schema describing the expected response structure, and FastMCP automatically converts that schema into a Python dataclass type. URL elicitation requests and empty-object schemas use `response_type=None`.
The handler receives four parameters:
@@ -65,11 +70,11 @@ The handler receives four parameters:
</ResponseField>
<ResponseField name="response_type" type="type | None">
- A Python dataclass type that FastMCP created from the server's JSON schema. Use this to construct your response with proper typing. If the server requests an empty object, this will be `None`.
+ A Python dataclass type that FastMCP created from a form request's JSON schema. Use this to construct your response with proper typing. For URL requests or empty-object schemas, this will be `None`.
</ResponseField>
<ResponseField name="params" type="ElicitRequestParams">
- The original MCP elicitation parameters, including the raw JSON schema in `params.requested_schema`
+ The original MCP elicitation parameters. Form requests carry the raw JSON schema on `params.requested_schema`; URL requests carry `params.url` instead and have no schema.
</ResponseField>
<ResponseField name="context" type="RequestContext">
diff --git a/docs/clients/fastmcp-remote.mdx b/docs/clients/fastmcp-remote.mdx
index ee218afe0..dfc36a82b 100644
--- a/docs/clients/fastmcp-remote.mdx
+++ b/docs/clients/fastmcp-remote.mdx
@@ -56,7 +56,7 @@ Pass the full MCP endpoint URL for the remote server. Many FastMCP HTTP servers
`fastmcp-remote` starts a local stdio bridge, then connects to the upstream server when the MCP host initializes that bridge. If the upstream server is unavailable, the URL does not point to an MCP endpoint, or authentication cannot complete, initialization fails and the host should report the remote server as failed. After initialization succeeds, later tool, resource, prompt, and ping requests continue to proxy through the same remote server configuration.
-OAuth is enabled automatically for HTTPS servers. The first connection opens the browser-based OAuth flow when the server requires authentication, then stores tokens locally for future runs.
+OAuth is enabled automatically unless you provide an `Authorization` header or pass `--auth none`. The first connection opens the browser-based OAuth flow when the server requires authentication, then stores tokens locally for future runs.
To pass a bearer token or another custom header directly, provide `--header` in `Name: Value` form. The header name ends at the first colon, so values can contain additional colons. Quote the header when the value contains spaces, just like any other shell argument. An `Authorization` header disables OAuth by default:
diff --git a/docs/clients/logging.mdx b/docs/clients/logging.mdx
index eea9ff322..0fb9f735b 100644
--- a/docs/clients/logging.mdx
+++ b/docs/clients/logging.mdx
@@ -32,8 +32,19 @@ LOGGING_LEVEL_MAP = logging.getLevelNamesMapping()
async def log_handler(message: LogMessage):
"""Forward MCP server logs to Python's logging system."""
- msg = message.data.get('msg')
- extra = message.data.get('extra')
+ data = message.data
+ if isinstance(data, dict):
+ msg = data.get('msg', data)
+ extra = data.get('extra')
+ else:
+ msg = data
+ extra = None
+
+ # Python's logging requires `extra` to be a mapping, but a server can send
+ # any JSON value, so fold anything else into the message instead.
+ if extra is not None and not isinstance(extra, dict):
+ msg = f"{msg} ({extra})"
+ extra = None
level = LOGGING_LEVEL_MAP.get(message.level.upper(), logging.INFO)
logger.log(level, msg, extra=extra)
@@ -55,19 +66,20 @@ The handler receives a `LogMessage` object:
The logger name (may be None)
</ResponseField>
-<ResponseField name="data" type="dict">
- The log payload, containing `msg` and `extra` keys
+<ResponseField name="data" type="Any">
+ The JSON-serializable log payload sent by the server. FastMCP's structured logger uses a dictionary with `msg` and `extra` keys, but other MCP servers may send any JSON value.
</ResponseField>
</Card>
## Structured Logs
-The `message.data` attribute is a dictionary containing the log payload. This enables structured logging with rich contextual information.
+The `message.data` attribute contains the server's JSON-serializable log payload. FastMCP servers commonly send a dictionary with `msg` and `extra` keys, which enables structured logging with rich contextual information.
```python
async def detailed_log_handler(message: LogMessage):
- msg = message.data.get('msg')
- extra = message.data.get('extra')
+ data = message.data
+ msg = data.get('msg', data) if isinstance(data, dict) else data
+ extra = data.get('extra') if isinstance(data, dict) else None
if message.level == "error":
print(f"ERROR: {msg} | Details: {extra}")
diff --git a/docs/clients/notifications.mdx b/docs/clients/notifications.mdx
index aa7d47058..b9e8dc384 100644
--- a/docs/clients/notifications.mdx
+++ b/docs/clients/notifications.mdx
@@ -31,6 +31,8 @@ async def message_handler(message):
print("Resources have changed")
elif method == "notifications/prompts/list_changed":
print("Prompts have changed")
+ elif method == "notifications/resources/updated":
+ print("A resource was updated")
client = Client(
"my_mcp_server.py",
@@ -113,6 +115,18 @@ class MyMessageHandler(MessageHandler):
"""Called for progress updates during long-running operations."""
pass
+ async def on_resource_updated(
+ self, notification: mcp_types.ResourceUpdatedNotification
+ ) -> None:
+ """Called when a specific resource changes."""
+ pass
+
+ async def on_cancelled(
+ self, notification: mcp_types.CancelledNotification
+ ) -> None:
+ """Called when a request is cancelled."""
+ pass
+
async def on_logging_message(
self, notification: mcp_types.LoggingMessageNotification
) -> None:
diff --git a/docs/clients/prompts.mdx b/docs/clients/prompts.mdx
index 5d1bd7377..696488bb4 100644
--- a/docs/clients/prompts.mdx
+++ b/docs/clients/prompts.mdx
@@ -128,12 +128,12 @@ See [Metadata](/servers/versioning#version-discovery) for how to discover availa
## Multi-Server Clients
-When using multi-server clients, prompts are accessible directly without prefixing:
+When using multi-server clients, prompts are mounted with the server name as a prefix, just like tools:
```python
async with client: # Multi-server client
- result1 = await client.get_prompt("weather_prompt", {"city": "London"})
- result2 = await client.get_prompt("assistant_prompt", {"query": "help"})
+ result1 = await client.get_prompt("weather_weather_prompt", {"city": "London"})
+ result2 = await client.get_prompt("assistant_assistant_prompt", {"query": "help"})
```
## Raw Protocol Access
diff --git a/docs/clients/tasks.mdx b/docs/clients/tasks.mdx
index ce27520e4..630323167 100644
--- a/docs/clients/tasks.mdx
+++ b/docs/clients/tasks.mdx
@@ -64,12 +64,12 @@ Check the current status without blocking:
```python
status = await task.status()
print(f"{status.status}: {status.statusMessage}")
-# status.status is "working", "completed", "failed", or "cancelled"
+# status.status is "working", "input_required", "completed", "failed", or "cancelled"
```
### Waiting with Control
-Use `task.wait()` for more control over waiting:
+Use `task.wait()` for more control over waiting. With no `state`, it returns when the task leaves `working`; pass a specific state when you need to wait for a particular transition:
```python
# Wait up to 30 seconds for completion
@@ -116,7 +116,7 @@ def status_handler(status):
Args:
status: Task status object with:
- taskId: Unique task identifier
- - status: "working", "completed", "failed", or "cancelled"
+ - status: "working", "input_required", "completed", "failed", or "cancelled"
- statusMessage: Optional progress message from server
"""
if status.status == "working":
diff --git a/docs/clients/transports.mdx b/docs/clients/transports.mdx
index 44c70c217..2c8d20caa 100644
--- a/docs/clients/transports.mdx
+++ b/docs/clients/transports.mdx
@@ -16,7 +16,9 @@ Transports handle the underlying connection between your client and MCP servers.
STDIO transport communicates with MCP servers through subprocess pipes. When using STDIO, your client launches and manages the server process, controlling its lifecycle and environment.
<Warning>
-STDIO servers run in isolated environments by default. They do not inherit your shell's environment variables. You must explicitly pass any configuration the server needs.
+STDIO servers inherit only a small allowlist of environment variables β€” just enough to locate an interpreter and a home directory. Anything else in your shell, including API keys and other credentials, does not reach the server unless you pass it through `env` explicitly.
+
+The allowlist is platform-specific. On POSIX systems it is `HOME`, `LOGNAME`, `PATH`, `SHELL`, `TERM`, and `USER`; on Windows it is `APPDATA`, `HOMEDRIVE`, `HOMEPATH`, `LOCALAPPDATA`, `PATH`, `PATHEXT`, `PROCESSOR_ARCHITECTURE`, `SYSTEMDRIVE`, `SYSTEMROOT`, `TEMP`, `USERNAME`, and `USERPROFILE`.
</Warning>
```python
@@ -42,7 +44,7 @@ client = Client("my_server.py") # Limited - no configuration options
### Environment Variables
-Since STDIO servers do not inherit your environment, you need strategies for passing configuration.
+Values you pass through `env` are merged on top of the inherited allowlist, so you add configuration rather than replacing the base environment. Anything your server needs beyond those six variables has to be listed explicitly.
**Selective forwarding** passes only the variables your server needs:
@@ -63,7 +65,11 @@ client = Client(transport)
from dotenv import dotenv_values
from fastmcp.client.transports import StdioTransport
-env = dotenv_values(".env")
+env = {
+ key: value
+ for key, value in dotenv_values(".env").items()
+ if value is not None
+}
transport = StdioTransport(command="python", args=["server.py"], env=env)
client = Client(transport)
```
diff --git a/docs/integrations/auth0.mdx b/docs/integrations/auth0.mdx
index 6ca28b88c..7047ca850 100644
--- a/docs/integrations/auth0.mdx
+++ b/docs/integrations/auth0.mdx
@@ -182,7 +182,8 @@ async def main():
# Test the protected tool
result = await client.call_tool("get_token_info")
- print(f"Auth0 audience: {result['audience']}")
+ token_info = result.data
+ print(f"Auth0 audience: {token_info['audience']}")
if __name__ == "__main__":
asyncio.run(main())
diff --git a/docs/integrations/azure.mdx b/docs/integrations/azure.mdx
index ddcef6a2a..c683fbce4 100644
--- a/docs/integrations/azure.mdx
+++ b/docs/integrations/azure.mdx
@@ -223,8 +223,9 @@ async def main():
# Test the protected tool
result = await client.call_tool("get_user_info")
- print(f"Azure user: {result['email']}")
- print(f"Name: {result['name']}")
+ user_info = result.data
+ print(f"Azure user: {user_info['email']}")
+ print(f"Name: {user_info['name']}")
if __name__ == "__main__":
asyncio.run(main())
diff --git a/docs/integrations/claude-code.mdx b/docs/integrations/claude-code.mdx
index 8098ff51e..7addeaaad 100644
--- a/docs/integrations/claude-code.mdx
+++ b/docs/integrations/claude-code.mdx
@@ -118,7 +118,7 @@ fastmcp install claude-code server.py --project /path/to/my-project
If your server needs environment variables (like API keys), you must include them:
```bash
-fastmcp install claude-code server.py --server-name "Weather Server" \
+fastmcp install claude-code server.py --name "Weather Server" \
--env API_KEY=your-api-key \
--env DEBUG=true
```
@@ -126,7 +126,7 @@ fastmcp install claude-code server.py --server-name "Weather Server" \
Or load them from a `.env` file:
```bash
-fastmcp install claude-code server.py --server-name "Weather Server" --env-file .env
+fastmcp install claude-code server.py --name "Weather Server" --env-file .env
```
<Warning>
diff --git a/docs/integrations/claude-desktop.mdx b/docs/integrations/claude-desktop.mdx
index 4478bcc37..b0d1b5265 100644
--- a/docs/integrations/claude-desktop.mdx
+++ b/docs/integrations/claude-desktop.mdx
@@ -141,7 +141,7 @@ Claude Desktop runs servers in a completely isolated environment with no access
If your server needs environment variables (like API keys), you must include them:
```bash
-fastmcp install claude-desktop server.py --server-name "Weather Server" \
+fastmcp install claude-desktop server.py --name "Weather Server" \
--env API_KEY=your-api-key \
--env DEBUG=true
```
@@ -149,7 +149,7 @@ fastmcp install claude-desktop server.py --server-name "Weather Server" \
Or load them from a `.env` file:
```bash
-fastmcp install claude-desktop server.py --server-name "Weather Server" --env-file .env
+fastmcp install claude-desktop server.py --name "Weather Server" --env-file .env
```
<Warning>
- **`uv` must be installed and available in your system PATH**. Claude Desktop runs in its own isolated environment and needs `uv` to manage dependencies.
diff --git a/docs/integrations/cursor.mdx b/docs/integrations/cursor.mdx
index da0744ee0..787497b02 100644
--- a/docs/integrations/cursor.mdx
+++ b/docs/integrations/cursor.mdx
@@ -139,7 +139,7 @@ Cursor runs servers in a completely isolated environment with no access to your
If your server needs environment variables (like API keys), you must include them:
```bash
-fastmcp install cursor server.py --server-name "Weather Server" \
+fastmcp install cursor server.py --name "Weather Server" \
--env API_KEY=your-api-key \
--env DEBUG=true
```
@@ -147,7 +147,7 @@ fastmcp install cursor server.py --server-name "Weather Server" \
Or load them from a `.env` file:
```bash
-fastmcp install cursor server.py --server-name "Weather Server" --env-file .env
+fastmcp install cursor server.py --name "Weather Server" --env-file .env
```
<Warning>
@@ -164,10 +164,10 @@ You can generate MCP JSON configuration for manual use:
```bash
# Generate configuration and output to stdout
-fastmcp install mcp-json server.py --server-name "Dice Roller" --with pandas
+fastmcp install mcp-json server.py --name "Dice Roller" --with pandas
# Copy configuration to clipboard for easy pasting
-fastmcp install mcp-json server.py --server-name "Dice Roller" --copy
+fastmcp install mcp-json server.py --name "Dice Roller" --copy
```
This generates the standard `mcpServers` configuration format that can be used with any MCP-compatible client.
diff --git a/docs/integrations/descope.mdx b/docs/integrations/descope.mdx
index 33786b6e2..7b00cd3e1 100644
--- a/docs/integrations/descope.mdx
+++ b/docs/integrations/descope.mdx
@@ -18,7 +18,7 @@ This guide shows you how to secure your FastMCP server using [**Descope**](https
Before you begin, you will need:
1. To [sign up](https://www.descope.com/sign-up) for a Free Forever Descope account
-2. Your FastMCP server's URL (can be localhost for development, e.g., `http://localhost:3000`)
+2. Your FastMCP server's URL (can be localhost for development, e.g., `http://localhost:8000`)
### Step 1: Configure Descope
@@ -55,21 +55,26 @@ Create a `.env` file with your Descope configuration:
```bash
DESCOPE_CONFIG_URL=https://api.descope.com/v1/apps/P.../.well-known/openid-configuration
-SERVER_URL=http://localhost:3000 # Your server's base URL
+BASE_URL=http://localhost:8000
```
### Step 3: FastMCP Configuration
-Create your FastMCP server file and use the DescopeProvider to handle all the OAuth integration automatically:
+Create your FastMCP server file and use the DescopeProvider to handle all the OAuth integration automatically. Nothing reads `.env` automatically, so load it explicitly with [python-dotenv](https://pypi.org/project/python-dotenv/) (`pip install python-dotenv`) before constructing the provider β€” otherwise the values you just wrote stay invisible to `os.environ`.
```python server.py
+import os
+
+from dotenv import load_dotenv
from fastmcp import FastMCP
from fastmcp.server.auth.providers.descope import DescopeProvider
+load_dotenv()
+
# DescopeProvider accepts either supported Well-Known URL format.
auth_provider = DescopeProvider(
- config_url="https://api.descope.com/v1/apps/P.../.well-known/openid-configuration",
- base_url="https://your-fastmcp-server.com",
+ config_url=os.environ["DESCOPE_CONFIG_URL"],
+ base_url=os.environ.get("BASE_URL", "http://localhost:8000"),
)
# Create FastMCP server with auth
diff --git a/docs/integrations/discord.mdx b/docs/integrations/discord.mdx
index 5d6c643b7..43586d578 100644
--- a/docs/integrations/discord.mdx
+++ b/docs/integrations/discord.mdx
@@ -108,7 +108,8 @@ async def main():
print("βœ“ Authenticated with Discord!")
result = await client.call_tool("get_user_info")
- print(f"Discord user: {result['username']}")
+ user_info = result.data
+ print(f"Discord user: {user_info['username']}")
if __name__ == "__main__":
asyncio.run(main())
diff --git a/docs/integrations/gemini-cli.mdx b/docs/integrations/gemini-cli.mdx
index 10613fb1b..86d35b20b 100644
--- a/docs/integrations/gemini-cli.mdx
+++ b/docs/integrations/gemini-cli.mdx
@@ -118,7 +118,7 @@ fastmcp install gemini-cli server.py --project /path/to/my-project
If your server needs environment variables (like API keys), you must include them:
```bash
-fastmcp install gemini-cli server.py --server-name "Weather Server" \
+fastmcp install gemini-cli server.py --name "Weather Server" \
--env API_KEY=your-api-key \
--env DEBUG=true
```
@@ -126,7 +126,7 @@ fastmcp install gemini-cli server.py --server-name "Weather Server" \
Or load them from a `.env` file:
```bash
-fastmcp install gemini-cli server.py --server-name "Weather Server" --env-file .env
+fastmcp install gemini-cli server.py --name "Weather Server" --env-file .env
```
<Warning>
diff --git a/docs/integrations/google.mdx b/docs/integrations/google.mdx
index 17d49d12f..141444080 100644
--- a/docs/integrations/google.mdx
+++ b/docs/integrations/google.mdx
@@ -130,8 +130,9 @@ async def main():
# Test the protected tool
result = await client.call_tool("get_user_info")
- print(f"Google user: {result['email']}")
- print(f"Name: {result['name']}")
+ user_info = result.data
+ print(f"Google user: {user_info['email']}")
+ print(f"Name: {user_info['name']}")
if __name__ == "__main__":
asyncio.run(main())
diff --git a/docs/integrations/oci.mdx b/docs/integrations/oci.mdx
index 02fa36dae..72165238d 100644
--- a/docs/integrations/oci.mdx
+++ b/docs/integrations/oci.mdx
@@ -75,7 +75,7 @@ Follow the Steps as mentioned below to create an OAuth client.
Click on "Edit OAuth configuration" button.
Configure the application as OAuth client by selecting "Configure this application as a client now" radio button.
Select "Authorization code" grant type. If you are planning to use the same OAuth client application for token exchange, select "Client credentials" grant type as well. In the sample, we will use the same client.
- For Authorization grant type, select redirect URL. In most cases, this will be the MCP server URL followed by "/oauth/callback".
+ For Authorization grant type, select redirect URL. In most cases, this will be the MCP server URL followed by "/auth/callback".
<Frame>
<img src="/integrations/images/oci/ocioauthconfiguration.png" alt="OAuth Configuration for an Integrated Application in OCI IAM Domain" />
diff --git a/docs/integrations/openapi.mdx b/docs/integrations/openapi.mdx
index d2826aa03..f6fb1a13f 100644
--- a/docs/integrations/openapi.mdx
+++ b/docs/integrations/openapi.mdx
@@ -62,9 +62,8 @@ api_client = httpx2.AsyncClient(
# Create MCP server with authenticated client
mcp = FastMCP.from_openapi(
- openapi_spec=spec,
+ openapi_spec=spec,
client=api_client,
- timeout=30.0 # 30 second timeout for all requests
)
```
@@ -404,7 +403,7 @@ FastMCP intelligently handles different types of parameters in OpenAPI requests:
### Query Parameters
-By default, FastMCP only includes query parameters that have non-empty values. Parameters with `None` values or empty strings are automatically filtered out.
+By default, FastMCP skips parameters whose value is `None`. Empty strings are still sent as empty query values, which is useful for APIs that distinguish between an omitted parameter and an explicitly blank one.
```python
# When calling this tool...
@@ -412,10 +411,10 @@ await client.call_tool("search_products", {
"category": "electronics", # βœ… Included
"min_price": 100, # βœ… Included
"max_price": None, # ❌ Excluded
- "brand": "", # ❌ Excluded
+ "brand": "", # βœ… Included as an empty value
})
-# The HTTP request will be: GET /products?category=electronics&min_price=100
+# The HTTP request will be: GET /products?category=electronics&min_price=100&brand=
```
### Path Parameters
diff --git a/docs/integrations/scalekit.mdx b/docs/integrations/scalekit.mdx
index 2b2fa9d10..ac04b46df 100644
--- a/docs/integrations/scalekit.mdx
+++ b/docs/integrations/scalekit.mdx
@@ -28,12 +28,12 @@ In your Scalekit dashboard:
2. Enter server details: a name, a resource identifier, and the desired MCP client authentication settings
3. Save, then copy the **Resource ID** (for example, res_92015146095)
-In your FastMCP project's `.env`:
+Record these values in a `.env` file in your FastMCP project:
-```sh
-SCALEKIT_ENVIRONMENT_URL=<YOUR_APP_ENVIRONMENT_URL>
-SCALEKIT_RESOURCE_ID=<YOUR_APP_RESOURCE_ID> # res_926EXAMPLE5878
-BASE_URL=http://localhost:8000/
+```sh .env
+SCALEKIT_ENVIRONMENT_URL=https://your-env.scalekit.com
+SCALEKIT_RESOURCE_ID=res_926EXAMPLE5878
+BASE_URL=http://localhost:8000
# Optional: additional scopes tokens must have
# SCALEKIT_REQUIRED_SCOPES=read,write
```
@@ -43,20 +43,25 @@ BASE_URL=http://localhost:8000/
### Step 2: Add auth to FastMCP server
-Create your FastMCP server file and use the ScalekitProvider to handle all the OAuth integration automatically:
+Create your FastMCP server file and use the ScalekitProvider to handle all the OAuth integration automatically. Nothing reads `.env` automatically, so load it explicitly with [python-dotenv](https://pypi.org/project/python-dotenv/) (`pip install python-dotenv`) before constructing the provider.
> **Warning:** The legacy `mcp_url` and `client_id` parameters are deprecated and will be removed in a future release. Use `base_url` instead of `mcp_url` and remove `client_id` from your configuration.
```python server.py
+import os
+
+from dotenv import load_dotenv
from fastmcp import FastMCP
from fastmcp.server.auth.providers.scalekit import ScalekitProvider
-# Discovers Scalekit endpoints and set up JWT token validation
+load_dotenv()
+
+# Discovers Scalekit endpoints and sets up JWT token validation
auth_provider = ScalekitProvider(
- environment_url=SCALEKIT_ENVIRONMENT_URL, # Scalekit environment URL
- resource_id=SCALEKIT_RESOURCE_ID, # Resource server ID
- base_url=SERVER_URL, # Public MCP endpoint
- required_scopes=["read"], # Optional scope enforcement
+ environment_url=os.environ["SCALEKIT_ENVIRONMENT_URL"], # Scalekit environment URL
+ resource_id=os.environ["SCALEKIT_RESOURCE_ID"], # Resource server ID
+ base_url=os.environ.get("BASE_URL", "http://localhost:8000"),
+ required_scopes=["read"], # Optional scope enforcement
)
# Create FastMCP server with auth
@@ -86,7 +91,7 @@ Set `required_scopes` when you need tokens to carry specific permissions. Leave
uv run python server.py
```
-Use any MCP client (for example, mcp-inspector, Claude, VS Code, or Windsurf) to connect to the running serve. Verify that authentication succeeds and requests are authorized as expected.
+Use any MCP client (for example, mcp-inspector, Claude, VS Code, or Windsurf) to connect to the running server. Verify that authentication succeeds and requests are authorized as expected.
## Production Configuration
@@ -99,8 +104,8 @@ from fastmcp.server.auth.providers.scalekit import ScalekitProvider
# Load configuration from environment variables
auth = ScalekitProvider(
- environment_url=os.environ.get("SCALEKIT_ENVIRONMENT_URL"),
- resource_id=os.environ.get("SCALEKIT_RESOURCE_ID"),
+ environment_url=os.environ["SCALEKIT_ENVIRONMENT_URL"],
+ resource_id=os.environ["SCALEKIT_RESOURCE_ID"],
base_url=os.environ.get("BASE_URL", "https://your-server.com")
)
diff --git a/docs/integrations/supabase.mdx b/docs/integrations/supabase.mdx
index 9ffda444d..d39696da7 100644
--- a/docs/integrations/supabase.mdx
+++ b/docs/integrations/supabase.mdx
@@ -30,7 +30,8 @@ Before you begin, you will need:
2. **OAuth Server enabled** in your Supabase Dashboard (Authentication β†’ OAuth Server)
3. **Dynamic Client Registration enabled** in the same settings
4. A **consent UI** hosted at your configured authorization path (see above)
-5. Your FastMCP server's URL (can be localhost for development, e.g., `http://localhost:8000`)
+5. Your Supabase Auth JWT signing algorithm. `SupabaseProvider` defaults to `ES256`; set `algorithm="RS256"` if your project is configured for RSA signing.
+6. Your FastMCP server's URL (can be localhost for development, e.g., `http://localhost:8000`)
### Step 1: Enable Supabase OAuth Server
@@ -58,6 +59,7 @@ from fastmcp.server.auth.providers.supabase import SupabaseProvider
auth = SupabaseProvider(
project_url="https://abc123.supabase.co",
base_url="http://localhost:8000",
+ algorithm="ES256", # Match your Supabase Auth JWT signing algorithm
)
mcp = FastMCP("Supabase Protected Server", auth=auth)
@@ -117,6 +119,7 @@ from fastmcp.server.auth.providers.supabase import SupabaseProvider
auth = SupabaseProvider(
project_url=os.environ["SUPABASE_PROJECT_URL"],
base_url=os.environ.get("BASE_URL", "https://your-server.com"),
+ algorithm=os.environ.get("SUPABASE_JWT_ALGORITHM", "ES256"),
)
mcp = FastMCP(name="Supabase Secured App", auth=auth)