Skip to content

fix(cli): handle missing Windows npx without crashing - #3687

Closed
Sak3th2004 wants to merge 1 commit into
modelcontextprotocol:mainfrom
Sak3th2004:fix/windows-npx-filenotfound
Closed

Sak3th2004 wants to merge 1 commit into
modelcontextprotocol:mainfrom
Sak3th2004:fix/windows-npx-filenotfound

Conversation

@Sak3th2004

Copy link
Copy Markdown

Summary

On Windows, probing for npx via subprocess.run can raise FileNotFoundError when the executable is absent. _get_npx_command() previously only caught CalledProcessError, so mcp dev could crash instead of returning None and printing the existing missing-npx guidance.

This change:

  • Catches (CalledProcessError, FileNotFoundError) in _get_npx_command()
  • Adds return annotations for _get_npx_command, _import_server, and _check_server_object
  • Tightens _check_server_object to take object instead of Any
  • Extends CLI unit tests for the missing-binary path

Fixes #3673

Test plan

  • Added test_get_npx_returns_none_when_windows_binary_missing
  • CI: tests/cli/test_utils.py

AI assistance: used Cursor to draft the patch and PR text; I own the change and can iterate on review feedback.

Catch FileNotFoundError when probing npx on Windows, add return annotations for CLI helpers, and cover the missing-binary path in unit tests. Fixes modelcontextprotocol#3673.
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3673.

If a maintainer assigns you to #3673, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take.

You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way.

CONTRIBUTING.md has the full reasoning, but in short:

  • We're a small team with very little capacity to review community PRs right now.
  • Many recent PRs are AI-generated with little human review, and reviewing one carefully still costs a maintainer as much time as it ever did. A well-described issue is usually more useful to us than the code.

Maintainers: reopen, remove missing-issue-link, or add bypass-issue-check to override.

@github-actions github-actions Bot closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.py

2 participants