[BUG] OpenTelemetry logs MCP tools as generic 'mcp_tool' instead of specific tool names like 'mcp__context7__resolve-library-id'

Status Fixed / completed
Reported on v2.1.2
Maintainer reply None cached
Activity 7 comments · opened Jan 9, 2026 · closed Mar 25, 2026

Summary

When MCP tools are called, OpenTelemetry telemetry logs them with tool_name: "mcp_tool" instead of the specific tool name following the mcp__<server>__<tool> pattern. This prevents building dashboards that show MCP usage broken down by server name (e.g., context7, notion, sentry).

Steps to Reproduce

  1. Enable Claude Code telemetry with OTLP export to Loki:

``json
{
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_LOGS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317"
}
}
``

  1. Configure MCP servers (e.g., context7, notion, sentry)
  1. Make MCP tool calls in a Claude Code session
  1. Query the telemetry logs:

``bash
curl -G 'http://localhost:3100/loki/api/v1/query_range' \
--data-urlencode 'query={service_name="claude-code"}' | \
jq '.data.result[] | select(.stream.tool_name == "mcp_tool") | .stream'
``

Expected Behavior

Based on the monitoring-usage documentation, tool_name should contain the full MCP tool name:

{
  "tool_name": "mcp__context7__resolve-library-id",
  "event_name": "tool_result",
  "success": "true"
}

This would allow grouping/filtering by MCP server name using regex like mcp__(?P<mcp_server>[^_]+)__.*.

Actual Behavior

All MCP tools are logged with a generic tool_name:

{
  "tool_name": "mcp_tool",
  "mcp_server_scope": "user",
  "event_name": "tool_result",
  "success": "true"
}

There is no field indicating which specific MCP server (context7, notion, sentry) was called.

Impact

Cannot build Grafana dashboards showing:

  • Top MCP servers by call count
  • MCP usage breakdown by server name
  • Performance metrics per MCP server

Proposed Solution

Either:

  1. Option A: Log the full tool name as mcp__<server>__<tool> in the tool_name field (matching documentation)
  2. Option B: Add a separate mcp_server_name field to the telemetry attributes

Environment

  • Claude Code version: 2.1.2
  • OS: macOS (Darwin 24.6.0)
  • MCP servers: context7, notion, sentry (all working correctly)

Evidence

Telemetry stream for an MCP call:

{
  "tool_name": "mcp_tool",
  "mcp_server_scope": "user",
  "event_name": "tool_result",
  "duration_ms": "1838",
  "success": "true",
  "session_id": "2dae27f9-d02e-43f9-99cb-4eb835457f09",
  "service_version": "2.1.2"
}

Compare to non-MCP tools which log correctly:

{
  "tool_name": "Bash",
  "event_name": "tool_result"
}

Related

  • Hooks documentation shows MCP tools follow mcp__<server>__<tool> pattern
  • Not related to #16371 (that issue is about tools not being registered; our MCP tools work fine)

View original on GitHub ↗

7 Comments

tech4242 · 7 months ago

+1 on this one! This would be super helpful and as long as it is optional I cannot imagine why this cannot be done.

tcvall86 · 7 months ago

So the thing is that this used to work for us. In our telemetry data I can see that we used to get logs with

mcp__<mcp server>__<mcp_tool_name>
It definitely worked in 2.0.76 so must have been introduced somewhere in 2.1.X

<img width="840" height="85" alt="Image" src="https://github.com/user-attachments/assets/8c11962c-d944-4dc8-802d-00286346b794" />

<img width="1067" height="156" alt="Image" src="https://github.com/user-attachments/assets/4e91ab94-a2c4-4488-9abd-4dd630e2158b" />

Edit: after further investigation it seems to have been working in 2.1.1 also

<img width="1148" height="38" alt="Image" src="https://github.com/user-attachments/assets/6c8ffce3-ed37-4a83-9fdf-2b5a1c9232b4" />

mrbaker4 · 7 months ago

+1 on this. Would love to better understand what MCP tools my team is using.

tech4242 · 7 months ago
+1 on this. Would love to better understand what MCP tools my team is using.

& I agree with OP in marking this as a bug - can't imagine any privacy benefit (given it is opt-in)

tcvall86 · 6 months ago

Ok so I got tired of no responses in this one. If you are still affected by this here comes a little summary of my findings

In 2.1.2 we can see the following changelog
https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#212

Fixed MCP tool names being exposed in analytics events by sanitizing user-specific server configurations

Sure.
We also see a new env var being available for Claude

OTEL_LOG_TOOL_DETAILS | Enable logging of MCP server/tool names and skill names in tool events (default: disabled) | 1 to enable

Alright so if we toggle this we can see in a claude_code.tool_result otel response

{
    "key": "tool_parameters",
    "value": {
        "stringValue": "{\"mcp_server_name\":\"<mcp-server>\",\"mcp_tool_name\":\"<actual_tool_name>\"}"
    }
},

This should help anyone building dashboards for the mcp tools

kushal-thakkar · 5 months ago

I shipped a fix for this issue in Jan 2026. The opt-in env var needs to be enabled: OTEL_LOG_TOOL_DETAILS=1

When enabled, the tool_parameters field in OTel events includes: {"mcp_server_name": "<server>", "mcp_tool_name": "<tool>"}

github-actions[bot] · 4 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.