Update tools/call input validation errors to be tool execution errors #824
+16
−37
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.
Reporting input validation errors as Tool Execution Errors instead of Protocol Errors in order to increase model self-recovery success rate.
Motivation and Context
The tools error handling specs is quite vague on wether input validation errors shall be treated as Protocol Errors (following the Invalid arguments exemple) or as Tool Execution Errors (following the Invalid input data exemple).
Only Tool Execution Errors are injected back into the LLM context window, just like successful responses. Input validation error messages can be leveraged by the model as much as any other prompt, giving it a chance to recover from the error without human intervention.
How Has This Been Tested?
The
should validate tool args
test suite insrc/server/mcp.test.ts
has been updated to reflect the new error reponse format.Breaking Changes
None
Types of changes
Checklist
Additional context
I am the author of the following article on MCP tool execution errors : Better MCP tools/call Error Responses: Help Your AI Recover Gracefully