Skip to content

fix(mcp): Capture transport implementation and HTTP metadata - #7925

Draft
betegon wants to merge 2 commits into
masterfrom
bt/mcp-transport-attributes
Draft

betegon wants to merge 2 commits into
masterfrom
bt/mcp-transport-attributes

Conversation

@betegon

@betegon betegon commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Description

Keep MCP transport implementation identity separate from OpenTelemetry network metadata, following getsentry/sentry-conventions#671. HTTP and SSE spans now record the concrete transport class, including custom subclasses, and read the HTTP protocol/version from each request's ASGI scope. HTTP/3 records quic.

Missing HTTP context no longer implies stdio/pipe, and HTTP headers no longer imply TCP. Stdio and independent custom stream transports remain without transport attributes until their actual transport boundary can be instrumented reliably.

Deploy getsentry/relay#6483 with the corrected conventions before releasing this change: older Relay can backfill the class name into an absent network.transport.

Validated against MCP 1.30.0 and 2.3.0 with static and streamed spans (111 and 117 tests passed respectively), plus Ruff and mypy. Real HTTP/SSE tests cover custom subclasses, HTTP versions and missing metadata. The sibling FastMCP expectations are aligned too; Python 3.12 / FastMCP 2.14.7 passes all 80 tests. Local FastMCP 3.4.8 and 4.0.11 setup was blocked by HTTP 403 from the configured package security proxy, so those versions still require CI verification.

Issues

Related: getsentry/sentry-conventions#671. No separate issue.

Reminders

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ 133246 passed | ❌ 1 failed | ⏭️ 7298 skipped | Total: 140545 | Pass Rate: 94.81% | Execution Time: 437m 16s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -148
Passed Tests 📉 -171
Failed Tests 📈 +1
Skipped Tests 📈 +22

➕ New Tests (1)

View new tests
  • test_cache_spans_item_size[True]
    • File: tests.integrations.django.test_cache_module
    • Status: ❌ Failing

❌ Failed Tests

test_cache_spans_item_size[True]

File: tests.integrations.django.test_cache_module
Suite: py3.14t-django-v5.2.17
Error: tests/integrations/django/test_cache_module.py:763: in test_cache_spans_item_size assert not spans[0]["attributes"]["cache.hit"] E assert not True

Stack Trace
tests/integrations/django/test_cache_module.py:763: in test_cache_spans_item_size
    assert not spans[0]["attributes"]["cache.hit"]
E   assert not True

✅ Patch coverage is 100.00%. Project has 2565 uncovered lines.
❌ Project coverage is 90.35%. Comparing base (1f4ba26) to head (bee91dc).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/mcp.py 100.00% ⚠️ 2 partials
Coverage diff
@@            Coverage Diff             @@
##        master       #PR       +/-##
==========================================
- Coverage    90.37%    90.35%    -0.02%
==========================================
  Files          202       202         —
  Lines        26552     26573       +21
  Branches      9854      9864       +10
==========================================
+ Hits         23995     24008       +13
- Misses        2557      2565        +8
- Partials      1495      1499        +4

Generated by Codecov Action

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