Repository navigation
Conversation
An SDK MCP tool handler that raises an empty-message exception (e.g. 'raise TimeoutError()') produced an error result whose text was an empty string, so the model could see that the tool failed but not why. Fall back to the exception type name, matching the existing fallback in Query._handle_sdk_mcp_request, so create_sdk_mcp_server's 'isError results the model can read' note holds.
Author
|
The empty-message MCP tool error fallback is green through |
This branch has not been deployed
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.
When an SDK MCP tool raises an exception with an empty message, such as
TimeoutError(), its error result contains an empty text block. The model receivesisError: truewithout any explanation.Fall back to the exception type name when
str(e)is empty, matchingQuery._handle_sdk_mcp_request. Exceptions with a message keep their existing text.The regression calls the tool through
Query, the in-memory JSON-RPC connection and the real MCP server. Against main1ea8cb74, it fails on both asyncio and Trio:[''] != ['TimeoutError']. With this one-line fix,python -m pytest tests/test_sdk_mcp_integration.py -qpasses 144 tests with both MCP 2.3.0 and the supported 1.23.0 floor (Python 3.13.3).Also passed
ruff check src/ tests/ scripts/andruff format --check src/ tests/ scripts/.mypy src/ scripts/passed with both MCP versions. No live Claude API or CLI was used. Upstream CI has not run yet.