@@ -142,11 +142,15 @@ class ServerRunner(Generic[LifespanT]):
142142 init_options : InitializationOptions | None = None
143143 """`InitializeResult` payload. Defaults to `server.create_initialization_options()`."""
144144
145+ @cached_property
146+ def on_request (self ) -> OnRequest :
147+ return self ._on_request
148+
145149 @cached_property
146150 def on_notify (self ) -> OnNotify :
147151 return self ._on_notify
148152
149- async def on_request (
153+ async def _on_request (
150154 self ,
151155 dctx : DispatchContext [TransportContext ],
152156 method : str ,
@@ -263,7 +267,7 @@ async def _inner(ctx: ServerRequestContext[LifespanT, Any]) -> None:
263267 def _compose_server_middleware (self , inner : CallNext ) -> CallNext :
264268 """Wrap `inner` in `Server.middleware`, outermost-first.
265269
266- Shared by `on_request ` and `_on_notify` so the same middleware chain
270+ Shared by `_on_request ` and `_on_notify` so the same middleware chain
267271 observes every inbound message. The composed callable takes the `ctx`
268272 at call time, so a middleware can rewrite it for the rest of the chain.
269273 """
@@ -338,7 +342,7 @@ def _negotiate_initialize(params: Mapping[str, Any] | None) -> tuple[InitializeR
338342 return init , negotiated
339343
340344 def _handle_initialize (self , params : Mapping [str , Any ] | None ) -> InitializeResult :
341- """Build the `initialize` result; state commits later in `on_request `."""
345+ """Build the `initialize` result; state commits later in `_on_request `."""
342346 _ , negotiated = self ._negotiate_initialize (params )
343347 opts = self .init_options if self .init_options is not None else self .server .create_initialization_options ()
344348 return InitializeResult (
0 commit comments