Model Context Protocol (MCP)
Pydantic AI supports Model Context Protocol (MCP) in two ways:
- Agents can connect to MCP servers and user their tools
- Pydantic AI can act as an MCP client and connect directly to local and remote MCP servers, learn more …
- Some model providers can themselves connect to remote MCP servers, learn more …
- Agents can be used within MCP servers, learn more …
What is MCP?
The Model Context Protocol is a standardized protocol that allow AI applications (including programmatic agents like Pydantic AI, coding agents like cursor, and desktop applications like Claude Desktop) to connect to external tools and services using a common interface.
As with other protocols, the dream of MCP is that a wide range of applications can speak to each other without the need for specific integrations.
There is a great list of MCP servers at github.com/modelcontextprotocol/servers.
Some examples of what this means:
- Pydantic AI could use a web search service implemented as an MCP server to implement a deep research agent
- Cursor could connect to the Pydantic Logfire MCP server to search logs, traces and metrics to gain context while fixing a bug
- Pydantic AI, or any other MCP client could connect to our Run Python MCP server to run arbitrary Python code in a sandboxed environment