Remove 3.0-deprecated FastMCP server methods - #4451
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e75e563514
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ``` | ||
|
|
||
| **FastMCP.as_proxy() → create_proxy()** | ||
| **FastMCP.as_proxy() → create_proxy()** (Removed in v4) |
There was a problem hiding this comment.
Document the
backend keyword migration
For users who called the removed method with its public keyword, e.g. FastMCP.as_proxy(backend=client, name=...), this replacement is incomplete: create_proxy requires target, so a mechanical replacement to create_proxy(backend=client, name=...) raises a missing-argument TypeError. Please either document that backend must become the first positional argument/target, or accept backend as an alias in create_proxy so the advertised migration works.
Useful? React with 👍 / 👎.
Removes deprecations that shipped replacements in 3.0:
- FastMCP.as_proxy() classmethod -> create_proxy()
- import_server() -> mount()
- mount(prefix=) -> namespace=
- mount(as_proxy=) -> now meaningless; mounts always invoke lifespan/middleware
- add_tool_transformation() -> add_transform(ToolTransform({...}))
- remove_tool_transformation() -> pure no-op that warned callers it had no
effect; removed entirely
- FastMCP.remove_tool() -> mcp.local_provider.remove_tool()
Also drops the now-unused URI_PATTERN/re import and FastMCPDeprecationWarning
import. The _REMOVED_KWARGS TypeError shim is retained.
Replaces FastMCP.as_proxy() helper calls with create_proxy(), rewrites the mount() as_proxy=/prefix= kwarg tests to plain mount() (the params are gone), and deletes deprecation-only tests for as_proxy() and remove_tool().
…gister Annotates the v2->v3 upgrade guide's deprecated server methods as removed in v4, and adds a Removed in 4.0 section to the change register.
debf712 to
da57546
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da5754671b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ## Removed in 4.0 | ||
|
|
||
| A streamable-HTTP session is now bound to the credential that created it. Once the session manager owns the server lifecycle (its `run()` drives FastMCP's lifespan through `_lifespan_proxy`), the SDK's `_session_owners` map is populated on session creation and checked on every subsequent request: a request that presents a *different* credential for an existing `Mcp-Session-Id` is answered with 404, exactly as if the session did not exist. This closes a gap where a leaked session id was usable by any bearer — before this, any valid token could drive someone else's session. Identity is the `(client_id, issuer, subject)` triple the token verifier supplies; components it does not populate degrade out of the comparison. | ||
| Deprecations that warned in 3.x are removed in 4.0. Each entry below is a hard removal — the old surface raises `TypeError` / `AttributeError` rather than warning, unless noted otherwise. |
There was a problem hiding this comment.
Keep v4 removal notes to completed removals
This section says every entry below is a hard removal, but the current tree still contains working shims/parameters listed below: fastmcp_slim/fastmcp/server/proxy.py and server/openapi/ still re-export with warnings, StreamableHttpTransport.__init__ still accepts sse_read_timeout, and tools/base.py/function_tool.py still accept serializer/exclude_args. If these docs ship with this PR, users will be told APIs are gone when they still only warn; either land the matching deletions or scope this section to the FastMCP server methods actually removed here.
Useful? React with 👍 / 👎.
Resolves an import conflict with the merged as_proxy removal (#4451) by keeping both new imports, and fixes a second stale-API bug this surfaced: the example indexed call_tool()'s CallToolResult like a raw list instead of reading .content.
Second batch of FastMCP 4.0 deprecation removals: the
FastMCPserver methods deprecated at 3.0 with replacements long shipped. Removed:FastMCP.as_proxy()(→create_proxy()),import_server()(→mount()), themount(prefix=...)andmount(as_proxy=...)parameters (→namespace=/ plainmount()),add_tool_transformation()/remove_tool_transformation()(→add_transform(ToolTransform(...))— the removal half was already a pure no-op that only warned), andFastMCP.remove_tool()(→local_provider.remove_tool()).All live call-sites in tests and examples were repointed to the replacements, the deprecation-only test files are gone (including 714 lines pinning
import_server), and the upgrade guide marks each item removed-in-4.0 with its migration path. The_REMOVED_KWARGShelper that turns removed 2.x constructor kwargs into guidedTypeErrors is deliberately kept — it's cheap and pays off for anyone jumping versions.Net: +181 / −1,258.
Labels: breaking change, v4.