Skip to content

fix(mcptools): always emit mcp.method.name attribute on MCP tracing spans - #9749

Open
Aryanbhargava18 wants to merge 2 commits into
jaegertracing:mainfrom
Aryanbhargava18:fix-mcp-tracing-method-name-9748
Open

Aryanbhargava18 wants to merge 2 commits into
jaegertracing:mainfrom
Aryanbhargava18:fix-mcp-tracing-method-name-9748

Conversation

@Aryanbhargava18

@Aryanbhargava18 Aryanbhargava18 commented Oct 4, 2026 •

Copy link
Copy Markdown

Which problem is this PR solving?

Resolves #9748

In cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/middleware.go, otelsemconv.McpMethodName(method) was previously only appended inside the else block when toolName == "". As a result, tool execution requests (tools/call) recorded gen_ai.operation.name and gen_ai.tool.name, but omitted mcp.method.name.

Per the OpenTelemetry GenAI Semantic Conventions for MCP server spans, mcp.method.name is marked as Required on all MCP spans (including tools/call). Furthermore, the specification explicitly notes:

"Populating this attribute for tool calling along with mcp.method.name allows consumers to treat MCP tool calls spans similarly with other tool call types."

This also aligns the tracing middleware with TestMetricsMiddlewareToolCallSuccess in the same package, which already asserts both gen_ai.tool.name and mcp.method.name.

Description of the changes

  • Initialize attrs with otelsemconv.McpMethodName(method) in createTracingMiddleware so it is unconditionally recorded on all MCP spans.
  • Update TestTracingMiddlewareToolCallSuccess in middleware_test.go to assert the presence of mcp.method.name.

How was this change tested?

  • Unit tests in cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/middleware_test.go.

…pans

Signed-off-by: Aryan Bhargava <aryanbhargava644@gmail.com>
…pans

Signed-off-by: Aryan Bhargava <aryanbhargava644@gmail.com>
@Aryanbhargava18
Aryanbhargava18 requested a review from a team as a code owner October 4, 2026 12:20

This branch has not been deployed

No deployments
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.

[Bug]: MCP tracing middleware omits required mcp.method.name attribute on tool execution spans

1 participant