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:
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:
with_transforms
namespace: Prefix for tools/prompts (“namespace_name”), path segment for resources (“protocol://namespace/path”).tool_renames: Map of original_name → final_name. Tools in this map use the specified name instead of namespace prefixing.
- A TransformingProvider wrapping this provider.
with_namespace
namespace: The namespace to apply.
- A TransformingProvider wrapping this provider.
list_tools
get_tool
- The Tool if found, or None to continue searching other providers.
list_resources
get_resource
- The Resource if found, or None to continue searching other providers.
list_resource_templates
get_resource_template
- The ResourceTemplate if a matching one is found, or None to continue searching.
list_prompts
get_prompt
- The Prompt if found, or None to continue searching other providers.
get_component
key: The prefixed key (e.g., “tool:name”, “resource:uri”, “template:uri”).
- The component if found, or None to continue searching other providers.
get_tasks
lifespan
enable
keys: Keys to enable (e.g., “tool:my_tool”).tags: Tags to enable - components with these tags will be enabled.only: If True, switches to allowlist mode - ONLY show these keys/tags.
disable
keys: Keys to disable (e.g., “tool:my_tool”).tags: Tags to disable - components with these tags will be disabled.

