From 18d5492523231e5b51b0e967637ef140318afca5 Mon Sep 17 00:00:00 2001 From: KevinTran3011 <112609054+KevinTran3011@users.noreply.github.com> Date: Mon, 24 Aug 2026 10:48:04 +1000 Subject: [PATCH] fix: avoid shell interpretation in MCP dev launcher --- src/mcp/cli/cli.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mcp/cli/cli.py b/src/mcp/cli/cli.py index 203034c6ef..69908e092a 100644 --- a/src/mcp/cli/cli.py +++ b/src/mcp/cli/cli.py @@ -45,7 +45,7 @@ def _get_npx_command(): # Try both npx.cmd and npx.exe on Windows for cmd in ["npx.cmd", "npx.exe", "npx"]: try: - subprocess.run([cmd, "--version"], check=True, capture_output=True, shell=True) + subprocess.run([cmd, "--version"], check=True, capture_output=True) return cmd except subprocess.CalledProcessError: continue @@ -271,12 +271,13 @@ def dev( ) sys.exit(1) - # Run the MCP Inspector command with shell=True on Windows - shell = sys.platform == "win32" + # Pass an argv list directly to the process. Using cmd.exe on Windows + # makes every argument part of a shell command and can reinterpret + # repository/file-controlled values. process = subprocess.run( [npx_cmd, "@modelcontextprotocol/inspector"] + uv_cmd, check=True, - shell=shell, + shell=False, env=dict(os.environ.items()), # Copy the environment for subprocess launch ) sys.exit(process.returncode)