Skip to content

Tool input validation returns with misleading error referencing outputSchema #986

@maff

Description

@maff

Bug description

The tool input validation introduced in #873 returns with a misleading error message referencing outputSchema when validation fails. For example, the first test case in
ToolInputValidationIntegrationTests#invalidInput_withDefaultValidation_shouldReturnToolError leads to the following error message, but only tests for the presence of age in the error message substring:

Validation failed: structuredContent does not match tool outputSchema. Validation errors: [: required property 'age' not found]

Instead of referring to structuredContent and outputSchema, the error message should clearly indicate that the error is referring to the input data as otherwise it's misleading to consumers/LLMs.

Environment

MCP SDK 2.0.0-M3 (via Spring AI 2.0.0-M7)

Steps to reproduce

  • Run ToolInputValidationIntegrationTests#invalidInput_withDefaultValidation_shouldReturnToolError & inspect the produced error message.
  • or create an MCP server with tool input validation enabled and call a tool with invalid input data

Expected behavior

  • A concise error response stating that the listed schema validation errors refer to input parameters.
  • Better assertions in the tool input validation test, not only checking for presence of a substring.

Minimal Complete Reproducible example

See steps to reproduce.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions