Skip to content

Commit 6a2b419

Browse files
committed
feat: improving input/output span attributes
Transport mechanism detection not yet working
1 parent efad41b commit 6a2b419

File tree

5 files changed

+444
-555
lines changed

5 files changed

+444
-555
lines changed

sentry_sdk/consts.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,54 @@ class SPANDATA:
779779
Example: "req_123abc"
780780
"""
781781

782+
MCP_TOOL_RESULT_CONTENT = "mcp.tool.result.content"
783+
"""
784+
The result/output content from an MCP tool execution.
785+
Example: "The weather is sunny"
786+
"""
787+
788+
MCP_TOOL_RESULT_CONTENT_COUNT = "mcp.tool.result.content_count"
789+
"""
790+
The number of items/keys in the MCP tool result.
791+
Example: 5
792+
"""
793+
794+
MCP_TOOL_RESULT_IS_ERROR = "mcp.tool.result.is_error"
795+
"""
796+
Whether the MCP tool execution resulted in an error.
797+
Example: True
798+
"""
799+
800+
MCP_PROMPT_RESULT_MESSAGE_CONTENT = "mcp.prompt.result.message_content"
801+
"""
802+
The message content from an MCP prompt retrieval.
803+
Example: "Review the following code..."
804+
"""
805+
806+
MCP_PROMPT_RESULT_MESSAGE_ROLE = "mcp.prompt.result.message_role"
807+
"""
808+
The role of the message in an MCP prompt retrieval (only set for single-message prompts).
809+
Example: "user", "assistant", "system"
810+
"""
811+
812+
MCP_PROMPT_RESULT_MESSAGE_COUNT = "mcp.prompt.result.message_count"
813+
"""
814+
The number of messages in an MCP prompt result.
815+
Example: 1, 3
816+
"""
817+
818+
MCP_RESOURCE_RESULT_CONTENT = "mcp.resource.result.content"
819+
"""
820+
The result/output content from an MCP resource read.
821+
Example: "File contents..."
822+
"""
823+
824+
MCP_TRANSPORT = "mcp.transport"
825+
"""
826+
The transport method used for MCP communication.
827+
Example: "pipe" (stdio), "tcp" (HTTP/WebSocket/SSE)
828+
"""
829+
782830

783831
class SPANSTATUS:
784832
"""

sentry_sdk/integrations/mcp/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
try:
1414
import mcp.server.lowlevel # noqa: F401
15-
import mcp.server.fastmcp # noqa: F401
1615
except ImportError:
1716
raise DidNotEnable("MCP SDK not installed")
1817

@@ -28,10 +27,9 @@ def setup_once():
2827
Patches MCP server classes to instrument handler execution.
2928
"""
3029
from sentry_sdk.integrations.mcp.lowlevel import patch_lowlevel_server
31-
from sentry_sdk.integrations.mcp.fastmcp import patch_fastmcp_server
3230

31+
# Patch server classes to instrument handlers
3332
patch_lowlevel_server()
34-
patch_fastmcp_server()
3533

3634

3735
__all__ = ["MCPIntegration"]

0 commit comments

Comments
 (0)