feat(client): add validate_output flag to call_tool to skip output-schema revalidation - #3322
Conversation
…hema revalidation
|
Thanks for the contribution. This repository only keeps pull requests open when they're linked to an issue that a maintainer has assigned to the author — CONTRIBUTING.md explains why and how we work. This PR has been closed for now because you aren't currently assigned to #2626. If a maintainer would like this change as a PR from you, they'll assign you to #2626 and this PR will reopen automatically — there's nothing more you need to do. (If you opened the issue, this PR already shows up on its timeline.) There's no need to open a new PR — this one will be reopened. While it's closed, please push any updates as new commits rather than force-pushing, since GitHub can't reopen a PR whose branch has been rewritten. Maintainers: reopening this PR, removing the |
Fixes #2626.
This PR adds a
validate_output: bool = Truekeyword argument to bothClientSession.call_tool()and the high-levelClient.call_tool(). When set toFalse, the client skips revalidating the returned structured content against the tool's declared output schema, allowing callers to work with servers whose output schemas are incomplete or out of sync with the actual result.Changes:
validate_outputto allClientSession.call_tool()overloads and the implementation.validate_outputtoClient.call_tool()and threaded it through theInputRequiredretry loop and the claimed-result resolver path.test_call_tool_validate_output_false_skips_validation.Verified:
uv run --frozen pytest tests/client/test_output_schema_validation.py -xvspasses (6/6).uv run --frozen ruff formatandruff checkclean.uv run --frozen pyright src/mcp/client/session.py src/mcp/client/client.py tests/client/test_output_schema_validation.pyreports 0 errors.