Use ergonomic provider initialization pattern#2675
Conversation
Updates examples and convenience methods to pass providers directly to FastMCP's __init__ instead of calling add_provider() after instantiation.
WalkthroughThis pull request refactors provider setup across multiple files to consolidate the two-step initialization process into a single-step approach. Previously, code would instantiate a FastMCP server and then invoke Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (2)**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/fastmcp/**/__init__.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-11-03T17:36:13.363ZApplied to files:
🧬 Code graph analysis (1)examples/providers/sqlite/server.py (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (7)
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 |
The FastMCP constructor already accepts a
providerskwarg, but examples and convenience methods were using a less ergonomic three-step pattern. This updates them to use the cleaner approach.Before:
After:
Changes apply to:
FastMCP.from_openapi()andFastMCP.from_fastapi()convenience methods