You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/patterns/cli.mdx
+40-1Lines changed: 40 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,10 +53,11 @@ This command runs the server directly in your current Python environment. You ar
53
53
#### Server Specification
54
54
<VersionBadgeversion="2.3.5" />
55
55
56
-
The server can be specified in three ways:
56
+
The server can be specified in four ways:
57
57
1.`server.py` - imports the module and looks for a FastMCP object named `mcp`, `server`, or `app`. Errors if no such object is found.
58
58
2.`server.py:custom_name` - imports and uses the specified server object
59
59
3.`http://server-url/path` or `https://server-url/path` - connects to a remote server and creates a proxy
60
+
4.`mcp.json` - runs servers defined in a standard MCP configuration file
60
61
61
62
<Tip>
62
63
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-server
98
99
fastmcp run https://example.com/mcp-server --log-level DEBUG
99
100
```
100
101
102
+
#### Running MCP Configuration Files
103
+
104
+
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.
105
+
106
+
**Example mcp.json:**
107
+
```json
108
+
{
109
+
"mcpServers": {
110
+
"fetch": {
111
+
"command": "uvx",
112
+
"args": [
113
+
"mcp-server-fetch"
114
+
]
115
+
},
116
+
"filesystem": {
117
+
"command": "npx",
118
+
"args": [
119
+
"-y",
120
+
"@modelcontextprotocol/server-filesystem",
121
+
"/Users/username/Documents"
122
+
]
123
+
}
124
+
}
125
+
}
126
+
```
127
+
128
+
**Run the configuration:**
129
+
```bash
130
+
# Run with default stdio transport
131
+
fastmcp run mcp.json
132
+
133
+
# Run with HTTP transport on custom port
134
+
fastmcp run mcp.json --transport http --port 8080
135
+
136
+
# Run with SSE transport
137
+
fastmcp run mcp.json --transport sse
138
+
```
139
+
101
140
### `dev`
102
141
103
142
Run a MCP server with the [MCP Inspector](https://github.com/modelcontextprotocol/inspector) for testing.
0 commit comments