mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-24 22:44:17 +02:00
* feat: add Provider abstraction for dynamic components
Introduces a `Provider` base class that allows dynamic provision of
tools, resources, and prompts at runtime. Providers are queried after
static components, enabling database-backed tools, external integrations,
and other dynamic component sources.
```python
from fastmcp import FastMCP, Provider
class DatabaseProvider(Provider):
async def list_tools(self, context):
return await db.fetch_tools()
mcp = FastMCP("Server", providers=[DatabaseProvider()])
```
* Add execution methods to Provider interface
Enable providers to customize how components are executed, not just listed.
This unlocks MountedProvider (future) invoking wrapped server middleware.
- call_tool, read_resource, read_resource_template, render_prompt
- Server uses provider execution methods after filter checks
- Default implementations delegate to component methods
* Apply unified error handling to provider execution
- Document error semantics: list_* gracefully degrades, execution propagates
- Wrap provider call_tool/read_resource/render_prompt with masking logic
- ToolError/ResourceError/PromptError pass through, others wrapped
|
||
|---|---|---|
| .. | ||
| auth | ||
| http | ||
| middleware | ||
| openapi | ||
| proxy | ||
| sampling | ||
| tasks | ||
| __init__.py | ||
| test_app_state.py | ||
| test_auth_integration.py | ||
| test_context.py | ||
| test_dependencies.py | ||
| test_event_store.py | ||
| test_file_server.py | ||
| test_icons.py | ||
| test_import_server.py | ||
| test_input_validation.py | ||
| test_log_level.py | ||
| test_logging.py | ||
| test_mount.py | ||
| test_providers.py | ||
| test_run_server.py | ||
| test_server.py | ||
| test_server_docket.py | ||
| test_server_interactions.py | ||
| test_server_lifespan.py | ||
| test_streamable_http_no_redirect.py | ||
| test_tool_annotations.py | ||
| test_tool_transformation.py | ||