#310

MCP: get_stdio_tools() fails in documented setup

Opendajiaohuangopened 1mo ago

Bug description

The MCP reference shows calling get_stdio_tools() as setup code that returns AgentTool values to pass to ai.Agent. On the frozen main revision, the documented call raises before returning tools when run outside agent.run().

Reproduction

From the repository root with Python 3.12:

uv run --frozen --python 3.12 python -c 'import asyncio, ai; asyncio.run(ai.mcp.get_stdio_tools("python", "--version"))'

Observed error:

RuntimeError: MCP tools must be used inside agent.run(). The connection pool is not initialized.

The pool check happens before an MCP transport is started, so this call does not launch the subprocess.

Expected behavior

The documented setup call should return tools that can be passed to ai.Agent, or the reference should show a supported lifecycle for discovery.

Source context

get_stdio_tools() calls the connection helper without establishing the pool. get_http_tools() establishes the pool around discovery. This is reproducible against main at c788059dd1db2d93ae1c3da6daffb660eca07dbb.

Activity

0

No activity yet.