Skip to content

Commit 18d5492

Browse files
fix: avoid shell interpretation in MCP dev launcher
1 parent 57394b0 commit 18d5492

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/mcp/cli/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def _get_npx_command():
4545
# Try both npx.cmd and npx.exe on Windows
4646
for cmd in ["npx.cmd", "npx.exe", "npx"]:
4747
try:
48-
subprocess.run([cmd, "--version"], check=True, capture_output=True, shell=True)
48+
subprocess.run([cmd, "--version"], check=True, capture_output=True)
4949
return cmd
5050
except subprocess.CalledProcessError:
5151
continue
@@ -271,12 +271,13 @@ def dev(
271271
)
272272
sys.exit(1)
273273

274-
# Run the MCP Inspector command with shell=True on Windows
275-
shell = sys.platform == "win32"
274+
# Pass an argv list directly to the process. Using cmd.exe on Windows
275+
# makes every argument part of a shell command and can reinterpret
276+
# repository/file-controlled values.
276277
process = subprocess.run(
277278
[npx_cmd, "@modelcontextprotocol/inspector"] + uv_cmd,
278279
check=True,
279-
shell=shell,
280+
shell=False,
280281
env=dict(os.environ.items()), # Copy the environment for subprocess launch
281282
)
282283
sys.exit(process.returncode)

0 commit comments

Comments
 (0)