Repository navigation
fix(tools): Reject unknown arguments and record the error code on tool spans - #91
Merged
Merged
Conversation
A tool silently ignored an unknown argument, for example `goals` on get_breakdown. The caller then got data that did not apply the filter it asked for. The input schemas are now strict: the SDK returns an input validation error that names the unknown key, and Plausible gets no request. Fixes #83 Co-authored-by: Claude <claude@anthropic.com>
A failed tool call now sets `error.type` on its mcp.server span to the code that the client receives, so traces can be filtered by cause. Only the code is recorded, because the message can contain user input. Fixes #84 Co-authored-by: Claude <claude@anthropic.com>
The Sentry MCP integration sets `error.type` to `tool_error` when it sends a failed tool result, after the handler ran, so the code written there was lost. Write it to `app.tool.error.code` instead. A new test runs the real Sentry wrapper and checks the exported span; it fails with the old attribute name. Co-authored-by: Claude <claude@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.
Two small changes to tool calls.
Unknown arguments are now rejected. Before, a tool ignored an argument it did not declare. For example,
get_breakdownwithgoals: "Signup"returned unfiltered data, and the caller did not know that the filter was not applied. Each tool input schema is now strict (additionalProperties: false). The SDK returns an input validation error that names the unknown key, and Plausible gets no request. MCP request metadata (_meta) is besidearguments, not inside it, so known clients are not affected.Failed tool spans get the error code. A failed tool call now sets
app.tool.error.codeon itsmcp.serverspan to the code the client receives (invalid_input,unauthorized,rate_limited,upstream_unavailable,invalid_query,internal). It is noterror.type, because the Sentry MCP integration sets that totool_errorwhen it sends the result. Only the code is recorded, because the message can contain user input. TELEMETRY.md documents this.Each change has tests that failed on the old code.
__tests__/tool-error-span.test.tsruns the real Sentry wrapper and checks the exported span, so an SDK overwrite makes it fail.Fixes #83
Fixes #84
Created with Claude Code