fastmcp.server.providers.proxy
ProxyProvider for proxying to remote MCP servers.
This module provides the ProxyProvider class that proxies components from
a remote MCP server via a client factory. It also provides proxy component
classes that forward execution to remote servers.
Functions
default_proxy_roots_handler
default_proxy_sampling_handler
default_proxy_elicitation_handler
default_proxy_log_handler
default_proxy_progress_handler
Classes
ProxyTool
A Tool that represents and executes a tool on a remote server.
Methods:
model_copy
from_mcp_tool
run
get_span_attributes
ProxyResource
A Resource that represents and reads a resource from a remote server.
Methods:
model_copy
from_mcp_resource
read
get_span_attributes
ProxyTemplate
A ResourceTemplate that represents and creates resources from a remote server template.
Methods:
model_copy
from_mcp_template
create_resource
get_span_attributes
ProxyPrompt
A Prompt that represents and renders a prompt from a remote server.
Methods:
model_copy
from_mcp_prompt
render
get_span_attributes
ProxyProvider
Provider that proxies to a remote MCP server via a client factory.
This provider fetches components from a remote server and returns Proxy*
component instances that forward execution to the remote server.
All components returned by this provider have task_config.mode=“forbidden”
because tasks cannot be executed through a proxy.
Methods:
get_tasks
FastMCPProxy
A FastMCP server that acts as a proxy to a remote MCP-compliant server.
This is a convenience wrapper that creates a FastMCP server with a
ProxyProvider. For more control, use FastMCP with add_provider(ProxyProvider(…)).
ProxyClient
A proxy client that forwards advanced interactions between a remote MCP server and the proxy’s connected clients.
Supports forwarding roots, sampling, elicitation, logging, and progress.
StatefulProxyClient
A proxy client that provides a stateful client factory for the proxy server.
The stateful proxy client bound its copy to the server session.
And it will be disconnected when the session is exited.
This is useful to proxy a stateful mcp server such as the Playwright MCP server.
Note that it is essential to ensure that the proxy server itself is also stateful.
Because session reuse means the receive-loop task inherits a stale
request_ctx ContextVar snapshot, the default proxy handlers are
replaced with versions that restore the ContextVar before forwarding.
ProxyTool.run stashes the current RequestContext in
_proxy_rc_ref before each backend call, and the handlers consult
it to detect (and correct) staleness.
Methods:

