+
    wi;                     B    R t ^ RIHt ^ RIHtHtHtHt  ! R R4      tR# )z
TaskContext - Pure task state management.

This module provides TaskContext, which manages task state without any
server/session dependencies. It can be used standalone for distributed
workers or wrapped by ServerTaskContext for full server integration.
)	TaskStore)TASK_STATUS_COMPLETEDTASK_STATUS_FAILEDResultTaskc                      a  ] tR t^t o RtV 3R lR lt]V 3R lR l4       t]V 3R lR l4       t]V 3R lR	 l4       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tV tR# )TaskContextaW  
Pure task state management - no session dependencies.

This class handles:
- Task state (status, result)
- Cancellation tracking
- Store interactions

For server-integrated features (elicit, create_message, notifications),
use ServerTaskContext from mcp.server.experimental.

Example (distributed worker):
    async def worker_job(task_id: str):
        store = RedisTaskStore(redis_url)
        task = await store.get_task(task_id)
        ctx = TaskContext(task=task, store=store)

        await ctx.update_status("Working...")
        result = await do_work()
        await ctx.complete(result)
c                &   < V ^8  d   QhRS[ RS[/# )   taskstore)r   r   )format__classdict__s   "Y/home/ubuntu/.local/lib/python3.14/site-packages/mcp/shared/experimental/tasks/context.py__annotate__TaskContext.__annotate__$   s        T  )      c                ,    Wn         W n        R V n        R# )FN)_task_store
_cancelled)selfr   r   s   &&&r   __init__TaskContext.__init__$   s    
r   c                    < V ^8  d   QhRS[ /# r
   returnstr)r   r   s   "r   r   r   *   s     ! ! !r   c                .    V P                   P                  # )zThe task identifier.)r   taskIdr   s   &r   task_idTaskContext.task_id)   s     zz   r   c                    < V ^8  d   QhRS[ /# r   )r   )r   r   s   "r   r   r   /   s      d r   c                    V P                   # )zThe current task state.)r   r!   s   &r   r   TaskContext.task.   s     zzr   c                    < V ^8  d   QhRS[ /# r   )bool)r   r   s   "r   r   r   4   s      d r   c                    V P                   # )z(Whether cancellation has been requested.r   r!   s   &r   is_cancelledTaskContext.is_cancelled3   s     r   c                   < V ^8  d   QhRR/# )r
   r   N )r   r   s   "r   r   r   8   s      d r   c                    RV n         R# )z
Request cancellation of this task.

This sets is_cancelled=True. Task work should check this
periodically and exit gracefully if set.
TNr*   r!   s   &r   request_cancellation TaskContext.request_cancellation8   s     r   c                $   < V ^8  d   QhRS[ RR/# )r
   messager   Nr   )r   r   s   "r   r   r   A   s     

 

3 

4 

r   c                z   "   V P                   P                  V P                  VR7      G Rj  xL
 V n        R#  L5i)zN
Update the task's status message.

Args:
    message: The new status message
)status_messageN)r   update_taskr"   r   )r   r3   s   &&r   update_statusTaskContext.update_statusA   s6       ;;22LL" 3 
 

 
s   +;9;c                $   < V ^8  d   QhRS[ RR/# )r
   resultr   N)r   )r   r   s   "r   r   r   M   s     
 
V 
 
r   c                   "   V P                   P                  V P                  V4      G Rj  xL
  V P                   P                  V P                  \        R7      G Rj  xL
 V n        R#  L> L5i)zV
Mark the task as completed with the given result.

Args:
    result: The task result
N)status)r   store_resultr"   r6   r   r   )r   r:   s   &&r   completeTaskContext.completeM   sY      kk&&t||V<<<;;22LL( 3 
 

 	=
s!   *A/A+2A/A- A/-A/c                $   < V ^8  d   QhRS[ RR/# )r
   errorr   Nr   )r   r   s   "r   r   r   Z   s     
 
 
 
r   c                   "   V P                   P                  V P                  \        VR7      G Rj  xL
 V n        R#  L5i)zT
Mark the task as failed with an error message.

Args:
    error: The error message
)r<   r5   N)r   r6   r"   r   r   )r   rA   s   &&r   failTaskContext.failZ   s9       ;;22LL%  3 
 

 
s   0A >A )r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   propertyr"   r   r+   r0   r7   r>   rC   __static_attributes____classdictcell__)r   s   @r   r   r      sx     ,   
 ! !     

 


 

 
r   r   N)	rI   #mcp.shared.experimental.tasks.storer   	mcp.typesr   r   r   r   r   r.   r   r   <module>rO      s!    : M MX
 X
r   