Skip to content

cli: avoid shell=True for npx/browser helpers#2014

Open
TheodorNEngoy wants to merge 2 commits intomodelcontextprotocol:mainfrom
TheodorNEngoy:codex/no-shell-true
Open

cli: avoid shell=True for npx/browser helpers#2014
TheodorNEngoy wants to merge 2 commits intomodelcontextprotocol:mainfrom
TheodorNEngoy:codex/no-shell-true

Conversation

@TheodorNEngoy
Copy link

This removes shell=True usage from the CLI helper path (a common security footgun).

Changes:

  • _get_npx_command() now returns a subprocess-friendly command prefix and uses COMSPEC /c only when npx is a .cmd/.bat shim.
  • mcp dev runs npx @modelcontextprotocol/inspector without shell=True.
  • URL elicitation example uses webbrowser.open() for cross-platform browser opening.

Tests:

  • uv run pytest -q tests/cli/test_utils.py
  • uv run ruff check src/mcp/cli/cli.py tests/cli/test_utils.py examples/snippets/clients/url_elicitation_client.py

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.

1 participant