Skip to content

Update tools/call input validation errors to be tool execution errors #824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fredericbarthelet
Copy link
Contributor

@fredericbarthelet fredericbarthelet commented Jul 30, 2025

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 in src/server/mcp.test.ts has been updated to reflect the new error reponse format.

Breaking Changes

None

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

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

@fredericbarthelet fredericbarthelet requested a review from a team as a code owner July 30, 2025 12:49
@fredericbarthelet fredericbarthelet requested a review from ihrpr July 30, 2025 12:49
Copy link
Member

@domdomegg domdomegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @fredericbarthelet, thanks for raising this PR!

I think as written, the spec would include these errors as protocol errors, as the fall under 'Invalid arguments'. So at this time I don't think we'd be willing to accept this PR.

However, it does raise a good point: it adds complexity to have two types of errors which are inconsistently handled in clients - resulting in the behaviour where models can't retry failed things in a range of cases.

Would you be open to raising a spec proposal in the main repo on this? https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/CONTRIBUTING.md

@domdomegg domdomegg removed the request for review from ihrpr August 4, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants