File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 33import importlib .metadata
44import importlib .util
55import os
6+ import shlex
67import subprocess
78import sys
89from pathlib import Path
@@ -275,8 +276,15 @@ def dev(
275276
276277 # Run the MCP Inspector command with shell=True on Windows
277278 shell = sys .platform == "win32"
279+ cmd_args = [npx_cmd , "@modelcontextprotocol/inspector" ] + uv_cmd
280+
281+ if shell :
282+ # On Windows with shell=True, I need to quote arguments to prevent injection
283+ # and join them into a single string, as passing a list with shell=True is unsafe/undefined behavior
284+ cmd_args = " " .join (shlex .quote (arg ) for arg in cmd_args )
285+
278286 process = subprocess .run (
279- [ npx_cmd , "@modelcontextprotocol/inspector" ] + uv_cmd ,
287+ cmd_args ,
280288 check = True ,
281289 shell = shell ,
282290 env = dict (os .environ .items ()), # Convert to list of tuples for env update
You can’t perform that action at this time.
0 commit comments