Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.py
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #3687 của @Sak3th2004 — đã đóng, không merge
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
Hướng nghiên cứu
Đọc src/mcp/cli/cli.py, tập trung vào _get_npx_command, _import_server và _check_server_object. Kiểm tra cách bước dò tìm npx trên Windows xử lý trường hợp thiếu tệp thực thi, sau đó chạy các bài kiểm tra CLI liên quan cùng các bước kiểm tra Ruff và Pyright đã nêu. Công việc hoàn tất khi ngoại lệ được xử lý và các chú thích kiểu được yêu cầu vượt qua những bước kiểm tra này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- Python
- Star
- 24.5k
- Fork
- 4k
- Merge trung bình
- 18 giờ 31 phút
- Pull request đã merge (30 ngày)
- 38
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/python-sdk
-
Streamable HTTP: Content-Type handling is order dependent and accepts invalid valuesCó thể đã có người làm @jayzuccarelli đã nhận 1 ngày trước. Đang mởbug v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
modelcontextprotocol/python-sdk#3691 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/python-sdk#3685 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Streamable HTTP server rejects a mixed-case Content-Type with 415Có thể đã có người làm @CRYPTONIKAV đã nhận 3 ngày trước. Đang mởbug v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelcontextprotocol/python-sdk#3670 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Audio(data=b"") raises "Either path or data can be provided", while Image(data=b"") worksCó thể đã có người làm @ajay206 đã nhận 1 ngày trước. Đang mởbug v1 v2
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
modelcontextprotocol/python-sdk#3656 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
modelcontextprotocol/python-sdk#3655 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/python-sdk
Issue tương tự
-
Atomic append fails to create a missing fileCó thể đã có người làm @harbinresearcher đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
fabiocaccamo/python-fsutil#201 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
danparshall/claude_researcher#87 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
GhostManager/Ghostwriter#998 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
datajoint/datajoint-python#1586 ·
Maintainer thường phản hồi trong vòng 1 ngày