Skip to content

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

cleaner

zzstoatzz789d856a53a6
diff --git a/docs/deployment/running-server.mdx b/docs/deployment/running-server.mdx
index 254caf2b3..5f5d758d2 100644
--- a/docs/deployment/running-server.mdx
+++ b/docs/deployment/running-server.mdx
@@ -63,13 +63,11 @@ See the [CLI documentation](/patterns/cli) for detailed information about all av
### Passing Arguments to Servers
-<VersionBadge version="2.6.2" />
-
-When servers accept command line arguments (using argparse, click, or other libraries), you can pass them using the `--server-arg` option:
+When servers accept command line arguments (using argparse, click, or other libraries), you can pass them after `--`:
```bash
-fastmcp run config_server.py --server-arg="--config" --server-arg="config.json"
-fastmcp run database_server.py --server-arg="--database-path" --server-arg="/tmp/db.sqlite"
+fastmcp run config_server.py -- --config config.json
+fastmcp run database_server.py -- --database-path /tmp/db.sqlite --debug
```
This is useful for servers that need configuration files, database paths, API keys, or other runtime options.
diff --git a/src/fastmcp/cli/cli.py b/src/fastmcp/cli/cli.py
index c1f1d7107..8470fad68 100644
--- a/src/fastmcp/cli/cli.py
+++ b/src/fastmcp/cli/cli.py
@@ -219,8 +219,9 @@ def dev(
sys.exit(1)
[email protected](context_settings={"allow_extra_args": True})
def run(
+ ctx: typer.Context,
server_spec: str = typer.Argument(
...,
help="Python file, object specification (file:obj), or URL",
@@ -256,13 +257,6 @@ def run(
help="Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
),
] = None,
- server_args: Annotated[
- list[str],
- typer.Option(
- "--server-arg",
- help="Additional arguments to pass to the server",
- ),
- ] = [],
) -> None:
"""Run a MCP server or connect to a remote one.
@@ -274,9 +268,11 @@ def run(
Note: This command runs the server directly. You are responsible for ensuring
all dependencies are available.
- Server arguments can be passed using --server-arg:
- fastmcp run server.py --server-arg="--config" --server-arg="config.json"
+ Server arguments can be passed after -- :
+ fastmcp run server.py -- --config config.json --debug
"""
+ server_args = ctx.args # extra args after --
+
logger.debug(
"Running server or client",
extra={
diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py
index 25512e264..4897cc6dd 100644
--- a/tests/cli/test_cli.py
+++ b/tests/cli/test_cli.py
@@ -411,7 +411,7 @@ class TestRunCommand:
)
def test_run_command_with_server_args(self, temp_python_file):
- """Test run command with server arguments."""
+ """Test run command with server arguments using -- pattern."""
with (
patch("fastmcp.cli.run.run_command") as mock_run_command,
):
@@ -420,9 +420,8 @@ class TestRunCommand:
[
"run",
str(temp_python_file),
- "--server-arg",
+ "--",
"--config",
- "--server-arg",
"config.json",
],
)