Skip to content

Add option to skip output validation for mcp client #2626

Open

Description

@germanbecker

Description

MCP Client session currently validates the output generated by MCP servers agains the reported json schema, and raises ValidationError.
This means that MCP server tools that have a not well maintained output schema, but are otherwise functional, are unusable.
The request is to add an option either at the ClientSession interface and/or the call_tool method so skip validation and return the result even if it does not conform to the output schemma

References

https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/client/session.py#L319-L349

Activity

  1. ernestprovo23 commented on May 22, 2026

    @ernestprovo23

    hey @germanbecker, would the right shape here be a validate_structured_output: bool = True kwarg on ClientSession.__init__? that's a one-flag gate at session.py:319-320 (only validation call site i can find), default true so nothing breaks for existing users.

    noticed #1189 went down this road last fall and got closed over the safety-vs-flexibility tradeoff. the difference this time is the framing... real-world driver is servers shipping buggy output schemas that are otherwise functional, not a perf concern. happy to take it on if a maintainer (cc @felixweinberger) thinks the use case clears the bar. if not, totally fine to close.

  2. germanbecker commented on May 23, 2026

    @germanbecker
    Author

    Hey! Thanks for looking into this! yes I think either at the __init__ level or at the call_tool would work. As for the justification, my example is a tool where the schema has a list of literals for an output, but it appears the maintainers forgot one possible literal. Since this will eventually be a text stream sent to an LLM, in some applications (like my case) is better so send the output that doesn't conform to schema than send an empty error

  3. germanbecker commented on May 23, 2026

    @germanbecker
    Author

    For reference the current workaround:

    class MyClientSession(ClientSession):
        async def _validate_tool_result(self, name: str, result: CallToolResult) -> None:
            pass
  4. added
    triageQueued for automated analysis — bot will process and remove this label
    on May 31, 2026
  5. ghost added
    enhancementRequest for a new feature that's not currently supported
    on Jun 1, 2026
  6. ghost added
    needs decisionIssue is actionable, needs maintainer decision on whether to implement
    on Jun 1, 2026
  7. ghost added
    P3Nice to haves, rare edge cases
    on Jun 1, 2026
  8. ghost removed
    triageQueued for automated analysis — bot will process and remove this label
    on Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesenhancementRequest for a new feature that's not currently supportedneeds decisionIssue is actionable, needs maintainer decision on whether to implement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions