Create specific ToolNotFoundError for easier handling than ToolError in multi-tenant environments#2423
Open
DevonFulcher wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
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.
Summary
Create a new error type
ToolNotFoundErrorthat is a more specific version of the genericToolError.closes #2422
Motivation and Context
We are running a remote MCP server and we are seeing errors like:
I'm unsure why our users are trying to call our remote MCP server with the name of a tool that we don't manage. Regardless, we would like to handle these errors separately from a generic
ToolError. For instance:ToolNotFoundError: user error that shouldn't alert us.ToolError: an error that could indicate an actual issue with our system that we should alert on and fix.How Has This Been Tested?
I added unit tests and successfully ran all tests locally.
Breaking Changes
There are no breaking changes in this PR. SDK users can still catch these as
ToolErroras they have done before.Types of changes
Checklist