Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Simplify proxy load

Jeremiah Lowined57b4cd4269
diff --git a/src/fastmcp/cli/cli.py b/src/fastmcp/cli/cli.py
index 4e82efae2..3f06e507b 100644
--- a/src/fastmcp/cli/cli.py
+++ b/src/fastmcp/cli/cli.py
@@ -292,10 +292,10 @@ def run(
"""Run an MCP server or connect to a remote one.
The server can be specified in four ways:
- 1. Module approach: server.py - runs the module directly, looking for an object named 'mcp', 'server', or 'app'
- 2. Import approach: server.py:app - imports and runs the specified server object
- 3. URL approach: http://server-url - connects to a remote server and creates a proxy
- 4. MCPConfig file: mcp.json - runs as a proxy server for the MCP Servers in the MCPConfig file
+ 1. Module approach: "server.py" - runs the module directly, looking for an object named 'mcp', 'server', or 'app'
+ 2. Import approach: "server.py:app" - imports and runs the specified server object
+ 3. URL approach: "http://server-url" - connects to a remote server and creates a proxy
+ 4. MCPConfig file: "mcp.json" - runs as a proxy server for the MCP Servers in the MCPConfig file
Server arguments can be passed after -- :
fastmcp run server.py -- --config config.json --debug
diff --git a/src/fastmcp/cli/run.py b/src/fastmcp/cli/run.py
index 1fa173307..1efd34e30 100644
--- a/src/fastmcp/cli/run.py
+++ b/src/fastmcp/cli/run.py
@@ -1,6 +1,7 @@
"""FastMCP run command implementation with enhanced type hints."""
import importlib.util
+import json
import re
import sys
from pathlib import Path
@@ -146,13 +147,11 @@ def create_client_server(url: str) -> Any:
def create_mcp_config_server(mcp_config_path: Path) -> FastMCP[None]:
"""Create a FastMCP server from a MCPConfig."""
from fastmcp import FastMCP
- from fastmcp.client import Client
- from fastmcp.client.transports import MCPConfigTransport
- from fastmcp.mcp_config import MCPConfig
- mcp_config = MCPConfig.from_file(mcp_config_path)
- client = Client[MCPConfigTransport](mcp_config)
- server = FastMCP.as_proxy(client)
+ with mcp_config_path.open() as src:
+ mcp_config = json.load(src)
+
+ server = FastMCP.as_proxy(mcp_config)
return server