Repository navigation
fix: report refused calls as error results instead of exceptions - #8
Merged
Merged
Conversation
The tools threw McpException for every expected failure: an unknown database, a rejected statement, a login that can write. The SDK logged each one as an unhandled exception with a stack trace, and the client got the reason prefixed with "An error occurred invoking 'x':". They now return an isError CallToolResult holding just the reason; the query log's warning already records the failure.
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.
The tools threw
McpExceptionfor every expected failure: an unknown database, a rejected statement, a login that can write. The SDK logged each one as an unhandled exception with a full stack trace. The client got the reason prefixed with "An error occurred invoking 'x':".They now return a
CallToolResultwithisError: truethat holds just the reason. Nothing is lost from the log:QueryServicealready writes a warning for each failed call. The README's description of errors ("returned as tool results withisError: true") was already right, and still is.Found while driving sql-mcp from fuseraft: a refused
admin_pgcall left a 15-line stack trace in the server's stderr under "fail".Tests
A_refused_call_is_an_error_result_with_just_the_reasoncallsquery_databaseover HTTP. It fails before the change.