π The fast, Pythonic way to build MCP servers and clients.
Use bare python for module mode when uv wraps the command
dgenio173b93a4c3e3
diff --git a/src/fastmcp/cli/run.py b/src/fastmcp/cli/run.pyindex 46cbae3c1..8257aa2a2 100644--- a/src/fastmcp/cli/run.py+++ b/src/fastmcp/cli/run.py@@ -273,7 +273,11 @@ def run_module_command(with environment setup (e.g. ``UVEnvironment.build_command``).extra_args: Extra arguments forwarded after the module name."""- cmd: list[str] = [sys.executable, "-m", module_name]+ # Use bare "python" when an env wrapper (e.g. uv run) is active so that+ # the wrapper can resolve the interpreter via --python / environment config.+ # Fall back to sys.executable for direct execution without a wrapper.+ python = "python" if env_command_builder is not None else sys.executable+ cmd: list[str] = [python, "-m", module_name]if extra_args:cmd.extend(extra_args)diff --git a/tests/cli/test_run.py b/tests/cli/test_run.pyindex bcb8e1a78..2780e4980 100644--- a/tests/cli/test_run.py+++ b/tests/cli/test_run.py@@ -767,6 +767,8 @@ class TestRunModuleCommand:cmd = mock_run.call_args[0][0]assert cmd[0] == "uv"assert cmd[1] == "run"+ # Should use bare "python" (not sys.executable) so uv resolves the interpreter+ assert cmd[2] == "python"assert "-m" in cmdassert "my_package" in cmd