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

Method run

src/mcp/shared/dispatcher.py:201–218  ·  view source on GitHub ↗

Drive the receive loop until the underlying channel closes. Each inbound request is dispatched to `on_request` in its own task; the returned dict (or raised `MCPError`) is sent back as the response. Inbound notifications go to `on_notify`. `task_status.started()` is

(
        self,
        on_request: OnRequest,
        on_notify: OnNotify,
        *,
        task_status: anyio.abc.TaskStatus[None] = anyio.TASK_STATUS_IGNORED,
    )

Source from the content-addressed store, hash-verified

199 """
200
201 async def run(
202 self,
203 on_request: OnRequest,
204 on_notify: OnNotify,
205 *,
206 task_status: anyio.abc.TaskStatus[None] = anyio.TASK_STATUS_IGNORED,
207 ) -> None:
208 """Drive the receive loop until the underlying channel closes.
209
210 Each inbound request is dispatched to `on_request` in its own task;
211 the returned dict (or raised `MCPError`) is sent back as the response.
212 Inbound notifications go to `on_notify`.
213
214 `task_status.started()` is called once the dispatcher is ready to
215 accept `send_request`/`notify` calls, so callers can use
216 `await tg.start(dispatcher.run, on_request, on_notify)`.
217 """
218 ...

Callers 15

cliFunction · 0.45
_run_serverMethod · 0.45
post_writerFunction · 0.45
post_writerMethod · 0.45
_get_npx_commandFunction · 0.45
devFunction · 0.45
runFunction · 0.45
run_codegenFunction · 0.45
buildFunction · 0.45
lifespanFunction · 0.45
mainFunction · 0.45
run_serverFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected