Skip to content

Commit ae9d325

Browse files
committed
feat: detecting transport and session id
1 parent 609489d commit ae9d325

File tree

4 files changed

+332
-274
lines changed

4 files changed

+332
-274
lines changed

sentry_sdk/consts.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,12 @@ class SPANDATA:
827827
Example: "pipe" (stdio), "tcp" (HTTP/WebSocket/SSE)
828828
"""
829829

830+
MCP_SESSION_ID = "mcp.session.id"
831+
"""
832+
The session identifier for the MCP connection.
833+
Example: "a1b2c3d4e5f6"
834+
"""
835+
830836

831837
class SPANSTATUS:
832838
"""

sentry_sdk/integrations/mcp/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ def setup_once():
2727
Patches MCP server classes to instrument handler execution.
2828
"""
2929
from sentry_sdk.integrations.mcp.lowlevel import patch_lowlevel_server
30+
from sentry_sdk.integrations.mcp.transport import (
31+
patch_streamable_http_transport,
32+
)
3033

3134
# Patch server classes to instrument handlers
3235
patch_lowlevel_server()
3336

37+
# Patch HTTP transport to track session IDs
38+
patch_streamable_http_transport()
39+
3440

3541
__all__ = ["MCPIntegration"]

0 commit comments

Comments
 (0)