fix(cli): handle missing Windows npx without crashing
Closed
SA
17d ago+17+17+01234567890123456789-5-5-0123456789
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_objectto takeobjectinstead ofAny - 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.