Skip to content

fix: report refused calls as error results instead of exceptions - #8

Merged
fuseraft merged 1 commit into
masterfrom
fix/tool-error-results
Oct 18, 2026
Merged

fuseraft merged 1 commit into
masterfrom
fix/tool-error-results

Conversation

@fuseraft

Copy link
Copy Markdown
Owner

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 full stack trace. The client got the reason prefixed with "An error occurred invoking 'x':".

They now return a CallToolResult with isError: true that holds just the reason. Nothing is lost from the log: QueryService already writes a warning for each failed call. The README's description of errors ("returned as tool results with isError: true") was already right, and still is.

Found while driving sql-mcp from fuseraft: a refused admin_pg call left a 15-line stack trace in the server's stderr under "fail".

Tests

  • New A_refused_call_is_an_error_result_with_just_the_reason calls query_database over HTTP. It fails before the change.
  • Full suite against local Postgres 16, MySQL 8.4, SQL Server 2022 and Oracle 23 Free: 307 passed, 0 skipped.

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.
@fuseraft
fuseraft merged commit 53c36b5 into master Oct 18, 2026
2 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.

1 participant