Chapter 10: Model Context Protocol (MCP)
Lecture
Chapter principle
Key takeaways
- MCP standardizes an integration boundary; it is not itself an agent.
- MCP is JSON-RPC 2.0 with an initialize handshake, capability negotiation, and stdio or Streamable HTTP transports.
- Servers offer tools, resources, and prompts; clients may offer roots, sampling, and elicitation.
- A failed tool returns isError: true; an unprocessable request returns a JSON-RPC error.
- Protocol authorization governs access to a server; per-action permission remains host policy.
- Tool definitions are untrusted input: they can be poisoned, changed, or collide across servers.
Experiments
Every experiment in the book is small, runnable and printed with its real output. In the Lab you can replay a recorded real run of each one, with no programming, and watch what the model and the agent do.
Experiment 21: A tool over a standard protocol
How does a model use a tool it discovers over a standard protocol?
The program plays both sides of a tool protocol shaped like MCP. A client asks a server what it can do and learns of one tool, a calculator. That list becomes the model’s tool description. The model gets two tasks: a multiplication, and “Delete invoice 7”, which no listed tool can do. Two more proposals are written by hand to show the two error paths. This is a recorded run of a real model. Its reply to the second task will be worded differently in a new run.
All the code for this chapter: github.com/agentic-engineering-book/code
Download the bookBrowse all chapters