MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / on_request

Method on_request

src/mcp/server/runner.py:202–211  ·  view source on GitHub ↗

`_on_request` wrapped in `dispatch_middleware`, outermost-first. Dispatch-tier middleware sees raw `(dctx, method, params) -> dict` and wraps everything - initialize, METHOD_NOT_FOUND, validation failures included.

(self)

Source from the content-addressed store, hash-verified

200
201 @cached_property
202 def on_request(self) -> OnRequest:
203 """`_on_request` wrapped in `dispatch_middleware`, outermost-first.
204
205 Dispatch-tier middleware sees raw `(dctx, method, params) -> dict` and
206 wraps everything - initialize, METHOD_NOT_FOUND, validation failures
207 included.
208 """
209 return reduce(
210 lambda handler, middleware: middleware(handler), reversed(self.dispatch_middleware), self._on_request
211 )
212
213 @cached_property
214 def on_notify(self) -> OnNotify:

Callers 1

serve_oneFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected