Repository navigation
Conversation
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.
Description
When an MCP tool call returns a result with
isError=true, the span currently looks like a success, so failed tool calls can't be counted or alerted on. This setserror.typeto"tool_error"on the span in that case, for both the mcp 1.x handler wrapper and the mcp 2.x tool-call middleware (including the 2.xMCPServer, which turns a raised tool exception into anisErrorresult).This follows the OTel MCP conventions, which say
error.typeSHOULD be"tool_error"when aCallToolResulthasisErrorset to true:https://github.com/open-telemetry/semantic-conventions-genai/blob/4a39b6ef1363fab57bc40e18c82abb32cc89ebcd/docs/gen-ai/mcp.md#L187-L192
It also matches what the JS SDK does.
The span status is left unchanged, as discussed in the issue (the JSON-RPC call itself succeeded, like the GraphQL 200 case). No custom attribute is added.
Tests cover
isErrortrue/false, a raisingMCPServertool, and a raised exception in a lowlevel handler (noerror.type, existing behaviour), in static and streaming mode, on mcp 2.x and 1.x.Issues