fastmcp.server.providers.base
Base Provider class for dynamic MCP components.
This module provides the Provider abstraction for providing tools,
resources, and prompts dynamically at runtime.
Example:
Functions
hashed_lookup_target
get_tool_by_hash() on provider found, if any.
Classes
Provider
Base class for dynamic component providers.
Subclass and override whichever methods you need. Default implementations
return empty lists / None, so you only need to implement what your provider
supports.
Methods:
required_extensions
auto_register = True. An explicitly registered extension with the
same identifier takes precedence, regardless of registration order.
Composite providers should include their children’s extensions.
transforms
add_transform
transform: The transform to add.
wrap_transform
transform: The transform to apply.
- A new provider that wraps this one with the transform applied.
list_tools
- Transformed sequence of tools (including disabled ones).
get_tool
name: The transformed tool name to look up.version: Optional version filter. If None, returns highest version.
- The tool if found (may be marked disabled), None if not found.
get_app_tool
tool_name tagged with the given app
name. Skips the transform chain entirely.
Returns:
- The tool if found and tagged with the given app name, else None.
get_tool_by_hash
get_tool().
The identity hash survives renaming, so _get_tool_by_hash() finds
the tool beneath this provider’s transforms. Its name above the
transforms comes from their listing, and the tool is then looked up
under that name with get_tool(), the same public lookup a name call
uses. While that lookup runs, the bottom of the chain answers the
found tool for its own name and looks up every other name as usual,
so transforms and get_tool() overrides decide exactly as they would
for a name call, while a different tool sharing the name cannot take
the found tool’s place. A version constraint the found tool does not
meet is looked up as usual and accepted only for the same identity.
A nested lookup of that same name on this provider while the hashed
lookup runs resolves to the found tool; tasks started during the
lookup resolve names as usual once it finishes.
Note: Like get_tool(), this does NOT filter disabled components. The
Server (FastMCP) performs enabled filtering after all transforms.
Args:
tool_hash: The identity hash from a<hash>_<local_name>name.tool_name: The local tool name from the same name.
- The tool if found and not hidden (may be marked disabled), else None.
list_resources
get_resource
uri: The transformed resource URI to look up.version: Optional version filter. If None, returns highest version.
- The resource if found (may be marked disabled), None if not found.
list_resource_templates
get_resource_template
uri: The transformed template URI to look up.version: Optional version filter. If None, returns highest version.
- The template if found (may be marked disabled), None if not found.
list_prompts
get_prompt
name: The transformed prompt name to look up.version: Optional version filter. If None, returns highest version.
- The prompt if found (may be marked disabled), None if not found.
get_tasks
lifespan
enable
names: Component names or URIs to enable.keys: Component keys to enable (e.g., ).version: Component version spec to enable (e.g., VersionSpec(eq=“v1”) or VersionSpec(gte=“v2”)). Unversioned components will not match.tags: Enable components with these tags.components: Component types to include (e.g., ).only: If True, ONLY enable matching components (allowlist mode).
- Self for method chaining.
disable
names: Component names or URIs to disable.keys: Component keys to disable (e.g., ).version: Component version spec to disable (e.g., VersionSpec(eq=“v1”) or VersionSpec(gte=“v2”)). Unversioned components will not match.tags: Disable components with these tags.components: Component types to include (e.g., ).
- Self for method chaining.

