Agent(mcp_servers=[...]). Pydantic AI provides the client integration.
Pydantic AI 2.x
UseMCPToolset for an HTTP MCP server:
StdioTransport to MCPToolset; see Pydantic AI’s MCP client documentation.
In-process FastMCP
Install the optional server package:Pydantic AI 1.x
ExistingMCPServerStdio and HTTP server instances remain supported when using Pydantic AI 1.x. Those classes were replaced by MCPToolset in 2.x; use the API that matches your installed Pydantic AI version.
A Thread context keeps managed server connections available across calls and closes them on exit. See threads.