run • AI Agent SDK
run: Main thread function that processes MCP requests.
run
Method
</div>
This is a method of the MCPToolRunner class in the mcp module.
Main thread function that processes MCP requests.
On Windows the stdio transport must spawn a child process (e.g. `npx) and talk to it over pipes. A non-main thread gets a SelectorEventLoop by default there, which does not support subprocesses and fails with an opaque fileno error during init (issue #5598). Use a dedicated ProactorEventLoop on Windows so subprocess stdio works; other platforms keep the standard asyncio.run` behaviour.
Signature
def run() -> AnyReturns
ResponseField
AnyThe result of the operation.
Uses
platform.systemasyncio.ProactorEventLoopasyncio.set_event_looploop.run_until_completeloop.shutdown_asyncgensloop.shutdown_default_executorloop.closeasyncio.run
Used By
Source
View on GitHubpraisonaiagents/mcp/mcp.py at line 70