Repository navigation
docs(client): complete ClientSession Args blocks and guard against drift (#3846) - #3960
wangkangmao wants to merge 2 commits into
Conversation
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3846. If a maintainer assigns you to #3846, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take. You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
Fixes #3846
Summary
Complete the Google-style
Args:blocks on the fourClientSessionrequest methods whose rendered API reference was silently missing parameters. Add an AST-based regression test that fails whenever a public parameter is absent from itsArgs:section.Root cause
src/mcp/client/session.pyrenders docstrings verbatim (mkdocstrings, noshow_overloads), so a parameter omitted from anArgs:block does not get documented — it just disappears. The four affected methods omitted exactly the parameters that have no default value to copy from a neighbouring@overload:send_requestrequest,result_type,request_read_timeout_seconds,progress_callbackread_resourceuri,metacall_toolname,arguments,read_timeout_seconds,progress_callback,metaget_promptname,arguments,metauri,request,nameandargumentsare mandatory, so the rendered reference showed only the optional kwargs and hid the arguments callers must pass. The higher-levelClient.read_resource(src/mcp/client/client.py) already documents bothuriandmetacorrectly, confirming the drift is local toClientSession.I confirmed the drift with an AST comparison on
mainat77001c96: every method's real parameter list (from the implementation signature) was checked against the names in itsArgs:section; all four methods had gaps.Changes
src/mcp/client/session.py: add the 14 missingArgs:entries above (±documented wording mirrors the existing style and the correctClientdocstrings). Docstrings only — no behaviour change.tests/client/test_docstring_args.py(new): parseClientSessionwithast, skip@overloadstubs, and assert that every parameter of the four affected implementation methods appears in itsArgs:section. This guards the whole class of drift, not just today's four methods.Verification
Commands (Python 3.13, editable install of local
src/mcp-typesand.plus test deps):AST alignment after the patch:
send_request5/5,read_resource5/5,call_tool9/9,get_prompt6/6 parameters documented (allMISSING=[]). Line endings match the upstream LF blob (0 CRLF in the committed content), so the production diff is exactly +14/-0 with no CRLF noise.Note: a previous attempt (#3848) was closed by the
require-linked-issuebot because the author was not assigned to the issue; its content was docstrings-only. This PR keeps the same scope and adds the regression test suggested in the issue discussion.