MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / on_request

Function on_request

tests/shared/test_jsonrpc_dispatcher.py:165–168  ·  view source on GitHub ↗
(ctx: DCtx, method: str, params: Mapping[str, Any] | None)

Source from the content-addressed store, hash-verified

163 handler_started = anyio.Event()
164
165 async def on_request(ctx: DCtx, method: str, params: Mapping[str, Any] | None) -> dict[str, Any]:
166 handler_started.set()
167 await ctx.cancel_requested.wait()
168 return {"completed": "after-cancel"}
169
170 async def on_notify(ctx: DCtx, method: str, params: Mapping[str, Any] | None) -> None:
171 pass # the cancelled notification is teed here; nothing to observe

Callers

nothing calls this directly

Calls 2

waitMethod · 0.80
progressMethod · 0.45

Tested by

no test coverage detected