+
    wi^              
          ^ RI t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
HtHtHt ^ RIt^ RIt^ RIHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHtHt ^ RIHt ^ RIH t H!t!H"t"H#t#H$t$H%t%H&t&H't'H(t(H)t)H*t*H+t+H,t,H-t-H.t.H/t/H0t0 ]! R]$]/4      t1]! R]%]04      t2]! R]#].4      t3]! R]$]/4      t4]! R]R7      t5]! R]#].4      t6]7]8,          t9 ! R R]4      t: ! R R]]4]23,          4      t; ! R R]]1]3]2]4]63,          4      t<R# )    N)Callable)AsyncExitStack)	timedelta)TracebackType)AnyGenericProtocolTypeVar)MemoryObjectReceiveStreamMemoryObjectSendStream)	BaseModelSelf)McpError)MessageMetadataServerMessageMetadataSessionMessageResponseRouter)CONNECTION_CLOSEDINVALID_PARAMSCancelledNotificationClientNotificationClientRequestClientResult	ErrorDataJSONRPCErrorJSONRPCMessageJSONRPCNotificationJSONRPCRequestJSONRPCResponseProgressNotificationRequestParamsServerNotificationServerRequestServerResultSendRequestTSendResultTSendNotificationTReceiveRequestTReceiveResultT)boundReceiveNotificationTc                   6   a  ] tR t^/t o RtV 3R lR ltRtV tR# )ProgressFnTz-Protocol for progress notification callbacks.c                L   < V ^8  d   QhRS[ RS[ R,          RS[R,          RR/# )   progresstotalNmessagereturn)floatstr)format__classdict__s   "F/home/ubuntu/.local/lib/python3.14/site-packages/mcp/shared/session.py__annotate__ProgressFnT.__annotate__2   s5      &+dl=@4Z	    c                   "   R # 5iN )selfr2   r3   r4   s   &&&&r:   __call__ProgressFnT.__call__2   s        r@   N)__name__
__module____qualname____firstlineno____doc__rB   __static_attributes____classdictcell__r9   s   @r:   r/   r/   /   s     7 r=   r/   c                      a  ] tR t^7t o RtRV 3R lR ll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	]
V 3R lR l4       t]
V 3R lR l4       tRtV tR# )RequestRespondera  Handles responding to MCP requests and manages request lifecycle.

This class MUST be used as a context manager to ensure proper cleanup and
cancellation handling:

Example:
    with request_responder as resp:
        await resp.respond(result)

The context manager ensures:
1. Proper cancellation scope setup and cleanup
2. Request completion tracking
3. Cleanup of in-flight requests
Nc                x   < V ^8  d   QhRS[ RS[P                  R,          RS[RRRS[R.S[3,          R	S[R
R/# )r1   
request_idrequest_metaNrequestsessionzBaseSession[
            SendRequestT,
            SendNotificationT,
            SendResultT,
            ReceiveRequestT,
            ReceiveNotificationT
        ]on_complete.RequestResponder[ReceiveRequestT, SendResultT]message_metadatar5   )	RequestIdr#   Metar*   r   r   r   )r8   r9   s   "r:   r;   RequestResponder.__annotate__G   sk       $((4/ !	
 OPRUUV * 
r=   c                    Wn         W n        W0n        W`n        W@n        R V n        \        P                  ! 4       V n        WPn	        R V n
        R# )FN)rP   rQ   rR   rV   _session
_completedanyioCancelScope_cancel_scope_on_complete_entered)rA   rP   rQ   rR   rS   rT   rV   s   &&&&&&&r:   __init__RequestResponder.__init__G   sD     %( 0"..0'r=   c                   < V ^8  d   QhRR/# )r1   r5   rU   r@   )r8   r9   s   "r:   r;   rY   `   s      K r=   c                |    RV n         \        P                  ! 4       V n        V P                  P	                  4        V # )zBEnter the context manager, enabling request cancellation tracking.T)ra   r]   r^   r_   	__enter__rA   s   &r:   rf   RequestResponder.__enter__`   s1    "..0$$&r=   c                j   < V ^8  d   QhRS[ S[,          R,          RS[R,          RS[R,          RR/# r1   exc_typeNexc_valexc_tbr5   )typeBaseExceptionr   )r8   r9   s   "r:   r;   rY   g   sM     C C}%,C %C $	C
 
Cr=   c                X    V P                   '       d   V P                  V 4       RV n        V P                  '       g   \	        R4      hV P                  P                  WV4       R#   RT n        T P                  '       g   \	        R4      hT P                  P                  YT4       i ; i)zFExit the context manager, performing cleanup and notifying completion.FNo active cancel scopeN)r\   r`   ra   r_   RuntimeError__exit__rA   rk   rl   rm   s   &&&&r:   rs   RequestResponder.__exit__g   s    	C!!$'!DM%%%"#;<<''6B "DM%%%"#;<<''6Bs   A' A' 'AB)c                4   < V ^8  d   QhRS[ S[,          RR/# )r1   responser5   N)r(   r   )r8   r9   s   "r:   r;   rY   w   s       kI&= $ r=   c                  "   V P                   '       g   \        R4      hV P                  '       d   Q R4       hV P                  '       g9   RV n        V P                  P                  V P                  VR7      G Rj  xL
  R# R#  L5i)zSend a response for this request.

Must be called within a context manager block.
Raises:
    RuntimeError: If not used within a context manager
    AssertionError: If request was already responded to
2RequestResponder must be used as a context managerzRequest already responded toTrP   rw   N)ra   rr   r\   	cancelledr[   _send_responserP   )rA   rw   s   &&r:   respondRequestResponder.respondw   su      }}}STT???B$BB"~~~"DO--..??X /    s   /BB1B<B=	Bc                   < V ^8  d   QhRR/# r1   r5   Nr@   )r8   r9   s   "r:   r;   rY      s     
 
d 
r=   c           	     >  "   V P                   '       g   \        R4      hV P                  '       g   \        R4      hV P                  P                  4        RV n        V P
                  P                  V P                  \        ^ RRR7      R7      G Rj  xL
  R#  L5i)z-Cancel this request and mark it as completed.ry   rq   TzRequest cancelledNcoder4   datarz   )	ra   rr   r_   cancelr\   r[   r|   rP   r   rg   s   &r:   r   RequestResponder.cancel   s     }}}STT!!!788!!#mm**A/BN + 
 	
 	
s   /BA"BBBc                    < V ^8  d   QhRS[ /# r1   r5   bool)r8   r9   s   "r:   r;   rY      s     : :4 :r=   c                V    V P                   '       * ;'       d    V P                  '       * # r?   )r\   r{   rg   s   &r:   	in_flightRequestResponder.in_flight   s    ??"994>>'99r=   c                    < V ^8  d   QhRS[ /# r   r   )r8   r9   s   "r:   r;   rY      s     0 04 0r=   c                .    V P                   P                  # r?   )r_   cancel_calledrg   s   &r:   r{   RequestResponder.cancelled   s    !!///r=   )	r_   r\   ra   r`   r[   rV   rR   rP   rQ   r?   )rE   rF   rG   rH   rI   rb   rf   rs   r}   r   propertyr   r{   rJ   rK   rL   s   @r:   rN   rN   7   sf      2 C C  &
 
 : : 0 0r=   rN   c                   <  a  ] tR t^t o RtR!V 3R lR lltV 3R lR ltV 3R lR ltV 3R	 lR
 ltR"V 3R lR llt	R!V 3R lR ll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V 3R lR ltV 3R lR ltR#V 3R lR lltV 3R lR ltV 3R ltR tV tR# )$BaseSessionz
Implements an MCP "session" on top of read/write streams, including features
like request/response linking, notifications, and progress.

This class is an async context manager that automatically starts processing
messages when entered.
Nc                   < V ^8  d   QhRS[ S[S[,          ,          RS[S[,          RS[S[,          RS[S[,          RS[R,          RR/# )r1   read_streamwrite_streamreceive_request_typereceive_notification_typeread_timeout_secondsNr5   )r   r   	Exceptionr   rn   r*   r-   r   )r8   r9   s   "r:   r;   BaseSession.__annotate__   sf     , ,.~	/IJ, -^<, #?3	,
 $((<#=, ($., 
,r=   c                    Wn         W n        / V n        ^ V n        W0n        W@n        WPn        / V n        / V n        . V n	        \        4       V n        R# )r   N)_read_stream_write_stream_response_streams_request_id_receive_request_type_receive_notification_type_session_read_timeout_seconds
_in_flight_progress_callbacks_response_routersr   _exit_stack)rA   r   r   r   r   r   s   &&&&&&r:   rb   BaseSession.__init__   sT     ()!#%9"*C'-A*#% !#)+r=   c                $   < V ^8  d   QhRS[ RR/# )r1   routerr5   Nr   )r8   r9   s   "r:   r;   r      s     . .. .T .r=   c                <    V P                   P                  V4       R# )a  
Register a response router to handle responses for non-standard requests.

Response routers are checked in order before falling back to the default
response stream mechanism. This is used by TaskResultHandler to route
responses for queued task requests back to their resolvers.

WARNING: This is an experimental API that may change without notice.

Args:
    router: A ResponseRouter implementation
N)r   append)rA   r   s   &&r:   add_response_routerBaseSession.add_response_router   s     	%%f-r=   c                    < V ^8  d   QhRS[ /# r   r   )r8   r9   s   "r:   r;   r      s      $ r=   c                   "   \         P                  ! 4       V n        V P                  P                  4       G R j  xL
  V P                  P	                  V P
                  4       V #  L+5ir?   )r]   create_task_group_task_group
__aenter__
start_soon_receive_looprg   s   &r:   r   BaseSession.__aenter__   sR      224))+++##D$6$67 	,s   8A(A&,A(c          	      z   < V ^8  d   QhRS[ S[,          R,          RS[R,          RS[R,          RS[R,          /# rj   )rn   ro   r   r   )r8   r9   s   "r:   r;   r      sQ     K K}%,K %K $	K
 
Kr=   c                   "   V P                   P                  4       G R j  xL
  V P                  P                  P	                  4        V P                  P                  WV4      G R j  xL
 #  LL L5ir?   )r   acloser   cancel_scoper   	__aexit__rt   s   &&&&r:   r   BaseSession.__aexit__   s`      %%''' 	%%,,.%%//6JJJ 	(
 Ks"   A1A-AA1(A/)A1/A1c                j   < V ^8  d   QhRS[ RS[S[,          RS[R,          RS[RS[R,          RS[/# )r1   rR   result_typerequest_read_timeout_secondsNmetadataprogress_callbackr5   )r'   rn   r+   r   r   r/   )r8   r9   s   "r:   r;   r      s^     J2 J2J2 .)J2 '0$&6	J2
 "J2 '-J2 
J2r=   c                   "   V P                   pV^,           V n         \        P                  \        \        ,          ,          ! ^4      w  rxWpP
                  V&   VP                  RRRR7      p	VeG   RV	9  d   / V	R&   RV	R,          9  d   / V	R,          R&   WiR,          R,          R&   WPP                  V&    \        RRR	R
V/V	B p
V P                  P                  \        \        V
4      VR7      4      G Rj  xL
  RpVe   VP                  4       pM(V P                  e   V P                  P                  4       p \        P                  ! V4      ;_uu_ 4        VP!                  4       G Rj  xL
 pRRR4       \3        X\        4      '       d   \%        TP4                  4      hTP7                  TP8                  4      T P
                  P;                  TR4       T P                  P;                  TR4       TP=                  4       G Rj  xL
  TP=                  4       G Rj  xL
  #  EL2 L  + '       g   i     L; i  \"         dK    \%        \'        \(        P*                  P,                  RTP.                  P0                   RT R2R7      4      hi ; i L Lw  T P
                  P;                  TR4       T P                  P;                  TR4       TP=                  4       G Rj  xL 
  TP=                  4       G Rj  xL 
  i ; i5i)a  
Sends a request and wait for a response. Raises an McpError if the
response contains an error. If a request read timeout is provided, it
will take precedence over the session read timeout.

Do not use this method to emit notifications! Use send_notification()
instead.
Tjsonby_aliasmodeexclude_noneNparams_metaprogressTokenjsonrpc2.0idr4   r   z(Timed out while waiting for response to z	. Waited z	 seconds.r   r4   r@   )r   r]   create_memory_object_streamr!   r   r   
model_dumpr   r    r   sendr   r   total_secondsr   
fail_afterreceiveTimeoutErrorr   r   httpxcodesREQUEST_TIMEOUT	__class__rE   
isinstanceerrormodel_validateresultpopr   )rA   rR   r   r   r   r   rP   response_streamresponse_stream_readerrequest_datajsonrpc_requesttimeoutresponse_or_errors   &&&&&&       r:   send_requestBaseSession.send_request   s      %%
%>272S2STcfrTr2stu2v/-<z* ))4fSW)X(|+)+X&l84424X&w/?I"7+O<3D$$Z0(	2,  O $$)).P_A`ks*tuuu G+76DDF33?<<JJL%%g...D.L.L.N(N% / +\::06677"112C2J2JK ""&&z48$$((T:!((***(//111C v )O /. 
"[[88F&0099:)&iy2	 	
( +1 ""&&z48$$((T:!((***(//111s   B5L8AJ 9H+:AJ >I H00H.1H05I =AJ ALJL%J&L+J .H00I 	;I ?J  I AJJ LLAL+K.,LLLLc                8   < V ^8  d   QhRS[ RS[R,          RR/# )r1   notificationrelated_request_idNr5   )r)   rW   )r8   r9   s   "r:   r;   r   <  s.     7 7'7 &,7 
	7r=   c           
        "   \        R	RR/VP                  RRRR7      B p\        \        V4      V'       d   \	        VR7      MRR7      pV P
                  P                  V4      G Rj  xL
  R#  L5i)
zS
Emits a notification, which is a one-way message that does not expect
a response.
r   r   Tr   r   )r   Nr   r@   )r   r   r   r   r   r   r   )rA   r   r   jsonrpc_notificationsession_messages   &&&  r:   send_notificationBaseSession.send_notification<  st       3  
 
%%t&t%T 
 )"#78Ug*>PQmq
   %%o666s   A(A3*A1+A3c                :   < V ^8  d   QhRS[ RS[S[,          RR/# )r1   rP   rw   r5   N)rW   r(   r   )r8   r9   s   "r:   r;   r   Q  s)     ; ;y ;KR[D[ ;`d ;r=   c           
       "   \        V\        4      '       dH   \        R WR7      p\        \	        V4      R7      pV P
                  P                  V4      G Rj  xL
  R# \        R VVP                  RRRR7      R7      p\        \	        V4      R7      pV P
                  P                  V4      G Rj  xL
  R#  L` L5i)r   r   r   r   r4   NTr   r   )r   r   r   )	r   r   r   r   r   r   r   r!   r   )rA   rP   rw   jsonrpc_errorr   jsonrpc_responses   &&&   r:   r|   BaseSession._send_responseQ  s     h	**(:VM,^M5RSO$$))/:::.**DvTX*Y 
 -^DT5UVO$$))/::: ; ;s%   AB>B:AB>3B<4B><B>c                   < V ^8  d   QhRR/# r   r@   )r8   r9   s   "r:   r;   r   _  s     k/ k/T k/r=   c                  a "   S P                   ;_uu_4       GR j  xL
  S P                  ;_uu_4       GR j  xL
   S P                     R j  xL
  p\        V\        4      '       d   S P	                  V4      G R j  xL
  K;  \        VP
                  P                  \        4      '       Ed    S P                  P                  VP
                  P                  P                  RRRR7      4      p\        VP
                  P                  P                  VP                  P                  '       d!   VP                  P                  P                  MR VS V 3R lVP                  R7      pVS P                   VP"                  &   S P%                  V4      G R j  xL
  VP&                  '       g   S P	                  V4      G R j  xL
  EK  EK  \        VP
                  P                  \:        4      '       Ed    S P<                  P                  VP
                  P                  P                  RRRR7      4      p\        VP                  \>        4      '       da   VP                  P                  P@                  pVS P                   9   d-   S P                   V,          PC                  4       G R j  xL
  EKn  EKq  \        VP                  \D        4      '       d   VP                  P                  PF                  p	V	S PH                  9   d   S PH                  V	,          p
 V
! VP                  P                  PJ                  VP                  P                  PL                  VP                  P                  P
                  4      G R j  xL
  S PQ                  V4      G R j  xL
  S P	                  V4      G R j  xL
  EKw  S PS                  V4      G R j  xL
  EK   EL EL EL ELh ELQ EL)  \         d   p\(        P*                  ! RT 24       \(        P,                  ! RTP
                  P                   24       \/        RTP
                  P                  P                  \1        \2        R	R
R7      R7      p\5        \7        T4      R7      pS P                  P9                  T4      G R j  xL 
   R p?EKr  R p?ii ; i EL EL@  \         d#   p\(        PN                  ! RT4        R p?ELfR p?ii ; i ELZ ELD  \         d=   p\(        P*                  ! RT RTP
                  P                   24        R p?EK  R p?ii ; i ELuEDM]  \T        PV                   d    \(        P,                  ! R4        M0\         d$   p\(        PX                  ! RT 24        R p?MR p?ii ; i\[        S P\                  P_                  4       4       Fg  w  r\1        \`        RR7      p TP9                  \/        RYR7      4      G R j  xL 
  TPc                  4       G R j  xL 
  KW    \         d     Ke  i ; i	  S P\                  Pe                  4        M  \[        S P\                  P_                  4       4       Fg  w  r\1        \`        RR7      p TP9                  \/        RYR7      4      G R j  xL 
  TPc                  4       G R j  xL 
  KW    \         d     Ke  i ; i	  S P\                  Pe                  4        i ; iR R R 4      GR j  xL 
  M  + GR j  xL 
 '       g   i     M; iR R R 4      GR j  xL 
  R #   + GR j  xL 
 '       g   i     R # ; i5i)NTr   r   c                 P   < SP                   P                  V P                  R 4      # r?   )r   r   rP   )rrA   s   &r:   <lambda>+BaseSession._receive_loop.<locals>.<lambda>t  s    doo6I6I!,,X\6]r=   )rP   rQ   rR   rS   rT   rV   zFailed to validate request: z Message that failed validation: r   zInvalid request parameters r   r   r   z)Progress callback raised an exception: %sz!Failed to validate notification: z. Message was: zRead stream closed by clientz%Unhandled exception in receive loop: zConnection closedr   )3r   r   r   r   _handle_incomingr4   rootr    r   r   r   rN   r   r   metar   r   rP   _received_requestr\   loggingwarningdebugr   r   r   r   r   r   r   r   r   	requestIdr   r"   r   r   r2   r3   r   _received_notification_handle_responser]   ClosedResourceError	exceptionlistr   itemsr   r   clear)rA   r4   validated_request	respondereerror_responser   r   cancelled_idprogress_tokencallbackr   streamr   s   f             r:   r   BaseSession._receive_loop_  s    f/%)%6%6 M= M='!'955"33G<<<#GOO$8$8.II"K040J0J0Y0Y ' 4 4 ? ?TZim ? n1- )9+2??+?+?+B+B#4#9#9#@#@#@ .?-C-C-J-J-O-O%)(9(,,]181A1A	)I ENDOOI,@,@A"&"8"8"CCC#,#7#7#7&*&;&;I&F F F $8& $GOO$8$8:MNN"+/+J+J+Y+Y ' 4 4 ? ?TZim ? n,L  *,*;*;=RSS/;/@/@/G/G/Q/Q#/4??#B*.//,*G*N*N*P$P$P $C $.l.?.?AU#V#V5A5F5F5M5M5[5[N (69Q9Q'Q373K3KN3[
).2:0<0A0A0H0H0Q0Q0<0A0A0H0H0N0N0<0A0A0H0H0P0P3. -. -. '+&A&A,&O O O&*&;&;L&I I I #33G<<<c M=<" D !G( K $OO.J1#,NO#MM,LW__MaMaLb*cd-9(-#*??#7#7#:#:&/)7,H)+'".N /=^TbEc.dO"&"4"4"9"9/"JJJJK4 %Q-.
 09 ).,3MM0[01-. -.).
 !P I( #OO"CA3oV]VeVeVjVjUk l  =[ &7^ ,, > <= O !!$I!"MNNO #'t'='='C'C'E"FJB%+<FYZE$kk,u*YZZZ$mmo--$  #G &&,,. #'t'='='C'C'E"FJB%+<FYZE$kk,u*YZZZ$mmo--$  #G &&,,.Q  s  ]"O]"]O!]\	UU
O$U
,U?O' 1U2C'O0
O*O0
0O0
O-O0
	1U;B6T
1S2T
6U<A$T
!A'S
S	S
T
!S;"T
:S>;T
?UUU]"!]$U
'U*O0
-O0
0S;B5R=0R31R=6U=SUT
S
S8S3-T
3S88T
>T
U0U<UUUUY+V+<Y>V+V+V&!Y&V++Y.9\	(X(
X
X(
 X#!X(
&\	(X73\	6X77 \	:\[1Z42[
[[\[!\ [!! \\	]\]\/\
\/(\/*]2]"=] >]"]	]
]	]		]"c                &   < V ^8  d   QhRS[ RS[ /# )r1   response_idr5   )rW   )r8   r9   s   "r:   r;   r     s       y r=   c                    \        V\        4      '       d    \        V4      # V#   \         d     \        P
                  ! RT: R24        T# i ; i)a  
Normalize a response ID to match how request IDs are stored.

Since the client always sends integer IDs, we normalize string IDs
to integers when possible. This matches the TypeScript SDK approach:
https://github.com/modelcontextprotocol/typescript-sdk/blob/a606fb17909ea454e83aab14c73f14ea45c04448/src/shared/protocol.ts#L861

Args:
    response_id: The response ID from the incoming message.

Returns:
    The normalized ID (int if possible, otherwise original value).
zResponse ID z/ cannot be normalized to match pending requests)r   r7   int
ValueErrorr  r  )rA   r  s   &&r:   _normalize_request_id!BaseSession._normalize_request_id  sY     k3''o;''   o,{o=l mnos   
% &AAc                $   < V ^8  d   QhRS[ RR/# )r1   r4   r5   N)r   )r8   r9   s   "r:   r;   r     s     %r %rn %r %rr=   c                  "   VP                   P                  p\        V\        \        ,          4      '       g   R# V P                  VP                  4      p\        V\        4      '       d9   V P                   F'  pVP                  W2P                  4      '       g   K&   R# 	  MCVP                  ;'       g    / pV P                   F  pVP                  W54      '       g   K   R# 	  V P                  P                  VR4      pV'       d   VP                  V4      G Rj  xL
  R# V P                  \!        RV 24      4      G Rj  xL
  R#  L- L5i)z
Handle an incoming response or error message.

Checks response routers first (e.g., for task-related responses),
then falls back to the normal response stream mechanism.
Nz.Received response with an unknown request ID: )r4   r   r   r!   r   r  r   r   route_errorr   r   route_responser   r   r   r   rr   )rA   r4   r   r  r   response_datar  s   &&     r:   r  BaseSession._handle_response  s     ## $, >?? 009 dL))00%%k::>> 1
 -1KK,=,=2M00((DD 1
 ''++K>++d###''7efmen5o(pqqq $qs<   BEE8&E#(EE E!&EEEEc                :   < V ^8  d   QhRS[ S[S[3,          RR/# )r1   r  r5   N)rN   r*   r(   )r8   r9   s   "r:   r;   r     s(      1A/S^B^1_ dh r=   c                   "   R# 5i)z
Can be overridden by subclasses to handle a request without needing to
listen on the message stream.

If the request is responded to within this method, it will not be
forwarded on to the message stream.
Nr@   )rA   r  s   &&r:   r  BaseSession._received_request       rD   c                $   < V ^8  d   QhRS[ RR/# )r1   r   r5   N)r-   )r8   r9   s   "r:   r;   r     s      9M RV r=   c                   "   R# 5i)zk
Can be overridden by subclasses to handle a notification without needing
to listen on the message stream.
Nr@   )rA   r   s   &&r:   r  "BaseSession._received_notification  r'  rD   c          
      b   < V ^8  d   QhRS[ S[,          RS[RS[R,          RS[ R,          RR/# )r1   r  r2   r3   Nr4   r5   )r7   r  r6   )r8   r9   s   "r:   r;   r     sI     
 
c	
 
 t|	

 t
 

r=   c                   "   R# 5i)zP
Sends a progress notification for a request that is currently being
processed.
Nr@   )rA   r  r2   r3   r4   s   &&&&&r:   send_progress_notification&BaseSession.send_progress_notification  r'  rD   c                Z   < V ^8  d   QhRS[ S[S[3,          S[,          S[,          RR/# )r1   reqr5   N)rN   r*   r(   r-   r   )r8   r9   s   "r:   r;   r   #  s5      o{:;>RRU^^ 
r=   c                   "   R# 5i)zCA generic handler for incoming messages. Overwritten by subclasses.Nr@   )rA   r0  s   &&r:   r   BaseSession._handle_incoming#  s
     
 	rD   c                   < V ^8  d   Qh/ S[ S[S[S[S[,          ,          3,          ;R&   S[;R&   S[ S[S[S[S[3,          3,          ;R&   S[ S[S[	3,          ;R&   S[
R,          ;R&   # )r1   r   r   r   r   r   r   )dictrW   r   r!   r   r  rN   r*   r(   r/   r  )r8   r9   s   "r:   r;   r      s     " I'=oP\>\']]^^# $ % & Y 0+1M NNOO' ( i455) * ,--+ r=   )r   r   r   r   r   r   r   r   r   r   r   r   r?   )NNN)NN)rE   rF   rG   rH   rI   rb   r   r   r   r   r   r|   r   r  r  r  r  r-  r   __annotate_func__rJ   rK   rL   s   @r:   r   r      s     , ,*. . K KJ2 J2X7 7*; ;k/ k/Z *%r %rN  
 
 C  r=   r   )=r  collections.abcr   
contextlibr   datetimer   typesr   typingr   r   r	   r
   r]   r   anyio.streams.memoryr   r   pydanticr   typing_extensionsr   mcp.shared.exceptionsr   mcp.shared.messager   r   r   mcp.shared.response_routerr   	mcp.typesr   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r-   r7   r  rW   r/   rN   r   r@   r=   r:   <module>rB     s    $ %   2 2   R  " * U U 5    ( ~}mDm\<@/1CEWX +]MJ);57IK]^ #I	( h0w;< h0VF		Fr=   