Repository navigation
fix: flag failed tool calls with MCP's isError - #122
Merged
Merged
Conversation
Tools reported failures only through a ❌ text prefix, never through MCP's isError flag. Clients and test harnesses that read the flag saw every failure as a success, so `expect(result).not.toBeToolError()` could never fail. ResponseBuilder.error now sets isError. withToolAnalytics, which every tool passes through and which already treats a ❌-prefixed answer as an error, also sets it on the answers that tools build by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Tools reported a failure only through a
❌prefix in the answer text, never through MCP'sisErrorflag. Clients and test harnesses that read the flag treated every failure as a success. One result:expect(result).not.toBeToolError()intests/mcp/direct.spec.mjscould never fail.withToolAnalyticswraps every tool and already counts a❌-prefixed answer as an error for analytics, so the flag follows the same rule. That covers the roughly 40 answers that tools build by hand, without touching their files. Answers that only mention❌further down, such as the logs-analysis tables, stay successes.Split out of the review of #96: with this flag, an MCP-aware harness can tell that a tool call failed.
Evidence
yarn test: 419 passed, including 4 new cases insrc/core/analytics.test.ts:ResponseBuilder.error, a hand-built❌answer, a success, and markdown with❌further down.yarn test:mcp:direct: 12 passed. Two offline Azure tests now also asserttoBeToolError().tsc --noEmitand Prettier are clean.Merge Danger
Door: two-way
Blast Radius: what MCP clients see when a tool fails
isError: trueon failed calls. Hosts may show these differently, for example as a tool error rather than a normal result. The text is unchanged.tests/docker/validate-image.mjsalready treatsisErroror a leading❌as an error, so it is unaffected.🤖 Generated with Claude Code