Skip to content

Set IsError on CallToolResponse to true when result is ErrorContent #394

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

Merged

Conversation

Astaggrock
Copy link
Contributor

Currently when providing an ErrorContent type as the result to a tool the IsError property on the resulting CallToolResponse is not set to true.

Motivation and Context

To allow the calling client to understand the response is an error the IsError property should be set to true when an error has occurred within the tool invocation. Unlike throwing an exception this can protect any potential unwanted information being reported from the exception details.

How Has This Been Tested?

Adjusted sample tools to confirm IsError is being set to true when an ErrorContent result is returned

Breaking Changes

No

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

…e that all items in `contentItems` are instances of `ErrorContent` and that the collection is not empty
…n IEnumerable<AIContent> into a CallToolResponse
Copy link
Contributor

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Thanks.

@stephentoub stephentoub merged commit 47de86a into modelcontextprotocol:main May 9, 2025
18 of 21 checks passed
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