Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fastmcp/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _get_npx_command():
try:
subprocess.run([cmd, "--version"], check=True, capture_output=True)
return cmd
except subprocess.CalledProcessError:
except (subprocess.CalledProcessError, FileNotFoundError):
continue
return None
return "npx" # On Unix-like systems, just use npx
Expand Down
17 changes: 17 additions & 0 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,23 @@ def test_get_npx_command_windows_exe(self, mock_run):
assert result == "npx.exe"
assert mock_run.call_count == 2

@patch("subprocess.run")
def test_get_npx_command_windows_cmd_missing(self, mock_run):
"""Test npx command detection continues when npx.cmd is missing."""
from fastmcp.cli.cli import _get_npx_command

with patch("sys.platform", "win32"):
# Missing npx.cmd should not abort detection
mock_run.side_effect = [
FileNotFoundError("npx.cmd not found"),
Mock(returncode=0),
]

result = _get_npx_command()

assert result == "npx.exe"
assert mock_run.call_count == 2

@patch("subprocess.run")
def test_get_npx_command_windows_fallback(self, mock_run):
"""Test npx command detection on Windows with plain npx."""
Expand Down
Loading