Repository navigation
feat(mcp): align MCP attributes with OTel semantic conventions - #420
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
🤖 This preview updates automatically when you update the PR. |
0dce5f2 to
1106c3b
Compare
Align Sentry MCP attributes with the OTel MCP semantic conventions that merged in open-telemetry/semantic-conventions#2083 (Jan 2026). OTel's MCP convention is deliberately minimal: only 4 mcp.* registry attributes, reusing existing gen_ai.*, network.*, jsonrpc.*, and error.* namespaces for everything else. This commit brings Sentry conventions in line with that approach. Changes: Set is_in_otel=true on 4 direct matches: - mcp.method.name - mcp.protocol.version - mcp.resource.uri - mcp.session.id Deprecated 7 attributes with backfill to OTel equivalents: - mcp.tool.name → gen_ai.tool.name - mcp.prompt.name → gen_ai.prompt.name - mcp.tool.result.content → gen_ai.tool.call.result - mcp.tool.result.is_error → error.type - mcp.request.id → jsonrpc.request.id - mcp.transport → network.transport - mcp.resource.protocol → network.protocol.name Created 3 new attributes: - gen_ai.prompt.name (OTel gen_ai registry, aliased from mcp.prompt.name) - jsonrpc.request.id (OTel MCP common refs, aliased from mcp.request.id) - jsonrpc.protocol.version (OTel MCP common refs) 27 Sentry-only attributes remain unchanged (mcp.client.*, mcp.server.*, mcp.logging.*, mcp.progress.*, mcp.prompt.result.*, etc.) — these have no OTel equivalent.
1106c3b to
b747d41
Compare
The backfill deprecations on mcp.tool.name and mcp.tool.result.content point to gen_ai.tool.name and gen_ai.tool.call.result respectively, but the target attributes were missing the reciprocal alias entries. Add mcp.tool.name and mcp.tool.result.content to the alias arrays of their replacement attributes to maintain symmetric alias-group metadata. Regenerated JS and Python attribute files to reflect the changes.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d05ce84. Configure here.
# Conflicts: # python/src/sentry_conventions/attributes.py
…ted MCP attributes Fix CI failures caused by asymmetric alias relationships and deprecated attribute references in name templates: - Add reciprocal aliases to mcp.tool.result.content for the full alias group (gen_ai.tool.call.result, gen_ai.tool.message, gen_ai.tool.output) - Add mcp.tool.result.content to gen_ai.tool.message and gen_ai.tool.output alias lists - Add alias list to mcp.tool.name (gen_ai.tool.name, ai.function_call) - Add mcp.tool.name to ai.function_call alias list - Update mcp.json name templates to use gen_ai.tool.name and gen_ai.prompt.name instead of deprecated mcp.tool.name and mcp.prompt.name
…jsonrpc.request.id Address review feedback from loewenheim: string attributes should default to pii 'maybe' unless scrubbing would cause product degradation.
| "templates": [ | ||
| "{{mcp.method.name}} {{mcp.tool.name}}", | ||
| "{{mcp.method.name}} {{mcp.prompt.name}}", | ||
| "{{mcp.method.name}} {{gen_ai.tool.name}}", | ||
| "{{mcp.method.name}} {{gen_ai.prompt.name}}", |
There was a problem hiding this comment.
Bug: Updating span name templates to use gen_ai.* attributes may cause historical spans with mcp.* attributes to render with generic, less descriptive names.
Severity: MEDIUM
Suggested Fix
Verify the behavior of the span name templating engine. Confirm whether it considers attribute aliases or re-processes templates at query time for historical data. If it does not, consider delaying the template change or implementing a backfill mechanism to ensure backward compatibility for historical span names.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: model/name/mcp.json#L10-L12
Potential issue: The span name templates for MCP server operations have been updated to
use new `gen_ai.*` attributes instead of the deprecated `mcp.*` attributes. This change
creates a risk that historical spans, ingested before this change, may fail to match the
new templates. If the template resolution system does not consider aliases or
retroactively transform attributes for historical data, these older spans could fall
back to less descriptive, generic names. This would result in reduced observability and
debugging value for historical MCP server operations, creating an inconsistency between
how old and new spans are displayed.
## Bump sentry-conventions to 0.12.0 Updates `sentry-conventions` to [0.12.0](https://github.com/getsentry/sentry-conventions/releases/tag/0.12.0). ### Changes in 0.12.0 - Align MCP attributes with OTel semantic conventions ([sentry-conventions#420](getsentry/sentry-conventions#420)) - Deprecates MCP-specific attributes in favor of `gen_ai.*`/`jsonrpc.*` OTel equivalents - Adds new `gen_ai.prompt.name` and `jsonrpc.*` attributes > **Note:** Lockfile not updated — `sentry-conventions==0.12.0` is not yet available on PyPI or the internal mirror. The lockfile will need to be updated once the package is published. --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
## Bump sentry-conventions to 0.12.0 Updates `sentry-conventions` to [0.12.0](https://github.com/getsentry/sentry-conventions/releases/tag/0.12.0). ### Changes in 0.12.0 - Align MCP attributes with OTel semantic conventions ([sentry-conventions#420](getsentry/sentry-conventions#420)) - Deprecates MCP-specific attributes in favor of `gen_ai.*`/`jsonrpc.*` OTel equivalents - Adds new `gen_ai.prompt.name` and `jsonrpc.*` attributes
## Bump sentry-conventions to 0.12.0 Updates `sentry-conventions` to [0.12.0](https://github.com/getsentry/sentry-conventions/releases/tag/0.12.0). ### Changes in 0.12.0 - Align MCP attributes with OTel semantic conventions ([sentry-conventions#420](getsentry/sentry-conventions#420)) - Deprecates MCP-specific attributes in favor of `gen_ai.*`/`jsonrpc.*` OTel equivalents - Adds new `gen_ai.prompt.name` and `jsonrpc.*` attributes > **Note:** Lockfile not updated — `sentry-conventions==0.12.0` is not yet available on PyPI or the internal mirror. The lockfile will need to be updated once the package is published. --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>

Description
Align Sentry MCP attributes with the OTel MCP semantic conventions that merged in open-telemetry/semantic-conventions#2083 (Jan 2026).
OTel's MCP convention is deliberately minimal: only 4 mcp.* registry attributes, reusing existing gen_ai., network., jsonrpc., and error. namespaces for everything else. This commit brings Sentry conventions in line with that approach.
Changes:
Set is_in_otel=true on 4 direct matches:
Deprecated 7 attributes with backfill to OTel equivalents:
Created 3 new attributes:
Closes https://linear.app/getsentry/issue/TET-2436/update-conventions-for-mcp-spans
PR Checklist
yarn testand verified that the tests pass.yarn generateto generate and format code and docs.If an attribute was added:
nextjs.function_id, notfunction_id)pii(i.e.maybeortrue. Usefalseonly for values that should never be scrubbed such as IDs)If an attribute was deprecated: