← Back
Editing: mcp.cpython-312.pyc
� ]*j|\ � �f � d Z ddlZddlmZ ddlmZ ddlZddlmZm Z ddl mZmZ ddl mZmZ ddlmZ dd lmZ dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ ddlmZ ddl!m"Z" er&ddlm#Z#m$Z$m%Z%m&Z&m'Z'm(Z( ddl)m*Z*m+Z+m,Z, dd lmZ ddl-m.Z. G d� de� Z/ dBd�Z0dCd�Z1de2de2ddfd�Z3ddd e2d!e2d"e2d#d$d%d&d'd&d(e2ddfd)�Z4dDd,�Z5ddd*d+d-d&de2ddf d.�Z6 dEde2d/d0d1d2dd3fd4�Z7 dFde2d5d6d/d0d1d2d7d8d9e8dd+fd:�Z9d;d6de2d<d+d=d+dd6f d>�Z:dGd?�Z;dGd@�Z<dGdA�Z=y# e $ r ed� �w xY w# e $ r dZ"Y ��w xY w)Ha 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)�_set_span_data_attribute�get_start_span_function)�OP�SPANDATA)�DidNotEnable�Integration)�nullcontext)�should_send_default_pii)�StreamedSpan)�has_span_streaming_enabled)�safe_serialize)�Server)�request_ctx)�StreamableHTTPServerTransportzMCP SDK not installed)�FastMCP)�Any�Callable�ContextManager�Optional�Tuple�Union)�Receive�Scope�Send)�Spanc �8 � e Zd ZdZdZddeddfd�Zed d�� Zy) �MCPIntegration�mcpzauto.ai.mcp�include_prompts�returnNc � � || _ 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)r"