Lesson 15.04 · Phase 15 · Capstone: Your Own Agent Harness

MCP client integration

An MCP server is someone else's code, running as a subprocess, writing text your model will read. Connect to it like you'd connect to any untrusted service.

Learning objectives

  • Build an MCP client over stdio: start the server, do the initialize handshake, list tools with pagination, and call them.
  • Turn MCP tools into harness tools with namespaced names, so they go through the same registry, validation and (later) permissions as built-ins.
  • Handle the ways servers fail: they won't start, they're too slow, they crash mid-call, they print junk.
  • Keep your environment away from servers by default, and treat their descriptions and annotations as untrusted text.

In 15.01 the bare loop crashed with KeyError: 'getticket': its tools were a dict in the source code. Real work needs tools you didn't write: your issue tracker, your database, a browser. MCP is the standard way to plug those in. Phase 7 built a server and a client by hand. Now the harness needs to be an MCP host, running several servers next to its own tools.

Loading the full lesson…