Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.py
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
閱讀 src/mcp/cli/cli.py,重點查看 _get_npx_command、_import_server 和 _check_server_object。檢查 Windows 上的 npx 探測如何處理執行檔缺失的情況,接著執行相關的 CLI 測試,以及指定的 Ruff 和 Pyright 檢查。例外獲得處理,且要求的註解通過這些檢查後,即表示完成。
由索引模型根據 Issue 內容生成。
描述
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).
- 主要語言
- Python
- 星號
- 24.5k
- 分支
- 4k
- 平均合併
- 15 小時 19 分鐘
- 30 天內合併 PR
- 32
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
modelcontextprotocol/python-sdk 的其他 Issue
-
Streamable HTTP server rejects a mixed-case Content-Type with 415可能已有人在做 @CRYPTONIKAV 於 1 天前認領。 未關閉bug v1 v2
難度 2/5 1-3 小時 新手友好度 75/100
modelcontextprotocol/python-sdk#3670 · 2 則留言 ·
維護者通常 1 天內回覆
-
Bug in the MCP Apps documentation.可能已有人在做 @Kludex 今天認領。 未關閉documentation v2
難度 2/5 1-3 小時 新手友好度 82/100
modelcontextprotocol/python-sdk#3662 ·
維護者通常 1 天內回覆
-
Audio(data=b"") raises "Either path or data can be provided", while Image(data=b"") works可能已有人在做 @KaiyiQuan 於 3 天前認領。 未關閉bug v1 v2
難度 1/5 1 小時以內 新手友好度 85/100
modelcontextprotocol/python-sdk#3656 · 1 則留言 ·
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 66/100
modelcontextprotocol/python-sdk#3655 ·
維護者通常 1 天內回覆
-
Simple chatbot: unused Server.stdio_context attribute obscures transport ownership可能已有人在做 @Kludex 今天認領。 未關閉enhancement
難度 1/5 1 小時以內 新手友好度 86/100
modelcontextprotocol/python-sdk#3654 ·
維護者通常 1 天內回覆
查看 modelcontextprotocol/python-sdk 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
lugassawan/swe-workbench#799 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 74/100
vllm-project/vllm#61131 ·
維護者通常 1 天內回覆
-
Non-string form field names raise AttributeError when files are attached可能已有人在做 @nightcityblade 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
kubernetes-client/python#2735 ·
維護者通常 1 天內回覆
-
desktop help wanted test
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆