Proxying Servers
Use FastMCP to act as an intermediary or change transport for other MCP servers.
New in version: 2.0.0
FastMCP provides a powerful proxying capability that allows one FastMCP server instance to act as a frontend for another MCP server (which could be remote, running on a different transport, or even another FastMCP instance). This is achieved using the FastMCP.from_client()
class method.
What is Proxying?
Proxying means setting up a FastMCP server that doesn’t implement its own tools or resources directly. Instead, when it receives a request (like tools/call
or resources/read
), it forwards that request to a backend MCP server, receives the response, and then relays that response back to the original client.
Use Cases
- Transport Bridging: Expose a server running on one transport (e.g., a remote SSE server) via a different transport (e.g., local Stdio for Claude Desktop).
- Adding Functionality: Insert a layer in front of an existing server to add caching, logging, authentication, or modify requests/responses (though direct modification requires subclassing
FastMCPProxy
). - Security Boundary: Use the proxy as a controlled gateway to an internal server.
- Simplifying Client Configuration: Provide a single, stable endpoint (the proxy) even if the backend server’s location or transport changes.
Creating a Proxy
The easiest way to create a proxy is using the FastMCP.from_client()
class method. This creates a standard FastMCP server that forwards requests to another MCP server.
How from_client
Works:
- It connects to the backend server using the provided client.
- It discovers all the tools, resources, resource templates, and prompts available on the backend server.
- It creates corresponding “proxy” components that forward requests to the backend.
- It returns a standard
FastMCP
server instance that can be used like any other.
Currently, proxying focuses primarily on exposing the major MCP objects (tools, resources, templates, and prompts). Some advanced MCP features like notifications and sampling are not fully supported in proxies in the current version. Support for these additional features may be added in future releases.
Bridging Transports
A common use case is to bridge transports. For example, making a remote SSE server available locally via Stdio:
In-Memory Proxies
You can also proxy an in-memory FastMCP
instance, which is useful for adjusting the configuration or behavior of a server you don’t completely control.
FastMCPProxy
Class
Internally, FastMCP.from_client()
uses the FastMCPProxy
class. You generally don’t need to interact with this class directly, but it’s available if needed.
Using the class directly might be necessary for advanced scenarios, like subclassing FastMCPProxy
to add custom logic before or after forwarding requests.