docs(client): ClientSession documents only the input-required kwargs, not its mandatory parameters

Đang mở Phù hợp với người mới
#3,846 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

  • #3848 của @lxcxjxhx — đã đóng, không merge
  • #3960 của @wangkangmao — đã đó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
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
documentation

Hướng nghiên cứu

Đọc các khối Args của ClientSession.send_request, call_tool, get_prompt và read_resource trong src/mcp/client/session.py, rồi so sánh chữ ký của chúng với các tham số được mô tả trong src/mcp/client/client.py. Bổ sung mô tả cho các tham số còn thiếu, dùng lại cách diễn đạt từ lớp Client khi có thể. Hoàn thành khi cả bốn khối Args đều mô tả các tham số mà từng phương thức chấp nhận.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

documentation

What is wrong

ClientSession.read_resource (src/mcp/client/session.py, docstring at 933) has a Google-style Args: block that lists only the three optional input-required kwargs:

documented in Args: ['input_responses', 'request_state', 'allow_input_required']
real parameters   : ['uri', 'input_responses', 'request_state', 'meta', 'allow_input_required']
UNDOCUMENTED      : ['uri', 'meta']

uri is the only parameter without a default, so the rendered API reference documents the optional arguments and hides the mandatory one. meta is undocumented as well.

The higher-level Client.read_resource (src/mcp/client/client.py:662,666) documents both correctly, so this looks like drift confined to the session layer rather than an intentional omission.

Minimal reproduction

import inspect
from mcp.client.session import ClientSession

print(inspect.signature(ClientSession.read_resource))
# (uri: AnyUrl, input_responses: ... = None, request_state: ... = None,
#  meta: ... = None, allow_input_required: bool = False) -> ReadResourceResult

Scope of the drift

The same pattern appears on three neighbouring methods in the same class, measured the same way on main — every one of them documents the input-required kwargs and nothing else, which suggests the block was written once and copied:

Method Documented in Args: Actually accepted
send_request (l. 540) metadata request, result_type, request_read_timeout_seconds, metadata, progress_callback
call_tool (l. 1052) input_responses, request_state, allow_input_required, allow_claimed name, arguments, read_timeout_seconds, progress_callback, input_responses, request_state, meta, allow_input_required, allow_claimed
get_prompt (l. 1217) input_responses, request_state, allow_input_required name, arguments, input_responses, request_state, meta, allow_input_required

call_tool is the most visible case: name and arguments are the two parameters every caller passes and neither is documented.

Proposed fix

Add the undocumented parameters to each Args: block, reusing the wording already used in the Client layer where the same parameter appears. Docstring-only, one file, no behaviour change; ruff check and ruff format --check pass on the file.

I am proposing this as one issue, because the four blocks share a cause and the fix is one file. Say the word if you would rather take read_resource alone and file the rest separately, and I will split it.

Willing to open a PR?

Yes — assign this to me (or label it help wanted) and I'll send it. I've read the intake gate and will include Fixes #<this> plus the AI-assistance disclosure the contributing guide asks for.

Ngôn ngữ chính
Python
Star
25k
Fork
4.2k
Merge trung bình
10 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/python-sdk

Tất cả issue của modelcontextprotocol/python-sdk

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.