Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.py
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #3687 by @Sak3th2004 — closed without merging
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Read src/mcp/cli/cli.py, focusing on _get_npx_command, _import_server, and _check_server_object. Check how the Windows npx probe handles a missing executable, then run the relevant CLI tests and the stated Ruff and Pyright checks. Done when the exception is handled and the requested annotations pass those checks.
Written by the indexing model from the issue text.
Description
Environment / Context
While running static analysis (ruff check --select ANN and pyright) on src/mcp/cli/cli.py during local development, I noticed a few missing type annotations and an uncaught exception edge case on Windows.
Description
-
Unhandled
FileNotFoundErrorin_get_npx_command:
Insrc/mcp/cli/cli.py,_get_npx_command()attempts to probe fornpxexecutables on Windows inside atry...except subprocess.CalledProcessError:block. Ifnpx.cmdornpx.exeis missing from the system entirely,subprocess.runraisesFileNotFoundErrorbeforeCalledProcessErrorcan be raised, causing an unexpected crash instead of returningNone. -
Missing Return Type Annotations (
ANN202):_get_npx_command()lacks a return type annotation (returnsstr | None)._import_server()lacks a return type annotation._check_server_object()lacks a return type annotation (-> bool).
-
AnyType Usage (ANN401):_check_server_object()usesserver_object: Any, which can be tightened toobjectsince it performs runtimeisinstancechecks.
Proposed Fix
- Update
_get_npx_command()to catch(subprocess.CalledProcessError, FileNotFoundError)and returnstr | None. - Add explicit return type annotations to
_import_serverand_check_server_object. - Replace
server_object: Anywithserver_object: object.
I would be happy to submit a PR for this if a maintainer is willing to assign the issue to me!
I know that the contributing guidelines for this project forbid direct PRs about formatting and such without assigning, so just putting this out there.
(Note: Disclosing per guidelines that AI tools were used to assist in local testing and analysis; I am ready to own, test, and answer questions on the proposed changes).
- Dominant language
- Python
- Stars
- 24.6k
- Forks
- 4.2k
- Avg merge
- 10h 37m
- Merged PRs (30d)
- 38
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/python-sdk
-
OAuth token expiry equality boundary causes intermittent downstream test failuresMay be free again A pull request for this issue was closed without being merged. Openbug v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
modelcontextprotocol/python-sdk#3729 · 2 comments ·
Maintainers usually reply within 1 day
-
bug v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
modelcontextprotocol/python-sdk#3725 · 4 comments ·
Maintainers usually reply within 1 day
-
bug v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelcontextprotocol/python-sdk#3698 · 2 comments ·
Maintainers usually reply within 1 day
-
Streamable HTTP: Content-Type handling is order dependent and accepts invalid valuesMay be free again @jayzuccarelli claimed this 8 days ago, and no pull request is open. Openbug v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
modelcontextprotocol/python-sdk#3691 · 1 comment ·
Maintainers usually reply within 1 day
-
Skills: URI traversal validation skips percent-encoded dot-segmentsMay be free again @Varshith-Kali claimed this 7 days ago, and no pull request is open. Openbug v2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelcontextprotocol/python-sdk#3685 · 2 comments ·
Maintainers usually reply within 1 day
All issues in modelcontextprotocol/python-sdk
Similar issues
-
Use mhctools predictor_required=False for saved-result rescoringPossibly taken @iskandr claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
521xueweihan/HelloGitHub#4051 · 1 comment ·
-
bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
awslabs/visual-asset-management-system#514 ·
Maintainers usually reply within 1 day
-
backend bug spec:REQ-053
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
nolte/kamerplanter#2547 ·
Maintainers usually reply within 1 day