fastmcp icon indicating copy to clipboard operation
fastmcp copied to clipboard

Proxy to stdio MCP Server

Open aghchan opened this issue 8 months ago • 3 comments

Description

Hi,

I'm currently running a stdio MCP server locally but unable to utilize the proxy to access the MCP server. Proxy was able to correctly detect the stdio mcp transport. I've tried using a local sse server instead of local stdio and that works but for some reason the local stdio does not.

Confirmed both servers are running (the MCP and the proxy server successfully start). Confirmed the proxy client identifies the transport Connected to downloaded mcp server with transport: <NodeStdioTransport(command='node', args=['/app/remote-mcp-server/node_modules/forwarded/index.js'])>

Ends up hanging when calling list tools

Appreciate any guidance you can provide

Example Code

running the server with the following code


        transport = infer_transport(main_file_path)
        print("Connected to downloaded mcp server with transport: ", transport)
        client = Client(transport=transport)

        proxy = FastMCP.from_client(client, name="Downloaded MCP Proxy")

        return proxy.run_sse_async(host="0.0.0.0", port=3000, log_level="debug")

Sample Client to test functionality

async def main():
    base_url = "https://mcp-gksg.onrender.com/sse"

    async with Client(base_url) as client:
        await client.ping()
        print(f"\nAvailable tools ({len(tools)}):")
        tools = await client.list_tools()
        for tool in tools:
            print(f"  - {tool.name}: {tool.description}")

if __name__ == "__main__":
    asyncio.run(main())

Version Information

FastMCP version:                                     2.2.0
MCP version:                                         1.6.0
Python version:                                     3.12.9
Platform:                     macOS-15.1.1-arm64-arm-64bit
FastMCP root path: ~/.pyenv/versions/3.12.9/lib/python3.12

Additional Context

No response

aghchan avatar Apr 25 '25 20:04 aghchan

I also have the issue

I have the test.py

from fastmcp import FastMCP

# Original server
original_server = FastMCP(name="Original")

@original_server.tool()
def tool_a() -> str:
    """print A"""
    return "A"

# Create a proxy of the original server
proxy = FastMCP.from_client(
    original_server,
    name="Proxy Server"
)

# proxy is now a regular FastMCP server that forwards
# requests to original_server
proxy.run(transport="stdio")

when I run, it didn't detect tools.

python test.py
[04/29/25 08:01:01] INFO     Starting server "Proxy Server"...                                                     server.py:262

huang-sh avatar Apr 29 '25 08:04 huang-sh

@huang-sh you are passing a server to from_client(), you need to wrap it in a Client object -- FastMCP.from_client(Client(original_server))

jlowin avatar Apr 29 '25 22:04 jlowin

@aghchan is it possible to provide a full script that demonstrates the issue? I think I only se eyour client test code here

jlowin avatar Apr 29 '25 22:04 jlowin

Closing this issue for now, we have many examples now of proxying stdio servers. Please open a new issue with a minimum reproducible example if you run into this issue

strawgate avatar Oct 04 '25 02:10 strawgate