Allow configuring FastMCP transport setting in the same way as other configuration#1796
Allow configuring FastMCP transport setting in the same way as other configuration#1796jvdmr wants to merge 2 commits intoPrefectHQ:mainfrom
Conversation
beedaf6 to
c8b672e
Compare
Co-authored-by: Joris Vandermeersch <joris.vandermeersch@vrt.be>
c8b672e to
b6d6777
Compare
|
No actionable comments were generated in the recent review. 🎉 WalkthroughThe transport configuration option has been made configurable through the Settings class. A new 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
`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.
```python
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