Model Context Protocol (MCP)
PydanticAI supports Model Context Protocol (MCP) in three ways:
- Agents act as an MCP Client, connecting to MCP servers to use their tools, learn more …
- Agents can be used within MCP servers, learn more …
- As part of PydanticAI, we're building a number of MCP servers, see below
What is MCP?
The Model Context Protocol is a standardized protocol that allow AI applications (including programmatic agents like PydanticAI, 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:
- PydanticAI 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
- PydanticAI, or any other MCP client could connect to our Run Python MCP server to run arbitrary Python code in a sandboxed environment
MCP Servers
To add functionality to PydanticAI while making it as widely usable as possible, we're implementing some functionality as MCP servers.
So far, we've only implemented one MCP server as part of PydanticAI:
- Run Python: A sandboxed Python interpreter that can run arbitrary code, with a focus on security and safety.