Skip to content

Remove 3.0-deprecated FastMCP server methods - #4451

Merged
jlowin merged 5 commits into
mainfrom
remove/server-method-deprecations
Jul 7, 2026
Merged

Remove 3.0-deprecated FastMCP server methods#4451
jlowin merged 5 commits into
mainfrom
remove/server-method-deprecations

Conversation

@jlowin

@jlowin jlowin commented Jul 7, 2026

Copy link
Copy Markdown
Member

Second batch of FastMCP 4.0 deprecation removals: the FastMCP server methods deprecated at 3.0 with replacements long shipped. Removed: FastMCP.as_proxy() (→ create_proxy()), import_server() (→ mount()), the mount(prefix=...) and mount(as_proxy=...) parameters (→ namespace= / plain mount()), add_tool_transformation()/remove_tool_transformation() (→ add_transform(ToolTransform(...)) — the removal half was already a pure no-op that only warned), and FastMCP.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_KWARGS helper that turns removed 2.x constructor kwargs into guided TypeErrors is deliberately kept — it's cheap and pays off for anyone jumping versions.

Net: +181 / −1,258.

Labels: breaking change, v4.

@jlowin jlowin added the v4 label Jul 7, 2026
@marvin-context-protocol marvin-context-protocol Bot added breaking change Breaks backward compatibility. Requires minor version bump. Critical for maintainer attention. server Related to FastMCP server implementation or server-side functionality. enhancements labels Jul 7, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

jlowin added 5 commits July 7, 2026 07:53
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.
@jlowin
jlowin force-pushed the remove/server-method-deprecations branch from debf712 to da57546 Compare July 7, 2026 11:54
@jlowin
jlowin merged commit 3cb3403 into main Jul 7, 2026
15 checks passed
@jlowin
jlowin deleted the remove/server-method-deprecations branch July 7, 2026 11:59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

jlowin added a commit that referenced this pull request Jul 7, 2026
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.
@jlowin jlowin added the enhancement Improvement to existing functionality. For issues and smaller PR improvements. label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Breaks backward compatibility. Requires minor version bump. Critical for maintainer attention. enhancement Improvement to existing functionality. For issues and smaller PR improvements. server Related to FastMCP server implementation or server-side functionality. v4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant