Expose remote MCP servers through your local server
New in version 2.0.0Proxying lets you expose a remote MCP server’s tools, resources, and prompts through your local server. Under the hood, FastMCP uses ProxyProvider (v3.0.0+) to source components from a client connection.
A common use case is bridging transports - making a remote server available locally:
Copy
from fastmcp.server import create_proxy# Bridge remote HTTP to local stdioremote_proxy = create_proxy("http://example.com/mcp/sse", name="Remote-to-Local")# Run locally via stdio for Claude Desktopif __name__ == "__main__": remote_proxy.run() # Defaults to stdio
Or expose a local server via HTTP:
Copy
from fastmcp.server import create_proxy# Bridge local server to HTTPlocal_proxy = create_proxy("local_server.py", name="Local-to-HTTP")if __name__ == "__main__": local_proxy.run(transport="http", host="0.0.0.0", port=8080)
New in version 2.10.3create_proxy() provides session isolation - each request gets its own isolated backend session:
Copy
from fastmcp.server import create_proxy# Each request creates a fresh backend session (recommended)proxy = create_proxy("backend_server.py")# Multiple clients can use this proxy simultaneously:# - Client A calls a tool → gets isolated session# - Client B calls a tool → gets different session# - No context mixing
If you pass an already-connected client, the proxy reuses that session:
Copy
from fastmcp import Clientfrom fastmcp.server import create_proxyasync with Client("backend_server.py") as connected_client: # This proxy reuses the connected session proxy = create_proxy(connected_client) # ⚠️ Warning: All requests share the same session
Shared sessions may cause context mixing in concurrent scenarios. Use only in single-threaded situations or with explicit synchronization.
New in version 2.10.3Proxies automatically forward MCP protocol features:
Feature
Description
Roots
Filesystem root access requests
Sampling
LLM completion requests
Elicitation
User input requests
Logging
Log messages from backend
Progress
Progress notifications
Copy
from fastmcp.server import create_proxy# All features forwarded automaticallyproxy = create_proxy("advanced_backend.py")# When the backend:# - Requests LLM sampling → forwarded to your client# - Logs messages → appear in your client# - Reports progress → shown in your client
New in version 2.10.5Components from a proxy server are “mirrored” - they reflect the remote server’s state and cannot be modified directly.To modify a proxied component (like disabling it), create a local copy:
Copy
from fastmcp import FastMCPfrom fastmcp.server import create_proxyproxy = create_proxy("backend_server.py")# Get mirrored toolmirrored_tool = await proxy.get_tool("useful_tool")# Create modifiable local copylocal_tool = mirrored_tool.copy()# Add to your own servermy_server = FastMCP("MyServer")my_server.add_tool(local_tool)# Now you can control visibilitymy_server.disable(keys=[local_tool.key])
When mounting proxy servers, this latency affects all operations on the parent server.For low-latency requirements, consider using import_server() to copy tools at startup.
Mount a proxy to add remote components to an existing server:
Copy
from fastmcp import FastMCPfrom fastmcp.server import create_proxyserver = FastMCP("My Server")# Add local tools@server.tooldef local_tool() -> str: return "Local result"# Mount proxied tools from remote serverremote = create_proxy("http://remote-server/mcp")server.mount(remote)# Now server has both local and proxied tools