π The fast, Pythonic way to build MCP servers and clients.
Add docs
Jeremiah Lowin74518fb7b262
diff --git a/docs/patterns/cli.mdx b/docs/patterns/cli.mdxindex dce1b5b32..0f8bfdb99 100644--- a/docs/patterns/cli.mdx+++ b/docs/patterns/cli.mdx@@ -53,10 +53,11 @@ This command runs the server directly in your current Python environment. You ar#### Server Specification<VersionBadge version="2.3.5" />-The server can be specified in three ways:+The server can be specified in four ways:1. `server.py` - imports the module and looks for a FastMCP object named `mcp`, `server`, or `app`. Errors if no such object is found.2. `server.py:custom_name` - imports and uses the specified server object3. `http://server-url/path` or `https://server-url/path` - connects to a remote server and creates a proxy+4. `mcp.json` - runs servers defined in a standard MCP configuration file<Tip>When using `fastmcp run` with a local file, it **ignores** the `if __name__ == "__main__"` block entirely. Instead, it finds your server object and calls its `run()` method directly with the transport options you specify. This means you can use `fastmcp run` to override the transport specified in your code.@@ -98,6 +99,44 @@ fastmcp run https://example.com/mcp-serverfastmcp run https://example.com/mcp-server --log-level DEBUG```+#### Running MCP Configuration Files++FastMCP can run servers defined in standard MCP configuration files (typically named `mcp.json`). When you run an mcp.json file, FastMCP creates a proxy server that runs all the servers referenced in the configuration.++**Example mcp.json:**+```json+{+ "mcpServers": {+ "fetch": {+ "command": "uvx",+ "args": [+ "mcp-server-fetch"+ ]+ },+ "filesystem": {+ "command": "npx",+ "args": [+ "-y",+ "@modelcontextprotocol/server-filesystem",+ "/Users/username/Documents"+ ]+ }+ }+}+```++**Run the configuration:**+```bash+# Run with default stdio transport+fastmcp run mcp.json++# Run with HTTP transport on custom port+fastmcp run mcp.json --transport http --port 8080++# Run with SSE transport+fastmcp run mcp.json --transport sse+```+### `dev`Run a MCP server with the [MCP Inspector](https://github.com/modelcontextprotocol/inspector) for testing.diff --git a/src/fastmcp/mcp_config.py b/src/fastmcp/mcp_config.pyindex 8d5576ec5..e6758e0c7 100644--- a/src/fastmcp/mcp_config.py+++ b/src/fastmcp/mcp_config.py@@ -270,7 +270,7 @@ class MCPConfig(BaseModel):if content := file_path.read_text().strip():return cls.model_validate_json(content)- return cls(mcpServers={})+ raise ValueError(f"No MCP servers defined in the config: {file_path}")class CanonicalMCPConfig(MCPConfig):