
    )`i	                    n    d dl mZ d dlmZmZ d dlmZmZmZ  G d de	          Z
 G d de
          ZdS )	    )annotations)Anycast)URL_ELICITATION_REQUIREDElicitRequestURLParams	ErrorDatac                  0     e Zd ZU dZded<   d fdZ xZS )McpErrorzM
    Exception type raised when an error arrives over an MCP connection.
    r   errorc                b    t                                          |j                   || _        dS )zInitialize McpError.N)super__init__messager   )selfr   	__class__s     i/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/mcp/shared/exceptions.pyr   zMcpError.__init__   s(    '''


    )r   r   )__name__
__module____qualname____doc____annotations__r   __classcell__r   s   @r   r
   r
      sW                    r   r
   c                  X     e Zd ZdZ	 dd fdZedd	            Zedd            Z xZ	S )UrlElicitationRequiredErrora<  
    Specialized error for when a tool requires URL mode elicitation(s) before proceeding.

    Servers can raise this error from tool handlers to indicate that the client
    must complete one or more URL elicitations before the request can be processed.

    Example:
        raise UrlElicitationRequiredError([
            ElicitRequestURLParams(
                mode="url",
                message="Authorization required for your files",
                url="https://example.com/oauth/authorize",
                elicitationId="auth-001"
            )
        ])
    Nelicitationslist[ElicitRequestURLParams]r   
str | Nonec                    |dt          |          dk    rdnd d}|| _        t          t          |dd |D             i	          }t	                                          |           dS )
z'Initialize UrlElicitationRequiredError.NzURL elicitation   s z	 requiredr   c                <    g | ]}|                     d d           S )T)by_aliasexclude_none)
model_dump.0es     r   
<listcomp>z8UrlElicitationRequiredError.__init__.<locals>.<listcomp>5   s)    "h"h"hVW1<<D<#Q#Q"h"h"hr   )coder   data)len_elicitationsr   r   r   r   )r   r   r   r   r   s       r   r   z$UrlElicitationRequiredError.__init__'   s     ?Ws</@/@1/D/D"WWWG)) "h"h[g"h"h"hi
 
 

 	r   returnc                    | j         S )zEThe list of URL elicitations required before the request can proceed.)r/   )r   s    r   r   z(UrlElicitationRequiredError.elicitations9   s     !!r   r   r   c                   |j         t          k    rt          dt           d|j                    t          t          t
          t          f         |j        pi           }t          t          t          t
          t          f                  |	                    dg                     }d |D             } | ||j
                  S )z5Reconstruct from an ErrorData received over the wire.zExpected error code z, got r   c                6    g | ]}t          j        |          S  )r   model_validater(   s     r   r+   z:UrlElicitationRequiredError.from_error.<locals>.<listcomp>F   s$    [[[Q.=a@@[[[r   )r,   r   
ValueErrorr   dictstrr   r-   listgetr   )clsr   r-   raw_elicitationsr   s        r   
from_errorz&UrlElicitationRequiredError.from_error>   s     :111`4L``TYT^``aaaDcNEJ$4"55T#s(^ 4dhh~r6R6RSS[[JZ[[[s<///r   )N)r   r   r   r   )r0   r   )r   r   r0   r   )
r   r   r   r   r   propertyr   classmethodr=   r   r   s   @r   r   r      s         ( #             $ " " " X" 0 0 0 [0 0 0 0 0r   r   N)
__future__r   typingr   r   	mcp.typesr   r   r   	Exceptionr
   r   r4   r   r   <module>rD      s    " " " " " "         Q Q Q Q Q Q Q Q Q Q
 
 
 
 
y 
 
 
20 20 20 20 20( 20 20 20 20 20r   