Skip to content

Remove deprecated FastMCP() constructor kwargs#3148

Merged
jlowin merged 3 commits intomainfrom
remove-deprecated-init-kwargs
Feb 11, 2026
Merged

Remove deprecated FastMCP() constructor kwargs#3148
jlowin merged 3 commits intomainfrom
remove-deprecated-init-kwargs

Conversation

@jlowin
Copy link
Member

@jlowin jlowin commented Feb 11, 2026

FastMCP v1 conflated server identity, transport config, and global settings into a single FastMCP() constructor — v2 deprecated the transport params but kept them for backwards compat, resulting in a 34-parameter __init__ with a _deprecated_settings indirection layer bridging old kwargs to transport methods.

This removes all 16 deprecated kwargs and replaces them with a **kwargs catch that raises TypeError with specific migration instructions. Users passing host= get told to use run_http_async(host=...) or FASTMCP_HOST; users passing include_tags= get told to use server.enable(tags=..., only=True). Environment variables continue to work — transport methods now read directly from fastmcp.settings instead of the deleted per-instance _deprecated_settings.

# Before: 34-param constructor with deprecated indirection
mcp = FastMCP("server", host="0.0.0.0", port=8080, include_tags={"public"})

# After: clean constructor, settings where they belong
mcp = FastMCP("server")
mcp.enable(tags={"public"}, only=True)
mcp.run_http(host="0.0.0.0", port=8080)

# Helpful error if you forget:
# TypeError: FastMCP() no longer accepts `host`. Pass `host` to `run_http_async()`, or set FASTMCP_HOST.

Also deletes ExperimentalSettings (dead code) and fixes mcp_config.py which was passing include_tags/exclude_tags through create_proxy() to the now-strict constructor.

Replace 16 deprecated kwargs with **kwargs catch that raises TypeError
with specific migration instructions. Transport methods now read from
fastmcp.settings directly. Delete ExperimentalSettings (dead code).
@jlowin jlowin added the breaking change Breaks backward compatibility. Requires minor version bump. Critical for maintainer attention. label Feb 11, 2026
@marvin-context-protocol marvin-context-protocol bot added enhancement Improvement to existing functionality. For issues and smaller PR improvements. server Related to FastMCP server implementation or server-side functionality. labels Feb 11, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Walkthrough

This PR removes multiple deprecated FastMCP constructor kwargs and centralizes removal checks via a _REMOVED_KWARGS checker; FastMCP.init signature no longer accepts legacy transport/server, tag-filtering, tool-serialization, and transformation kwargs. Tag filtering is applied post-proxy-creation via enable/disable calls. The MCP Apps decorator parameter is renamed from ui= to app= and a new public AppConfig replaces ToolUI/ResourceUI (wire format unchanged). ExperimentalSettings and related deprecation plumbing were removed. HTTP transport code now reads configuration directly from fastmcp.settings. Several documentation anchors were updated.

Possibly related PRs

  • #2836: Removes passing tool_transformations into proxy creation and applies transforms post-creation, matching transformation-wiring changes in this PR.
  • #3117: Introduces AppConfig and renames decorator parameter from ui= to app=, the same breaking API change implemented here.
  • #2581: Removes deprecated settings shims and simplifies access to the global settings object, relating to the migration to fastmcp.settings used in transport code.
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Remove deprecated FastMCP() constructor kwargs' clearly and concisely summarizes the main change: removal of deprecated kwargs from the constructor.
Description check ✅ Passed The PR description is comprehensive and well-structured, explaining the motivation, implementation details, before/after examples, and migration guidance for users. It follows good practices by being specific about changes and providing concrete examples.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-deprecated-init-kwargs

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jlowin
Copy link
Member Author

jlowin commented Feb 11, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

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

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: 29a37a8432

ℹ️ 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".

exclude_tags=self.exclude_tags,
)

if self.include_tags:

Choose a reason for hiding this comment

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

P1 Badge Handle empty include_tags when configuring proxy filters

Using a truthiness check here changes behavior for include_tags=set(): the filter is now skipped entirely, so the proxy exposes all components, whereas the previous path (FastMCP(..., include_tags=set())) still applied allowlist mode and resulted in no components being enabled. This can silently broaden access when config generation produces an empty include list; check for is not None instead so an explicit empty set remains an explicit filter.

Useful? React with 👍 / 👎.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/fastmcp/server/mixins/transport.py (1)

240-242: port or will swallow an explicit port=0 (OS-assigned port)

port = port or fastmcp.settings.port treats 0 as falsy. If a caller passes port=0 to let the OS assign a port, it silently falls back to the settings default. This is likely a pre-existing issue, but worth noting since the function signature accepts int | None.

Suggested fix
-        host = host or fastmcp.settings.host
-        port = port or fastmcp.settings.port
+        host = host if host is not None else fastmcp.settings.host
+        port = port if port is not None else fastmcp.settings.port

@jlowin jlowin merged commit 25e2f4d into main Feb 11, 2026
14 checks passed
@jlowin jlowin deleted the remove-deprecated-init-kwargs branch February 11, 2026 16:39
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant