Skip to content

Commit 27ad99d

Browse files
Theodor N. EngøyTheodor N. Engøy
authored andcommitted
fix: restore _get_npx_command behavior
1 parent 42ea897 commit 27ad99d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/mcp/cli/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import importlib.metadata
44
import importlib.util
55
import os
6-
import shutil
76
import subprocess
87
import sys
98
from pathlib import Path
@@ -45,10 +44,14 @@ def _get_npx_command():
4544
if sys.platform == "win32":
4645
# Try both npx.cmd and npx.exe on Windows
4746
for cmd in ["npx.cmd", "npx.exe", "npx"]:
48-
if shutil.which(cmd):
47+
try:
48+
# `.cmd` wrappers are common on Windows, so use `shell=True` here.
49+
subprocess.run([cmd, "--version"], check=True, capture_output=True, shell=True)
4950
return cmd
51+
except (subprocess.CalledProcessError, FileNotFoundError):
52+
continue
5053
return None
51-
return shutil.which("npx")
54+
return "npx" # On Unix-like systems, just use npx
5255

5356

5457
def _parse_env_var(env_var: str) -> tuple[str, str]: # pragma: no cover

0 commit comments

Comments
 (0)