docs/python-sdk/fastmcp-server-providers-aggregate.mdx
fastmcp.server.providers.aggregateAggregateProvider for combining multiple providers into one.
This module provides AggregateProvider, a utility class that presents
multiple providers as a single unified provider. Useful when you want to
combine custom providers without creating a full FastMCP server.
Example: ```python from fastmcp.server.providers import AggregateProvider
# Combine multiple providers into one
combined = AggregateProvider()
combined.add_provider(provider1)
combined.add_provider(provider2, namespace="api") # Tools become "api_foo"
# Use like any other provider
tools = await combined.list_tools()
```
AggregateProvider <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/server/providers/aggregate.py#L47" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Utility provider that combines multiple providers into one.
Components are aggregated from all providers. For get_* operations, providers are queried in parallel and the highest version is returned.
When adding providers with a namespace, wrap_transform() is used to apply the Namespace transform. This means namespace transformation is handled by the wrapped provider, not by AggregateProvider.
Errors from individual providers are logged and skipped by default. Set
provider_error_strategy="raise" to fail the aggregate operation when
any provider fails.
Methods:
add_provider <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/server/providers/aggregate.py#L90" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>add_provider(self, provider: Provider) -> None
Add a provider with optional namespace.
If the provider is a FastMCP server, it's automatically wrapped in FastMCPProvider to ensure middleware is invoked correctly.
Args:
provider: The provider to add.namespace: Optional namespace prefix. When set:get_app_tool <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/server/providers/aggregate.py#L208" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_app_tool(self, app_name: str, tool_name: str) -> Tool | None
Query all child providers for an app tool.
get_tool_by_hash <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/server/providers/aggregate.py#L223" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_tool_by_hash(self, tool_hash: str, tool_name: str) -> Tool | None
Query all child providers for a tool matching a hash.
The hash identifies a tool by app name and registered name, with no mount-point component, so composing one app into two branches yields two distinct tools claiming the same identity. That is ambiguous rather than resolvable: picking either one silently routes a UI's call into the wrong branch. Raise instead.
An ambiguity raised by a child is a verdict, not a provider failure, so it propagates whatever the error strategy is. Swallowing it would turn a duplicated app into "unknown tool", which sends whoever hits it looking for a missing registration instead of a duplicate one.
get_tasks <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/server/providers/aggregate.py#L332" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_tasks(self) -> Sequence[FastMCPComponent]
Get all task-eligible components from all providers.
lifespan <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/server/providers/aggregate.py#L345" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>lifespan(self) -> AsyncIterator[None]
Combine lifespans of all providers.