feat: add deferred MCP provider registration#42
Conversation
Co-Authored-By: AJ Steers <aj@airbyte.io>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
🎉 Thanks for opening this pull request! Your contribution is appreciated. Here are some helpful commands you can use: Quick Commands
Available Poe TasksYou can run any of these tasks using the slash command: Core Tasks
Quick Fixes
Build & Install
Other Commands
The CI will automatically run tests when you push commits. Happy coding! 🚀 |
Co-Authored-By: AJ Steers <aj@airbyte.io>
There was a problem hiding this comment.
Pull request overview
Adds deferred registration support for FastMCP providers (parallel to the existing deferred mcp_tool / mcp_prompt / mcp_resource patterns), and wires provider registration into the existing register_mcp_tools(app, mcp_module=...) flow with annotation merging for provider-sourced tools.
Changes:
- Added
@mcp_provider(annotations=...)decorator and a_REGISTERED_PROVIDERSregistry for deferred provider factory collection. - Extended
register_mcp_tools(...)to instantiate/register matching providers and attach a transform that merges provider-level annotations into provider tool annotations without overwriting tool-declared annotations. - Added unit tests covering provider decorator collection and annotation merge behavior via
register_mcp_tools.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tests/test_fastmcp_extensions.py |
Adds unit tests for provider registration and provider-tool annotation merging. |
src/fastmcp_extensions/registration.py |
Registers deferred providers during register_mcp_tools and applies an annotations-merging transform to provider tools. |
src/fastmcp_extensions/decorators.py |
Introduces mcp_provider decorator + provider registry and clears it in _clear_registrations(). |
src/fastmcp_extensions/__init__.py |
Exposes mcp_provider from the package public API (__all__). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Adds
mcp_provider(annotations=...)as a deferred-registration companion tomcp_tool()for FastMCP providers. Provider factories are collected by module, registered through the existingregister_mcp_tools(app, mcp_module=...)flow, and receive a transform that fills missing tool annotations without overwriting annotations already declared by the provider’s tools.Example:
Tests cover decorator collection and provider tool annotation merging/registration.
Link to Devin session: https://app.devin.ai/sessions/f1992546281649c585688348e5774812
Requested by: Aaron ("AJ") Steers (@aaronsteers)