[BUG] OpenTelemetry logs MCP tools as generic 'mcp_tool' instead of specific tool names like 'mcp__context7__resolve-library-id'
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
- 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"
}
}
- Configure MCP servers (e.g., context7, notion, sentry)
- Make MCP tool calls in a Claude Code session
- 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:
- Option A: Log the full tool name as
mcp__<server>__<tool>in thetool_namefield (matching documentation) - Option B: Add a separate
mcp_server_namefield 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)
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗