Skip to content

feat(core): emit canonical MCP semantic attributes - #25060

Draft
betegon wants to merge 1 commit into
developfrom
bt/mcp-otel-attributes
Draft

betegon wants to merge 1 commit into
developfrom
bt/mcp-otel-attributes

Conversation

@betegon

@betegon betegon commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

MCP spans emit legacy names and flattened content without the canonical OpenTelemetry attributes. Add JSON-RPC request IDs, GenAI tool/prompt names, tool-only execute_tool, case-sensitive prompt variables, and serialized tool arguments and successful results, following the OpenTelemetry MCP conventions. Preserve legacy attributes and the existing input/output capture options.

For a successful tool result with content: [{ type: "text", text: "Hello" }], before we emit only flattened fields such as mcp.tool.result.content = "Hello". After we also emit gen_ai.tool.call.result = '{"content":[{"type":"text","text":"Hello"}]}'. Multiple blocks remain an array inside that JSON value; existing indexed legacy keys remain unchanged.

Canonical content excludes protocol metadata and continuation state, and is omitted if serialization fails or exceeds the 20,000-character Sentry capture budget. Structured tool output supports any JSON value. Real MCP SDK v1/v2 coverage checks streamed spans in ESM/CJS with capture enabled and disabled.

#25059 is merged; this branch is rebased on develop and uses published @sentry/conventions@0.27.0. Before releasing this payload change, confirm the conventions deployment in Snuba and the Sentry backend, then Relay, and deploy Relay #6511 and Sentry #127361 for scrubbing and frontend compatibility. Merge status alone does not establish deployment. Network metadata (#24506) and OAuth attribution (#24508) remain separate changes.

Validated the 48-project SDK build, formatting and lint, 168 MCP unit tests, and eight real MCP SDK v1/v2 ESM/CJS integration tests after rebase.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.83 kB - -
@sentry/browser - with treeshaking flags 27.96 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.87 kB - -
@sentry/browser (incl. Tracing) 52.02 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.02 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.96 kB - -
@sentry/browser (incl. Tracing, Replay) 91.75 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.62 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 96.47 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 109.43 kB - -
@sentry/browser (incl. Feedback) 47.35 kB - -
@sentry/browser (incl. sendFeedback) 34.89 kB - -
@sentry/browser (incl. FeedbackAsync) 40 kB - -
@sentry/browser (incl. Metrics) 30.85 kB - -
@sentry/browser (incl. Logs) 31.13 kB - -
@sentry/browser (incl. Metrics & Logs) 31.78 kB - -
@sentry/react 31.64 kB - -
@sentry/react (incl. Tracing) 54.34 kB - -
@sentry/vue 37.98 kB - -
@sentry/vue (incl. Tracing) 54.95 kB - -
@sentry/svelte 29.86 kB - -
@sentry/remix (Remix 3 client bundle) 57.02 kB - -
CDN Bundle 31.56 kB - -
CDN Bundle (incl. Tracing) 52.52 kB - -
CDN Bundle (incl. Logs, Metrics) 33.77 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 54.46 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.7 kB - -
CDN Bundle (incl. Tracing, Replay) 90.19 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92.11 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.34 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.28 kB - -
CDN Bundle - uncompressed 92.98 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.83 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.52 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 161.79 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.56 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 276 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 281.94 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 289.7 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 295.63 kB - -
@sentry/nextjs (client) 56.75 kB - -
@sentry/sveltekit (client) 52.41 kB - -
@sentry/core/server 41.51 kB +0.95% +387 B 🔺
@sentry/core/browser 13.81 kB - -
@sentry/node 152.26 kB +0.2% +292 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.78 kB - -
@sentry/node - without tracing 94.54 kB +0.01% +3 B 🔺
@sentry/node - without channel injection 130.48 kB +0.24% +311 B 🔺
@sentry/aws-serverless 102.69 kB +0.01% +7 B 🔺
@sentry/cloudflare (withSentry) - minified 210.38 kB - -
@sentry/cloudflare (withSentry) 521.61 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 228.06 kB - -

View base workflow run

betegon added a commit that referenced this pull request Oct 13, 2026
Use `@sentry/conventions/attributes` for registered MCP keys, including
all singleton and indexed result fields. The branch now uses published
conventions `0.27.0` from `develop`, so both local result prefixes can
be removed.

Before, the SDK constructed `mcp.tool.result.0.content` from a local
prefix. After, `MCP_TOOL_RESULT_KEY_CONTENT.replace('<key>', '0')`
produces that same key. Singleton keys, values, original array indexes,
and input/output capture behavior remain unchanged. Deprecated
tool-result fields stay emitted for compatibility; this change adds no
aliases or backfill.

This is the mechanical base for network metadata (#24506), OAuth
attribution (#24508), and canonical OpenTelemetry attributes (#25060).
The latter separately adds complete serialized results in
`gen_ai.tool.call.result`.
@betegon
betegon force-pushed the bt/mcp-otel-attributes branch from a038085 to 29abc47 Compare October 14, 2026 08:52

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.

1 participant