FastMCPProvider for wrapping FastMCP servers as providers.This module provides the FastMCPProvider class that wraps a FastMCP server
and exposes its components through the Provider interface.It also provides FastMCPProvider* component classes that delegate execution to
the wrapped server’s middleware, ensuring middleware runs when components are
executed.
Tool that delegates execution to a wrapped server’s middleware.When run() is called, this tool invokes the wrapped server’s
_call_tool_middleware() method, ensuring the server’s middleware
chain is executed.Methods:
Delegate to child server’s call_tool() without task_meta.This is called when the tool is used within a TransformedTool
forwarding function or other contexts where task_meta is not available.
Resource that delegates reading to a wrapped server’s read_resource().When read() is called, this resource invokes the wrapped server’s
read_resource() method, ensuring the server’s middleware chain is executed.Methods:
Prompt that delegates rendering to a wrapped server’s render_prompt().When render() is called, this prompt invokes the wrapped server’s
render_prompt() method, ensuring the server’s middleware chain is executed.Methods:
Delegate to child server’s render_prompt() without task_meta.This is called when the prompt is used within a transformed context
or other contexts where task_meta is not available.
Resource template that creates FastMCPProviderResources.When create_resource() is called, this template creates a
FastMCPProviderResource that will invoke the wrapped server’s middleware
when read.Methods:
Create a FastMCPProviderResource for the given URI.The uri is the external/transformed URI (e.g., with namespace prefix).
We use _original_uri_template with params to construct the internal
URI that the nested server understands.
Read the resource content for background task execution.Reads the resource via the wrapped server and returns the ResourceResult.
This method is called by Docket during background task execution.
Schedule this template for background execution via docket.The child’s FunctionResourceTemplate.fn is registered (via get_tasks),
and it expects splatted **kwargs, so we splat params here.
Provider that wraps a FastMCP server.This provider enables mounting one FastMCP server onto another, exposing
the mounted server’s tools, resources, and prompts through the parent
server.Components returned by this provider are wrapped in FastMCPProvider*
classes that delegate execution to the wrapped server’s middleware chain.
This ensures middleware runs when components are executed.Methods:
Return task-eligible components from the mounted server.Returns the child’s ACTUAL components (not wrapped) so their actual
functions get registered with Docket. Gets components with child
server’s transforms applied, then applies this provider’s transforms
for correct registration keys.
Start the mounted server’s user lifespan.This starts only the wrapped server’s user-defined lifespan, NOT its
full _lifespan_manager() (which includes Docket). The parent server’s
Docket handles all background tasks.