Skip to content

as_proxy substantially slower #1583

@wbste

Description

@wbste

Description

I use FastMCP.as_proxy all the time, but recently I built a new server and made it with acting as a proxy. For certain servers (http streamable at least), Tool execution is substantially slower. Repo:

  1. Launch server as is.
  2. Open inspector with npx @modelcontextprotocol/inspector
  3. Connect via Streamable HTTP to http://localhost:8000/mcp
  4. List tools
  5. Run the single tool.

Response is instant.

Now swap lines 15 and 16 (so FastMCP.as_proxy... is active).

Create an mcp_test.json in the same directory as the script, then run the same test. Every tool (local and remote) will be much slower to respond.

{
    "mcpServers": {
        "deepwiki": {
            "url": "https://mcp.deepwiki.com/mcp",
            "transport": "http"
        },
        "time": {
            "command": "uvx",
            "args": [
                "mcp-server-time"
            ]
        }
    }
}

Example Code

import json
from datetime import datetime
from pathlib import Path
from zoneinfo import ZoneInfo

from fastmcp import FastMCP

# MARK: Config
config_path = Path("mcp_test.json")
with config_path.open(encoding="utf-8") as f:
    config = json.load(f)


# MARK: FastMCP
# mcp = FastMCP.as_proxy(config, name="Slow MCP", include_fastmcp_meta=False)
mcp = FastMCP(name="Fast MCP", include_fastmcp_meta=False)


@mcp.tool
def custom_get_current_time():
    """Get current time in LA with DST information."""
    now = datetime.now(ZoneInfo("America/Los_Angeles"))
    is_dst = bool(now.dst() and now.dst().total_seconds() != 0) if now.dst() else False
    result = {"timezone": "America/Los_Angeles", "datetime": now.isoformat(), "is_dst": is_dst}
    return json.dumps(result, indent=2)


if __name__ == "__main__":
    mcp.run(transport="http", host="127.0.0.1", port=8000)

Version Information

FastMCP version:                                        2.11.3
MCP version:                                            1.13.1
Python version:                                        3.12.10
Platform:                            Windows-11-10.0.26100-SP0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.httpRelated to HTTP transport, networking, or web server functionality.serverRelated to FastMCP server implementation or server-side functionality.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions