+
    wi                       R t ^ RIHt ^ RIt^ RIHt ^ RIHtHtH	t	H
t
HtHt ^ RIHt ^ RIHt ^ RIHt ]	! R]R	7      t ! R
 R]]],          4      t ! R R]4      t ! R R]4      t]],          ],          ],          t ! R R]4      t]],          ],          t]]]]3tR R ltR R lt R R lt!RR R llt"RR R llt#R# )z&Elicitation utilities for MCP servers.)annotationsN)Sequence)GenericLiteralTypeVarUnionget_args
get_origin)	BaseModel)ServerSession)	RequestIdElicitSchemaModelT)boundc                  4    ] tR t^t$ RtRtR]R&   R]R&   RtR# )	AcceptedElicitationz)Result when user accepts the elicitation.acceptLiteral['accept']actionr   data N__name__
__module____qualname____firstlineno____doc__r   __annotations____static_attributes__r       J/home/ubuntu/.local/lib/python3.14/site-packages/mcp/server/elicitation.pyr   r      s    3 (F(
r   r   c                  *    ] tR t^t$ RtRtR]R&   RtR# )DeclinedElicitationz*Result when user declines the elicitation.declinezLiteral['decline']r   r   Nr   r   r   r   r!   r!      s    4!*F*r   r!   c                  *    ] tR t^t$ RtRtR]R&   RtR# )CancelledElicitationz)Result when user cancels the elicitation.cancelzLiteral['cancel']r   r   Nr   r   r   r   r$   r$      s    3 (F(r   r$   c                  *    ] tR t^'t$ RtRtR]R&   RtR# )AcceptedUrlElicitationz0Result when user accepts a URL mode elicitation.r   r   r   r   Nr   r   r   r   r'   r'   '   s    : (F(r   r'   c                    V ^8  d   QhRRRR/# )   schemaztype[BaseModel]returnNoner   )formats   "r   __annotate__r.   4   s       T r   c                   V P                   P                  4        Fe  w  rVP                  pVe   V\        P                  J d   K+  \        V4      '       d   K>  \        V4      '       d   KQ  \        RV R\         R24      h	  R# )zCValidate that a Pydantic model only contains primitive field types.NzElicitation schema field 'z' must be a primitive type zw, a sequence of strings (list[str], etc.), or Optional of these types. Nested models and complex types are not allowed.)	model_fieldsitems
annotationtypesNoneType_is_primitive_field_is_string_sequence	TypeError_ELICITATION_PRIMITIVE_TYPES)r*   
field_name
field_infor2   s   &   r   _validate_elicitation_schemar;   4   s    "("5"5";";"=
**
u~~!= ,, ,,,ZL8S/0 1_`  #>r   c                    V ^8  d   QhRRRR/# r)   r2   typer+   boolr   )r-   s   "r   r.   r.   G   s      D T r   c                    \        V 4      pV'       dK    \        V\        4      '       d1   \        V 4      p\	        V4      ^8H  ;'       d    V^ ,          \
        J #  R# R#   \         d     R# i ; i)zMCheck if annotation is a sequence of strings (list[str], Sequence[str], etc).F)r	   
issubclassr   r   lenstrr7   r2   originargss   &  r   r6   r6   G   sj    
#F	&(++
+4yA~88$q'S.8 ,   		s   5A  A   A/.A/c                    V ^8  d   QhRRRR/# r=   r   )r-   s   "r   r.   r.   W   s      D T r   c                    V \         9   d   R# \        V 4      pV\        J g   V\        P                  J d@   \        V 4      p\        ;QJ d    R V 4       F  '       d   K   R# 	  R# ! R V 4       4      # R# )zDCheck if a field is a primitive type allowed in elicitation schemas.Tc              3     "   T F:  q\         P                  J ;'       g    V\        9   ;'       g    \        V4      x  K<  	  R # 5iN)r3   r4   r8   r6   ).0args   & r   	<genexpr>&_is_primitive_field.<locals>.<genexpr>b   s<      
ptil5>>!ddS,H%HddL_`cLddpts   AAAF)r8   r	   r   r3   	UnionTyper   allrD   s   &  r   r5   r5   W   sx     11 
#F&EOO3
#s 
pt
ss 	
s 	
s 
pt
 
 	
 r   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r)   sessionr   messagerC   r*   ztype[ElicitSchemaModelT]related_request_idRequestId | Noner+   z%ElicitationResult[ElicitSchemaModelT]r   )r-   s   "r   r.   r.   i   sA     %L %L%L%L %%L )	%L
 +%Lr   c                  "   \        V4       VP                  4       pV P                  VVVR7      G Rj  xL
 pVP                  R8X  d6   VP                  e(   VP                  VP                  4      p\        VR7      # VP                  R8X  d   \        4       # VP                  R8X  d   \        4       # \        RVP                   24      h L5i)a  Elicit information from the client/user with schema validation (form mode).

This method can be used to interactively ask for additional information from the
client within a tool's execution. The client might display the message to the
user and collect a response according to the provided schema. Or in case a
client is an agent, it might decide how to handle the elicitation -- either by asking
the user or automatically generating a response.

For sensitive data like credentials or OAuth flows, use elicit_url() instead.
)rS   requestedSchemarT   Nr   )r   r"   r%   Unexpected elicitation action: )
r;   model_json_schemaelicit_formr   contentmodel_validater   r!   r$   
ValueError)rR   rS   r*   rT   json_schemaresultvalidated_datas   &&&&   r   elicit_with_validationra   i   s     " !(**,K&&#- '  F }} V^^%?..v~~>"77	)	#"$$	(	"#%% :6==/JKK!s   3CCBCc               0    V ^8  d   QhRRRRRRRRRRR	R
/# )r)   rR   r   rS   rC   urlelicitation_idrT   rU   r+   UrlElicitationResultr   )r-   s   "r   r.   r.      sL     -L -L-L-L 
-L 	-L
 )-L -Lr   c                  "   V P                  VVVVR7      G Rj  xL
 pVP                  R8X  d   \        4       # VP                  R8X  d   \        4       # VP                  R8X  d   \	        4       # \        RVP                   24      h Lm5i)a  Elicit information from the user via out-of-band URL navigation (URL mode).

This method directs the user to an external URL where sensitive interactions can
occur without passing data through the MCP client. Use this for:
- Collecting sensitive credentials (API keys, passwords)
- OAuth authorization flows with third-party services
- Payment and subscription flows
- Any interaction where data should not pass through the LLM context

The response indicates whether the user consented to navigate to the URL.
The actual interaction happens out-of-band. When the elicitation completes,
the server should send an ElicitCompleteNotification to notify the client.

Args:
    session: The server session
    message: Human-readable explanation of why the interaction is needed
    url: The URL the user should navigate to
    elicitation_id: Unique identifier for tracking this elicitation
    related_request_id: Optional ID of the request that triggered this elicitation

Returns:
    UrlElicitationResult indicating accept, decline, or cancel
)rS   rc   rd   rT   Nr   r"   r%   rX   )
elicit_urlr   r'   r!   r$   r]   )rR   rS   rc   rd   rT   r_   s   &&&&& r   rg   rg      s     < %%%-	 &  F }} %''	)	#"$$	(	"#%% :6==/JKKs   BB	A.BrJ   )$r   
__future__r   r3   collections.abcr   typingr   r   r   r   r   r	   pydanticr
   mcp.server.sessionr   	mcp.typesr   r   r   r!   r$   ElicitationResultr'   re   rC   intfloatr?   r8   r;   r6   r5   ra   rg   r   r   r   <module>rq      s    , "  $ I I  , 1C )W-?%@ +) +)9 ) ((:;>QQThh )Y ) .0CCFZZ  !$S%6 & $%LP-L -Lr   