π The fast, Pythonic way to build MCP servers and clients.
Merge pull request #1138 from strawgate/run-mcp-config
Jeremiah Lowin1ea3ee82fe9a
diff --cc docs/patterns/cli.mdxindex e394b99f5,0f8bfdb99..69ef01131--- a/docs/patterns/cli.mdx+++ b/docs/patterns/cli.mdx@@@ -100,20 -97,46 +101,58 @@@ fastmcp run https://example.com/mcp-ser# Connect to a remote server with specified log levelfastmcp run https://example.com/mcp-server --log-level DEBUG++# Run with a specific Python version+fastmcp run server.py --python 3.11++# Run with additional packages+fastmcp run server.py --with pandas --with numpy++# Run within a specific project directory+fastmcp run server.py --project /path/to/project++# Run with dependencies from a requirements file+fastmcp run server.py --with-requirements requirements.txt```+ #### 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 --cc src/fastmcp/cli/run.pyindex f0464d2e4,1efd34e30..a31b41e16--- a/src/fastmcp/cli/run.py+++ b/src/fastmcp/cli/run.py@@@ -1,8 -1,8 +1,9 @@@"""FastMCP run command implementation with enhanced type hints."""import importlib.util+ import jsonimport re+import subprocessimport sysfrom pathlib import Pathfrom typing import Any, Literal