Skip to content

docs(client): complete ClientSession Args blocks and guard against drift (#3846) - #3960

Closed
wangkangmao wants to merge 2 commits into
modelcontextprotocol:mainfrom
wangkangmao:docs/complete-session-args-3846
Closed

wangkangmao wants to merge 2 commits into
modelcontextprotocol:mainfrom
wangkangmao:docs/complete-session-args-3846

Conversation

@wangkangmao

Copy link
Copy Markdown

Fixes #3846

Summary

Complete the Google-style Args: blocks on the four ClientSession request methods whose rendered API reference was silently missing parameters. Add an AST-based regression test that fails whenever a public parameter is absent from its Args: section.

Root cause

src/mcp/client/session.py renders docstrings verbatim (mkdocstrings, no show_overloads), so a parameter omitted from an Args: 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:

Method Parameters that were undocumented
send_request request, result_type, request_read_timeout_seconds, progress_callback
read_resource uri, meta
call_tool name, arguments, read_timeout_seconds, progress_callback, meta
get_prompt name, arguments, meta

uri, request, name and arguments are mandatory, so the rendered reference showed only the optional kwargs and hid the arguments callers must pass. The higher-level Client.read_resource (src/mcp/client/client.py) already documents both uri and meta correctly, confirming the drift is local to ClientSession.

I confirmed the drift with an AST comparison on main at 77001c96: every method's real parameter list (from the implementation signature) was checked against the names in its Args: section; all four methods had gaps.

Changes

  • src/mcp/client/session.py: add the 14 missing Args: entries above (±documented wording mirrors the existing style and the correct Client docstrings). Docstrings only — no behaviour change.
  • tests/client/test_docstring_args.py (new): parse ClientSession with ast, skip @overload stubs, and assert that every parameter of the four affected implementation methods appears in its Args: 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-types and . plus test deps):

python -m py_compile src/mcp/client/session.py                      # exit 0
python -m pytest tests/client/test_docstring_args.py -q            # 1 passed
python -m pytest tests/client/test_session.py -q                   # 94 passed
python -m pytest tests/client/test_docstring_args.py -q            # negative control: fails on HEAD (missing 14 params)
git diff --check                                                   # clean

AST alignment after the patch: send_request 5/5, read_resource 5/5, call_tool 9/9, get_prompt 6/6 parameters documented (all MISSING=[]). 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-issue bot 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.

@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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:

  • We're a small team with very little capacity to review community PRs right now.
  • Many recent PRs are AI-generated with little human review, and reviewing one carefully still costs a maintainer as much time as it ever did. A well-described issue is usually more useful to us than the code.

Maintainers: reopen, remove missing-issue-link, or add bypass-issue-check to override.

@github-actions github-actions Bot closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant