[mcp-core] Clarify tool input validation error message. Fixes #986#989
Open
HarshMehta112 wants to merge 1 commit into
Open
[mcp-core] Clarify tool input validation error message. Fixes #986#989HarshMehta112 wants to merge 1 commit into
HarshMehta112 wants to merge 1 commit into
Conversation
Signed-off-by: Harsh Mehta <harshmehta010102@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tool input validation reused the JSON schema validator's output-oriented error message, producing misleading errors that referenced
structuredContentandoutputSchemaeven when the failure was about atool's input arguments. This makes the input validation message clearly refer to input.
Motivation and Context
Tool input validation (added in #873) reuses
JsonSchemaValidator.validate(schema, content), whose error message is hardcoded for output validation. On invalid input, consumers/LLMs received:This is misleading — the failure is about input arguments, not output. Fixes #986.
The fix adds a context-aware overload
validate(schema, content, dataDescription)(adefaultmethod delegating to the existing 2-arg method, so it's backward compatible for custom validatorimplementations). Input validation now passes an input-specific description, producing:
Output validation continues to use the 2-arg method and is unchanged.
ToolInputValidationIntegrationTests(sync + async, Tomcat streamable HTTP): asserts the error message references input (inputSchema) and does not containoutputSchema/structuredContent.Previously only checked a single substring (
age/minimum).ToolInputValidatorTests: verifies the input-specific description is passed to the validator.DefaultJsonSchemaValidatorTests(jackson2 + jackson3): added coverage for the new 3-arg overload; existing 2-arg output-message tests left unchanged.spring-javaformat:validate.Breaking Changes
None. The new interface method is a
defaultthat delegates to the existing method, so customJsonSchemaValidatorimplementations require no changes. Output validation behavior and messages are unchanged.Types of changes
Checklist
Additional context
The validator already carries tool-specific wording (
tool outputSchema), so adding a symmetric input-aware path is consistent with the existing design. An alternative — making the validator's message fullygeneric and having callers prepend context — was rejected because it would also change the output message, widening scope beyond this issue.