@@ -140,18 +140,17 @@ def __init__(
140140 self ._request_handlers ["ping" ] = RequestHandler ("ping" , handler = _ping_handler )
141141
142142 # Process user-provided handlers with duplicate detection
143- if handlers :
144- for handler in handlers :
145- if isinstance (handler , RequestHandler ):
146- if handler .method in self ._request_handlers :
147- raise ValueError (f"Duplicate request handler for '{ handler .method } '" )
148- self ._request_handlers [handler .method ] = handler
149- elif isinstance (handler , NotificationHandler ): # pyright: ignore[reportUnnecessaryIsInstance]
150- if handler .method in self ._notification_handlers :
151- raise ValueError (f"Duplicate notification handler for '{ handler .method } '" )
152- self ._notification_handlers [handler .method ] = handler
153- else :
154- raise TypeError (f"Unknown handler type: { type (handler )} " )
143+ for handler in handlers :
144+ if isinstance (handler , RequestHandler ):
145+ if handler .method in self ._request_handlers :
146+ raise ValueError (f"Duplicate request handler for '{ handler .method } '" )
147+ self ._request_handlers [handler .method ] = handler
148+ elif isinstance (handler , NotificationHandler ): # pyright: ignore[reportUnnecessaryIsInstance]
149+ if handler .method in self ._notification_handlers :
150+ raise ValueError (f"Duplicate notification handler for '{ handler .method } '" )
151+ self ._notification_handlers [handler .method ] = handler
152+ else :
153+ raise TypeError (f"Unknown handler type: { type (handler )} " )
155154
156155 def _add_handler (self , handler : Handler ) -> None :
157156 """Add a handler, silently replacing any existing handler for the same method."""
@@ -376,8 +375,8 @@ async def _handle_request(
376375 if hasattr (req , "params" ) and req .params is not None :
377376 task_metadata = getattr (req .params , "task" , None )
378377 ctx = RequestContext (
379- session ,
380- lifespan_context ,
378+ session = session ,
379+ lifespan_context = lifespan_context ,
381380 experimental = Experimental (
382381 task_metadata = task_metadata ,
383382 _client_capabilities = client_capabilities ,
@@ -424,8 +423,8 @@ async def _handle_notification(
424423 client_capabilities = session .client_params .capabilities if session .client_params else None
425424 task_support = self ._experimental_handlers .task_support if self ._experimental_handlers else None
426425 ctx = RequestContext (
427- session ,
428- lifespan_context ,
426+ session = session ,
427+ lifespan_context = lifespan_context ,
429428 experimental = Experimental (
430429 task_metadata = None ,
431430 _client_capabilities = client_capabilities ,
0 commit comments