MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / _get_npx_command

Function _get_npx_command

src/mcp/cli/cli.py:42–53  ·  view source on GitHub ↗

Get the correct npx command for the current platform.

()

Source from the content-addressed store, hash-verified

40
41
42def _get_npx_command():
43 """Get the correct npx command for the current platform."""
44 if sys.platform == "win32":
45 # Try both npx.cmd and npx.exe on Windows
46 for cmd in ["npx.cmd", "npx.exe", "npx"]:
47 try:
48 subprocess.run([cmd, "--version"], check=True, capture_output=True, shell=True)
49 return cmd
50 except subprocess.CalledProcessError:
51 continue
52 return None
53 return "npx" # On Unix-like systems, just use npx
54
55
56def _parse_env_var(env_var: str) -> tuple[str, str]: # pragma: no cover

Callers 4

test_get_npx_unix_likeFunction · 0.90
test_get_npx_windowsFunction · 0.90
devFunction · 0.85

Calls 1

runMethod · 0.45

Tested by 3

test_get_npx_unix_likeFunction · 0.72
test_get_npx_windowsFunction · 0.72