π The fast, Pythonic way to build MCP servers and clients.
Made the test context aware. Since windows will called npx subprocess twice, once to find it, and once to execute it, but unix will only call once.
justjoehere24a1f740955d
diff --git a/tests/test_cli.py b/tests/test_cli.pyindex 4ed0e1895..f81538148 100644--- a/tests/test_cli.py+++ b/tests/test_cli.py@@ -1,6 +1,7 @@"""Tests for the FastMCP CLI."""import json+import sysfrom pathlib import Pathfrom unittest.mock import patch, call@@ -276,7 +277,6 @@ def test_server_dependencies_empty(mock_config, server_file):def test_dev_with_dependencies(mock_config, server_file):"""Test that dev command handles dependencies correctly."""- # Create a server file with dependenciesserver_file = server_file.parent / "server_with_deps.py"server_file.write_text("""from fastmcp import FastMCP@@ -287,21 +287,56 @@ mcp = FastMCP("test", dependencies=["pandas", "numpy"])runner = CliRunner()with patch("subprocess.run") as mock_run:- mock_run.return_value.returncode = 0 # Set successful return code+ mock_run.return_value.returncode = 0result = runner.invoke(app, ["dev", str(server_file)])assert result.exit_code == 0- # Check that dependencies were passed to subprocess.run- mock_run.assert_called_once()- args = mock_run.call_args[0][0]- assert "npx" in args- assert "@modelcontextprotocol/inspector" in args- assert "uv" in args- assert "run" in args- assert "--with" in args- assert "pandas" in args- assert "numpy" in args- assert "fastmcp" in args+ if sys.platform == "win32":+ # On Windows, expect two calls+ assert mock_run.call_count == 2+ assert mock_run.call_args_list[0] == call(+ ["npx.cmd", "--version"], check=True, capture_output=True, shell=True+ )+ assert mock_run.call_args_list[1] == call(+ [+ "npx.cmd",+ "@modelcontextprotocol/inspector",+ "uv",+ "run",+ "--with",+ "fastmcp",+ "--with",+ "numpy",+ "--with",+ "pandas",+ "fastmcp",+ "run",+ str(server_file),+ ],+ check=True,+ shell=True,+ )+ else:+ # On Unix, expect one call+ mock_run.assert_called_once_with(+ [+ "npx",+ "@modelcontextprotocol/inspector",+ "uv",+ "run",+ "--with",+ "fastmcp",+ "--with",+ "numpy",+ "--with",+ "pandas",+ "fastmcp",+ "run",+ str(server_file),+ ],+ check=True,+ shell=False, # Note: shell=False on Unix+ )def test_run_with_dependencies(mock_config, server_file):