Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#3,673 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
cli

調査の方向性

src/mcp/cli/cli.pyを読み、_get_npx_command、_import_server、_check_server_objectに注目してください。Windowsでのnpxの確認処理が実行ファイルの欠落をどのように扱うかを確認し、関連するCLIテストと指定されたRuffおよびPyrightのチェックを実行してください。例外が処理され、要求された注釈がこれらのチェックに合格したら完了です。

索引モデルが issue の本文から書いたものです。

説明

enhancement
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
  1. Unhandled FileNotFoundError in _get_npx_command:
    In src/mcp/cli/cli.py, _get_npx_command() attempts to probe for npx executables on Windows inside a try...except subprocess.CalledProcessError: block. If npx.cmd or npx.exe is missing from the system entirely, subprocess.run raises FileNotFoundError before CalledProcessError can be raised, causing an unexpected crash instead of returning None.

  2. Missing Return Type Annotations (ANN202):

    • _get_npx_command() lacks a return type annotation (returns str | None).
    • _import_server() lacks a return type annotation.
    • _check_server_object() lacks a return type annotation (-> bool).
  3. Any Type Usage (ANN401):

    • _check_server_object() uses server_object: Any, which can be tightened to object since it performs runtime isinstance checks.
Proposed Fix
  • Update _get_npx_command() to catch (subprocess.CalledProcessError, FileNotFoundError) and return str | None.
  • Add explicit return type annotations to _import_server and _check_server_object.
  • Replace server_object: Any with server_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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/python-sdk のほかの issue

modelcontextprotocol/python-sdk の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。