You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: move transport-specific parameters from FastMCP constructor to run()
Transport-specific parameters like `host`, `port`, `json_response`, `stateless_http`,
`event_store`, `retry_interval`, `sse_path`, `message_path`, `streamable_http_path`,
and `transport_security` no longer belong in the FastMCP constructor since they are
irrelevant when using stdio transport.
These parameters are now passed to `run()`, `sse_app()`, or `streamable_http_app()`
depending on the transport being used. The `run()` method uses `@overload` decorators
to provide proper type hints for each transport type.
DNS rebinding auto-configuration logic has been moved from the constructor to
`sse_app()` and `streamable_http_app()` methods where it can use the actual host
parameter.
BREAKING CHANGE: Transport-specific parameters must now be passed to run() or
the transport app methods instead of the FastMCP constructor.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/migration.md
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,63 @@ The `mount_path` parameter has been removed from `FastMCP.__init__()`, `FastMCP.
122
122
123
123
This parameter was redundant because the SSE transport already handles sub-path mounting via ASGI's standard `root_path` mechanism. When using Starlette's `Mount("/path", app=mcp.sse_app())`, Starlette automatically sets `root_path` in the ASGI scope, and the `SseServerTransport` uses this to construct the correct message endpoint path.
124
124
125
+
### Transport-specific parameters moved from FastMCP constructor to run()/app methods
126
+
127
+
Transport-specific parameters have been moved from the `FastMCP` constructor to the `run()`, `sse_app()`, and `streamable_http_app()` methods. This provides better separation of concerns - the constructor now only handles server identity and authentication, while transport configuration is passed when starting the server.
**Note:** DNS rebinding protection is automatically enabled when `host` is `127.0.0.1`, `localhost`, or `::1`. This now happens in `sse_app()` and `streamable_http_app()` instead of the constructor.
181
+
125
182
### Resource URI type changed from `AnyUrl` to `str`
126
183
127
184
The `uri` field on resource-related types now uses `str` instead of Pydantic's `AnyUrl`. This aligns with the [MCP specification schema](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/draft/schema.ts) which defines URIs as plain strings (`uri: string`) without strict URL validation. This change allows relative paths like `users/me` that were previously rejected.
0 commit comments