+
    wi                         R t ^ RIHt ^ RIHtHtHt ^ RIHt ^ RI	H
t
Ht ^ RIHtHt ^ RIHt ]'       d   ^ RIHt ]! R]P&                  R	7      t ! R
 R4      tR# )u8  
Experimental server session features for server→client task operations.

This module provides the server-side equivalent of ExperimentalClientFeatures,
allowing the server to send task-augmented requests to the client and poll for results.

WARNING: These APIs are experimental and may change without notice.
)AsyncIterator)TYPE_CHECKINGAnyTypeVarN)validate_sampling_tools!validate_tool_use_result_messages)"require_task_augmented_elicitationrequire_task_augmented_sampling)poll_until_terminal)ServerSessionResultT)boundc                      a  ] tR t^t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltR
R/V 3R lR llt	R
RRRRRRRRRRRRRRRRR/	V 3R lR llt
RtV tR# )!ExperimentalServerSessionFeaturesu  
Experimental server session features for server→client task operations.

This provides the server-side equivalent of ExperimentalClientFeatures,
allowing the server to send task-augmented requests to the client and
poll for results.

WARNING: These APIs are experimental and may change without notice.

Access via session.experimental:
    result = await session.experimental.elicit_as_task(...)
c                "   < V ^8  d   QhRRRR/# )   sessionr   returnN )format__classdict__s   "\/home/ubuntu/.local/lib/python3.14/site-packages/mcp/server/experimental/session_features.py__annotate__.ExperimentalServerSessionFeatures.__annotate__)   s          D      c                    Wn         R # )N_session)selfr   s   &&r   __init__*ExperimentalServerSessionFeatures.__init__)   s    r   c                :   < V ^8  d   QhRS[ RS[P                  /# r   task_idr   )strtypesGetTaskResult)r   r   s   "r   r   r   ,   s!     
 
c 
e.A.A 
r   c           
        "   V P                   P                  \        P                  ! \        P                  ! \        P
                  ! VR7      R7      4      \        P                  4      G Rj  xL
 #  L5i)z
Send tasks/get to the client to get task status.

Args:
    task_id: The task identifier

Returns:
    GetTaskResult containing the task status
taskIdparamsN)r   send_requestr%   ServerRequestGetTaskRequestGetTaskRequestParamsr&   )r   r#   s   &&r   get_task*ExperimentalServerSessionFeatures.get_task,   sV      ]]// 4 4E<V<V^e<f gh
 
 	
 
s   A,A5.A3/A5c                <   < V ^8  d   QhRS[ RS[S[,          RS[/# )r   r#   result_typer   )r$   typer   )r   r   s   "r   r   r   ;   s-     
 

 ']
 
	
r   c           
        "   V P                   P                  \        P                  ! \        P                  ! \        P
                  ! VR7      R7      4      V4      G Rj  xL
 #  L5i)z
Send tasks/result to the client to retrieve the final result.

Args:
    task_id: The task identifier
    result_type: The expected result type

Returns:
    The task result, validated against result_type
r(   r*   N)r   r,   r%   r-   GetTaskPayloadRequestGetTaskPayloadRequestParams)r   r#   r3   s   &&&r   get_task_result1ExperimentalServerSessionFeatures.get_task_result;   sP      ]]// ; ;5CdCdlsCt uv
 
 	
 
s   AA' A%!A'c                J   < V ^8  d   QhRS[ RS[S[P                  ,          /# r"   )r$   r   r%   r&   )r   r   s   "r   r   r   O   s&      s }U=P=P/Q r   c               b   "   \        V P                  V4        Rj  xL
  pV5x  K   LDR# 5i)a8  
Poll a client task until it reaches terminal status.

Yields GetTaskResult for each poll, allowing the caller to react to
status changes. Exits when task reaches a terminal status.

Respects the pollInterval hint from the client.

Args:
    task_id: The task identifier

Yields:
    GetTaskResult for each poll
N)r
   r0   )r   r#   statuss   && r   	poll_task+ExperimentalServerSessionFeatures.poll_taskO   s.      0wG 	 	&L	Gs   /,*,	/,/ttli`  c                Z   < V ^8  d   QhRS[ RS[P                  RS[RS[P                  /# )r   messagerequestedSchemar?   r   )r$   r%   ElicitRequestedSchemaintElicitResult)r   r   s   "r   r   r   a   sE     1G 1G1G 441G
 1G 
		1Gr   c               l  "   V P                   P                  '       d!   V P                   P                  P                  MRp\        V4       V P                   P	                  \
        P                  ! \
        P                  ! \
        P                  ! VV\
        P                  ! VR7      R7      R7      4      \
        P                  4      G Rj  xL
 pVP                  P                  pV P                  V4        Rj  xL
  pK   L7 L	D
T P                  T\
        P                  4      G Rj  xL 
 # 5i)a  
Send a task-augmented elicitation to the client and poll until complete.

The client will create a local task, process the elicitation asynchronously,
and return the result when ready. This method handles the full flow:
1. Send elicitation with task field
2. Receive CreateTaskResult from client
3. Poll client's task until terminal
4. Retrieve and return the final ElicitResult

Args:
    message: The message to present to the user
    requestedSchema: Schema defining the expected response
    ttl: Task time-to-live in milliseconds

Returns:
    The client's elicitation response

Raises:
    McpError: If client doesn't support task-augmented elicitation
Nr?   )rA   rB   taskr*   )r   client_paramscapabilitiesr   r,   r%   r-   ElicitRequestElicitRequestFormParamsTaskMetadataCreateTaskResultrH   r)   r=   r8   rE   )r   rA   rB   r?   client_capscreate_resultr#   _s   &&&$    r   elicit_as_task0ExperimentalServerSessionFeatures.elicit_as_taska   s     8 CG--B]B]B]dmm11>>cg*;7"mm88## 88 '(7"//C8 ""
 
  $$++~~g. 	 	!!
	. ))'53E3EFFFFsB   CD4D+D4:D
>D?D
D4D

$D4.D1/D4system_promptNinclude_contexttemperaturestop_sequencesmetadatamodel_preferencestoolstool_choicec                  < V ^8  d   QhRS[ S[P                  ,          RS[RS[RS[R,          RS[P
                  R,          RS[R,          RS[ S[,          R,          R	S[S[S[3,          R,          R
S[P                  R,          RS[ S[P                  ,          R,          RS[P                  R,          RS[P                  /# )r   messages
max_tokensr?   rT   NrU   rV   rW   rX   rY   rZ   r[   r   )listr%   SamplingMessagerD   r$   IncludeContextfloatdictr   ModelPreferencesTool
ToolChoiceCreateMessageResult)r   r   s   "r   r   r      s     HN HNu,,-HN 	HN
 HN TzHN --4HN T\HN S	D(HN sCx.4'HN !11D8HN EJJ$&HN %%,HN 
	"	"HNr   c       
          "   V P                   P                  '       d!   V P                   P                  P                  MRp\        V4       \	        WV4       \        V4       V P                   P                  \        P                  ! \        P                  ! \        P                  ! VVVVVVVV	V
V\        P                  ! VR7      R7      R7      4      \        P                  4      G Rj  xL
 pVP                  P                  pV P                  V4        Rj  xL
  pK   L7 L	D
T P!                  T\        P"                  4      G Rj  xL 
 # 5i)a  
Send a task-augmented sampling request and poll until complete.

The client will create a local task, process the sampling request
asynchronously, and return the result when ready.

Args:
    messages: The conversation messages for sampling
    max_tokens: Maximum tokens in the response
    ttl: Task time-to-live in milliseconds
    system_prompt: Optional system prompt
    include_context: Context inclusion strategy
    temperature: Sampling temperature
    stop_sequences: Stop sequences
    metadata: Additional metadata
    model_preferences: Model selection preferences
    tools: Optional list of tools the LLM can use during sampling
    tool_choice: Optional control over tool usage behavior

Returns:
    The sampling result from the client

Raises:
    McpError: If client doesn't support task-augmented sampling or tools
    ValueError: If tool_use or tool_result message structure is invalid
NrG   )r]   	maxTokenssystemPromptincludeContextrV   stopSequencesrX   modelPreferencesrZ   
toolChoicerH   r*   )r   rI   rJ   r	   r   r   r,   r%   r-   CreateMessageRequestCreateMessageRequestParamsrM   rN   rH   r)   r=   r8   rg   )r   r]   r^   r?   rT   rU   rV   rW   rX   rY   rZ   r[   rO   rP   r#   rQ   s   &&$$$$$$$$$$    r   create_message_as_task8ExperimentalServerSessionFeatures.create_message_as_task   s!    R CG--B]B]B]dmm11>>cg'4K@)(3"mm88** ;;!)",%2'6$/&4!)):##."//C8" ""%
 
*  $$++~~g. 	 	!1
.	. ))'53L3LMMMMsB   C+E-D%.+ED)D'D)!E'D))$EEEr   )__name__
__module____qualname____firstlineno____doc__r   r0   r8   r=   rR   rq   __static_attributes____classdictcell__)r   s   @r   r   r      s        
 

 
( $1G
 1G 1GfHN
 HN %)HN 8<HN %)HN ,0HN +/HN <@HN *.HN 04HN HN HNr   r   )rw   collections.abcr   typingr   r   r   	mcp.typesr%   mcp.server.validationr   r   *mcp.shared.experimental.tasks.capabilitiesr   r	   %mcp.shared.experimental.tasks.pollingr
   mcp.server.sessionr   Resultr   r   r   r   r   <module>r      sJ    * . .  \ F0
)5<<
0AN ANr   