Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.py
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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分
- マージ済み PR(30日)
- 32
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
-
docs pydanty:is-working
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
pydantic/pydantic-ai#10113 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
GreedyBear-Project/GreedyBear#1727 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
ARM-software/CMSIS-DSP#354 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
kiat/codeAssist#391 ·
-
needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
darnitdevorg/darnit#587 ·
メンテナーはふだん 1 日以内に返信