Skip to content

feat(mcp): align MCP attributes with OTel semantic conventions - #420

Merged
constantinius merged 6 commits into
mainfrom
feat/align-mcp-with-otel
Jun 16, 2026
Merged

constantinius merged 6 commits into
mainfrom
feat/align-mcp-with-otel

Conversation

@constantinius

Copy link
Copy Markdown
Contributor

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:

  • 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)

Closes https://linear.app/getsentry/issue/TET-2436/update-conventions-for-mcp-spans

PR Checklist

  • I have run yarn test and verified that the tests pass.
  • I have run yarn generate to generate and format code and docs.

If an attribute was added:

  • The attribute is in a namespace (e.g. nextjs.function_id, not function_id)
  • I have used the correct value for pii (i.e. maybe or true. Use false only for values that should never be scrubbed such as IDs)

If an attribute was deprecated:

@constantinius
constantinius requested review from a team, Lms24, cleptric, mjq and nsdeschenes as code owners June 9, 2026 13:35
@linear-code

linear-code Bot commented Jun 9, 2026

Copy link
Copy Markdown

TET-2436

@github-actions

github-actions Bot commented Jun 9, 2026 •

Copy link
Copy Markdown

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (mcp) Align MCP attributes with OTel semantic conventions by constantinius in #420

🤖 This preview updates automatically when you update the PR.

@constantinius
constantinius force-pushed the feat/align-mcp-with-otel branch from 0dce5f2 to 1106c3b Compare June 9, 2026 13:39
@constantinius
constantinius requested review from a team and betegon June 9, 2026 13:40
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.
@constantinius
constantinius force-pushed the feat/align-mcp-with-otel branch from 1106c3b to b747d41 Compare June 9, 2026 13:46
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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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
@constantinius
constantinius enabled auto-merge (squash) June 15, 2026 16:25
…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.
@constantinius
constantinius requested a review from loewenheim June 16, 2026 08:03
@constantinius
constantinius disabled auto-merge June 16, 2026 08:21
@constantinius
constantinius enabled auto-merge (squash) June 16, 2026 08:21
@constantinius
constantinius merged commit 3aaf002 into main Jun 16, 2026
15 checks passed
Comment thread model/name/mcp.json
Comment on lines 10 to +12
"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}}",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@constantinius
constantinius deleted the feat/align-mcp-with-otel branch June 16, 2026 09:35
constantinius added a commit to getsentry/sentry that referenced this pull request Jun 17, 2026
## 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>
constantinius added a commit to getsentry/snuba that referenced this pull request Jun 18, 2026
## 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
sehr-m pushed a commit to getsentry/sentry that referenced this pull request Jun 23, 2026
## 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>
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.

5 participants