Add httpx.HTTPStatusError error handling to tool run #1119
+56
−0
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.
This change adds httpx.HTTPStatusError handling to the tool run class to provide detailed error information when returning from the MCP server.
Motivation and Context
The default error message from httpx does not have detailed information on the exception thrown. Our tools use httpx to make API calls and it would be much easier for us to
raise_for_status
and not have to catch the exception to format a better message to be rasied.Current tool implementation example
This is currently what we have to do to get a detailed exception message to the mcp tool run handler.
Ideal tool implementation
Current response format
Ideal response
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context