Skip to content

Comments

Add FASTMCP_TRANSPORT setting#3196

Closed
jlowin wants to merge 1 commit intomainfrom
feat/transport-setting
Closed

Add FASTMCP_TRANSPORT setting#3196
jlowin wants to merge 1 commit intomainfrom
feat/transport-setting

Conversation

@jlowin
Copy link
Member

@jlowin jlowin commented Feb 16, 2026

run_async() hardcoded "stdio" as the fallback when no transport was specified, which meant users running third-party servers (like AWS MCP servers in ECS containers) had no way to change the default transport without modifying source code. The CLI and fastmcp.json provided workarounds, but a bare mcp.run() call was locked to stdio.

This adds a transport field to Settings so that FASTMCP_TRANSPORT=http (or any valid transport) controls the default. run_async reads from the setting instead of hardcoding "stdio", while explicit transport= arguments and CLI --transport flags still override it. Fits naturally alongside the existing FASTMCP_HOST and FASTMCP_PORT settings.

# Third-party server code you can't modify:
mcp.run()  # reads FASTMCP_TRANSPORT from env

# Or in your own code:
import fastmcp
fastmcp.settings.transport = "http"

Closes #1795
Supersedes #1796

@jlowin jlowin added the enhancement Improvement to existing functionality. For issues and smaller PR improvements. label Feb 16, 2026
@marvin-context-protocol marvin-context-protocol bot added the server Related to FastMCP server implementation or server-side functionality. label Feb 16, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 16, 2026

Walkthrough

The changes add a configurable transport setting to the Settings model and update the TransportMixin to use this setting as the default when no transport is explicitly provided. A new public field transport with type Literal["stdio", "http", "sse", "streamable-http"] and default value "stdio" is introduced in the Settings class. The TransportMixin.run_async method is modified to retrieve the default transport from fastmcp.settings.transport instead of using a hard-coded "stdio" value. This allows the transport mechanism to be configured through the settings system rather than being fixed.

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description clearly explains the problem, solution, and includes code examples, but is missing the required contributors and review checklists from the template. Add the Contributors Checklist and Review Checklist sections from the template, and check off the appropriate items before marking ready for review.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the primary change: adding a FASTMCP_TRANSPORT setting to the configuration system.
Linked Issues check ✅ Passed The PR fully addresses issue #1795 by adding the FASTMCP_TRANSPORT environment variable configuration option, enabling transport control without modifying source code.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the FASTMCP_TRANSPORT setting as specified in issue #1795, with no extraneous modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ 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 feat/transport-setting

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 jlowin added this to the 3.1 milestone Feb 16, 2026
@jlowin
Copy link
Member Author

jlowin commented Feb 16, 2026

Superseded — pushing changes to #1796 instead to preserve contributor credit.

@jlowin jlowin closed this Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Further allow configuring FastMCP through environment variables

1 participant