Skip to content

Avoid shell=True when launching mcp dev inspector on Windows#2371

Closed
raashish1601 wants to merge 1 commit into
modelcontextprotocol:mainfrom
raashish1601:contributor-54/python-sdk-1257
Closed

Avoid shell=True when launching mcp dev inspector on Windows#2371
raashish1601 wants to merge 1 commit into
modelcontextprotocol:mainfrom
raashish1601:contributor-54/python-sdk-1257

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

  • resolve npx to a concrete executable on Windows instead of probing with shell=True
  • keep mcp dev launching the inspector with a direct argv call and copied environment
  • add focused CLI tests for the Windows resolution path and the shell-free inspector launch

Fixes #1257.

Validation

  • PYTHONPATH=src python -m pytest tests/cli/test_utils.py -q
  • python -m ruff check src/mcp/cli/cli.py tests/cli/test_utils.py
  • git diff --check

@maxisbey
Copy link
Copy Markdown
Contributor

Closing in favor of #2524, which removes the now-stale # pragma: no cover along with the same shutil.which() change. Thanks for the contribution.

AI Disclaimer

@maxisbey maxisbey closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don’t use shell=True in mcp dev subprocess on Windows (command injection risk)

2 participants