AI Engineer World's Fair 2025
MCP is all you need
Loading slides…
Read the talk
MCP is all you need: letting tools borrow the client’s model
MCP sampling lets an agent inside a tool request inference through its client. A PyPI research example shows how this separates specialized context, SQL repair and progress reporting from the main agent.
From a talk by Samuel Colvin
Before you start: Familiarity with Python, LLM tool calling and basic SQL will help you follow the demonstration.
How much infrastructure does agent communication need?
When agents need to communicate, how much new infrastructure do we actually need? Samuel Colvin approaches that question from Python’s validation and agent tooling. He created Pydantic, which he reports was receiving about 360 million downloads a month, approximately 140 per second. He describes its use throughout general Python development and broadly across Python’s generative AI SDKs and agent frameworks.
Pydantic became a company at the beginning of 2023, then expanded into Pydantic AI, a Python agent framework built on similar principles, and Logfire, its commercial observability platform. Colvin also describes himself as a somewhat inactive co-maintainer of the MCP Python SDK. Those projects bring together the concerns that recur throughout the demonstration: typed interfaces, agent execution and visibility into what happened.
The title riffs on Jason Liu’s talks, Pydantic Is All You Need and Pydantic Is Still All You Need. Its qualification matters: neither Pydantic nor MCP solves everything. The useful claim is narrower—MCP already provides capabilities that can simplify communication between agents, so inventing another communication mechanism may be unnecessary.
The scope here is autonomous agents and application code, particularly Python, rather than Claude Desktop, Cursor, Zed or Windsurf. Colvin characterizes those interactive applications as MCP’s original focus. MCP’s prompts and resources can be valuable there; for the autonomous application he is building, they play a smaller role. Tool calling is the part that carries the design.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Tool calling needs more than an endpoint description
Why not describe the tools with OpenAPI? Colvin’s answer is that the requirements extend beyond describing a request and its final response. A running agent may need a changing tool inventory, messages during execution, or an inference request flowing in the opposite direction.
| Capability | What it enables |
|---|---|
| Dynamic tools | Tools appear or disappear as server state changes. |
| Logging | Information reaches the client before a tool finishes. |
| Sampling | A server asks its client to arrange inference. |
| Tracing and observability | Developers inspect execution across components. |
| Standard input/output | A tool server runs as a local subprocess. |
These are the requirements behind Colvin’s OpenAPI comparison. In particular, subprocess communication over standard input and standard output gives application code a useful way to compose local tools without treating every integration as an HTTP service.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
When a tool is itself an agent
The familiar MCP architecture connects an agent to independently developed tools. The agent need not be designed for a particular tool, and the tool need not know the agent that will call it. Colvin compares this to a browser visiting a website: the shared protocol makes composition possible. Today’s browser monoculture weakens the diversity of that example, but the original interoperability principle still applies.
Now let one of those tools be an agent. It can reason with an LLM and call additional tools, either through MCP or through direct integrations. The composition still works, but each nested agent now needs model access, configuration and resources. A remote MCP server also has to account for the inference costs it incurs while answering someone else’s request.
Sampling moves access to inference back through the client. Instead of requiring every agent exposed as a tool to provision its own model connection, the tool can ask the originating client to obtain a model response on its behalf.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
The sampling round trip
In MCP, sampling means a server can request a model generation through its client. The server is still serving a tool call; requesting inference is an intermediate step toward completing that call.
The request follows this sequence:
- The outer agent calls its LLM, which selects an MCP tool.
- The client sends the tool call to the MCP server.
- The server determines that it needs an LLM response and sends a sampling request back to the client.
- The client obtains the model response and passes it to the server.
- The server finishes its work and returns the tool result, allowing the outer agent to continue.
The client retains control over model selection and permissions. Borrowing the client’s model access does not guarantee use of the identical outer model, and it does not make inference free.
At the time of the presentation, Colvin describes sampling as powerful but not widely supported. Pydantic AI’s implementation was still a pull request, covering both sides: client support for proxying model calls and server support for using the MCP client as the model connection. The demonstration therefore reflects that development version.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
A research tool that generates and repairs SQL
The concrete application is a research agent for open-source packages and libraries. A complete research system would need many tools; this demonstration implements one: looking up package download counts in the public PyPI dataset on BigQuery. The tool contains a Pydantic AI agent that turns a question into SQL.
The setup configures Logfire, declares the dependencies available during execution and permits retries when the model returns unsuitable output. A substantial system prompt gives the inner agent the table schema, instructions and examples. That prepares the model to generate a query, but generation alone is not the completion condition.
The output validator connects the generated SQL to the database:
- Remove surrounding Markdown formatting when present.
- Check that the query targets the expected table, returning corrective feedback if it does not.
- Execute the query.
- If execution fails, raise
ModelRetryso the model receives feedback and can attempt a repair.
The key change is that a database error becomes another input to the agent rather than immediately ending the tool call.
The execution-to-retry boundary can be expressed in Python as a small helper, called after formatting and table checks:
python
from collections.abc import Callable
from typing import TypeVar
from pydantic_ai import ModelRetry
Result = TypeVar("Result")
def execute_or_retry(
sql: str,
execute_query: Callable[[str], Result],
query_error: type[Exception],
) -> Result:
try:
return execute_query(sql)
except query_error as exc:
raise ModelRetry(
f"The query failed: {exc}. Correct the SQL and try again."
) from exc
The database adapter supplies the execution function and its query-error type. Pydantic AI handles the retry after ModelRetry propagates out of the validator, subject to the configured retry allowance. The demonstrated validator also calls context.deps.mcp_context.log as it works.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Keep the user informed while the tool runs
The MCP call context reaches the inner agent through its typed dependencies. With deps_type describing those dependencies, a validator—or another tool call—can access the MCP context through context.deps.mcp_context. Type hints expose the log method and its signature, so logging remains available inside the agent without losing the interface information supplied by the SDK.
Those log messages return to the client before the tool finishes and can ultimately reach the person waiting for the answer. MCP also has a separate progress-notification capability, which this example does not use. Logging can describe what is happening; progress notifications could report how far an operation has advanced when that information is available.
The same mechanism serves two interfaces. In a Cursor-style application, it can reassure the user that a tool is still working and explain its current activity. In a web research application, it can expose activity during a task that takes minutes. The final answer no longer has to be the first visible sign of work.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Put specialized context inside the tool
After a successful query, the tool converts the output into a list of dictionaries and then formats it as XML-like text. Colvin chooses that representation because he finds models good at interpreting XML. The result is structured text for the outer model to read, rather than a final answer written directly for the user.
The server uses FastMCP bundled inside the MCP Python SDK, which Colvin distinguishes from the separate implementation sharing that name. This is the historical SDK API used in the recording; the repository’s current v2 quickstart has breaking changes. The server registers one PyPI-downloads tool, and the Python function’s docstring becomes the tool description supplied to the LLM that decides whether to call it.
The tool accepts the user’s question in natural language. An alternative would be to make the central agent generate SQL, placing the table schema and query instructions in its context or in a large tool description. Colvin reports that models do not respond well to excessive information in tool descriptions. More fundamentally, those instructions would occupy the main agent’s context on calls where it never uses the PyPI tool.
| SQL generation location | Main agent carries | Specialized work happens |
|---|---|---|
| Central agent | Schema and query instructions | In the outer model call |
| Inside the tool | A description of the tool’s purpose | When the tool is invoked |
Keeping inference inside the tool also keeps its specialized context there. Sampling supplies model access across that boundary without requiring the main agent to carry the SQL-generation prompt. The tool returns a string, and the demonstrated server runs over standard input and standard output by default.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Ask the question, then inspect the nested execution
The main application registers one MCP server that launches the PyPI server script. The outer agent acts as the MCP client and makes the server’s tool available to its model. It also receives the current date, avoiding stale assumptions about what “this year” means. Colvin then asks how many downloads Pydantic has had this year and runs the agent live.
The live demonstration reports about 1.6 billion Pydantic downloads for the year to date. That is the application’s reported result, not a count of unique users; the recording does not establish the calendar year, exact cutoff or query filters needed to reproduce it.
Colvin next opens Logfire. The trace shown is from a run immediately before he came on stage, rather than the just-completed live run. He leaves the detailed treatment of MCP tracing to the following talk and focuses on reading the application’s execution. The outer agent calls GPT-4o, which selects the PyPI tool. It passes a natural-language description of the question; it does not generate the SQL itself.
The MCP client calls the server, which runs a second Pydantic AI agent. That inner agent requests inference through the client, producing the alternating client and server service entries visible in the trace. The nesting makes the sampling path inspectable: the server’s model work appears inside the tool execution, while the client supplies the model connection.
Opening the outer model exchange shows the next boundary: the query’s XML-like result comes back as the tool response, and the outer LLM turns it into a human-readable answer. Opening the inner server-agent call reveals the SQL that was generated and executed. Colvin inspects it and says it looks correct. The demonstration ends with both levels visible—the answer delivered to the user and the database query underneath it—so a plausible sentence is not the only evidence available for understanding the result.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Resources
From the talk
The March 2025 protocol revision explains how servers request model generations through clients, including capability negotiation and model preferences.
Python implementations for MCP clients and servers. The current repository documents SDK v2 and links to the earlier v1 line.
Further reading
PyPA's guide provides BigQuery setup, the download table schema, example SQL and limitations of download counts.
Colvin's February 2023 account of starting the company and funding its next stage.
Updates since the talk
Current examples show a Pydantic AI agent inside an MCP tool and model requests routed through a sampling-capable client.
- Pydantic's Q2 2025 updateArticle
Samuel Colvin reports released MCP sampling support alongside Pydantic AI and Logfire improvements.
Full transcript
Loading transcript…