MCP is all you need — Samuel Colvin, Pydantic

Introduction to Pydantic and MCP 00:00

  • Samuel Colvin introduces himself as the creator of Pydantic, a popular Python data validation library with 360 million downloads per month.
  • Pydantic is widely used in general Python development and GenAI, including SDKs and agent frameworks.
  • Colvin's company, Pydantic, has developed Pydantic AI (an agent framework) and Pydantic Logfire (an observability platform).
  • He is an inactive co-maintainer of the MCP Python SDK.
  • The talk's title is a play on previous talks ("Pydantic is all you need"), emphasizing that MCP can simplify many use cases in agent communication.

MCP Primitives and Tool Calling 02:03

  • The focus is on autonomous agents or code, not UI-based coding agents like Cursor or Zed.
  • Of MCP's three primitives (prompts, resources, tool calling), prompts and resources are less relevant for this use case.
  • Tool calling is highlighted as especially valuable and more complex than just using OpenAPI.
  • MCP supports dynamic tools, logging during execution, sampling (a powerful but confusingly named capability), tracing, and running as a subprocess over standard I/O.
  • MCP enables agents and tools to be composed agnostically, similar to how browsers and websites interact using open protocols.

Sampling in MCP 05:01

  • Sampling allows a remote MCP server to use the client's LLM, reducing cost and complexity.
  • The client proxies LLM requests on behalf of the server; this chain can continue through multiple tool calls.
  • Sampling enables features like dynamic LLM access but is not widely supported yet.
  • Pydantic AI is adding support for MCP sampling as both client and server.

Example: Research Agent with BigQuery Tool 07:10

  • A demo agent is configured to research open-source packages using a single tool that queries the BigQuery public dataset for PyPI downloads.
  • Code is shown configuring dependencies, retries, and a system prompt that describes table/schema details.
  • Output validation includes removing markdown quotes, table name checks, executing queries, and retrying with the LLM if the query fails.
  • Logging via MCP context provides progress updates to users before completion.
  • This technique allows for interactive updates (logs or progress) while an agent or tool is still working.

Running an MCP Server and Integrating Tools 10:50

  • An MCP server is set up using Fast MCP, registering the BigQuery tool for PyPI downloads.
  • Tool descriptions (from docstrings) are presented to the LLM for selection.
  • Offloading SQL generation and related instructions to the tool (rather than the central agent) keeps the main agent’s context window smaller and more manageable.
  • The server runs over standard IO, easily integrating with agent frameworks.

Demo Results and Observability with Logfire 13:01

  • The agent can answer questions like “How many downloads did Pydantic have this year?” with real data (e.g., 1.6 billion downloads).
  • Observability through Logfire allows inspection of the full workflow, from outer agent’s prompt to tool decision, SQL query generation, and final results.
  • The system shows chaining of client-server-client calls, model usage, and returns structured XML-ish query results to the LLM for natural language output.
  • Actual SQL generated by the agent can be inspected for correctness and transparency.

Conclusion and Q&A Invitation 15:07

  • Samuel invites questions and discussion at the Pydantic booth, welcoming further exploration or demonstrations of potential failure cases.