Deep-Dive 22 · 50 min · Senior

MCP: Building Production Tool Servers

The wire protocol that turns hardcoded tool registries into discoverable, versioned, independently-deployable services. The platform turn.

3
Primitives
2
Transports
4
Lifecycle phases
9
Artifacts

A tool is a function the model can call. A tool server is a process that exposes tools, resources, and prompts over a wire protocol — discoverable, versioned, independently deployable. MCP is that wire protocol. This deep-dive is about building production tool servers: the lifecycle, the capability negotiation, the schema validation, the registry, and the failure modes that turn a clever integration into a production outage.

Pi's 4 tools are hand-coded. An MCP server externalizes tool definitions into a discoverable, versioned, independently-deployable service. This is the difference between a personal harness and a platform.

Key Claims

The platform turn. Pi's four tools are compiled-in function references. Adding one means editing source, shipping a build, restarting. MCP externalizes tools into services. A vendor ships a server; the agent discovers it at runtime. This is the structural difference between a personal harness and a platform.

Three primitives, three trust boundaries. Tools (model-initiated, untrusted input, schema-validated). Resources (user/client-initiated, semi-trusted). Prompts (user-initiated, server-authored, trusted). Confusing them — exposing as a tool what should be a resource — is a security bug.

Capability negotiation is the contract. The initialize handshake exchanges what both sides support. The session may only use the intersection. A client built once works against every server — including future and third-party ones — using whatever subset both offer.

JSON Schema is the validation boundary, not documentation. additionalProperties: false is a security control — it prevents a steered model from injecting unexpected fields. The server re-validates on every call. Never trust the model or the client to validate.

Three error classes, three recovery paths. Unknown tool, validation failure, execution failure. Each returns a distinguishable isError payload. The model's response differs per class — conflating them produces a confused loop.

After This Module

01State the MCP thesis and explain why externalizing tools is the difference between a personal harness and a platform.
02Describe the three primitives, two transports, and the JSON-RPC 2.0 envelope that carries them.
03Walk the full server lifecycle: initialization, capability negotiation, message loop, graceful shutdown.
04Write a JSON Schema for tool input and explain why additionalProperties: false is a security control.
05Implement a production MCP server in TypeScript with validation, error handling, health logging, and graceful shutdown.
06Explain the registry/discovery pattern and how capability negotiation enables version-drift tolerance.
07Diagnose the four production failure modes: stdout corruption, schema drift, subscription flood, no graceful shutdown.

Artifacts

01
Full deep-dive: thesis, three primitives, lifecycle, capability negotiation, validation boundary, TypeScript server, registry, failure modes.
MD
02
6 Mermaid diagrams: externalization, three trust boundaries, lifecycle, capability negotiation, validation boundary, production failure modes.
MD
03
10-slide reveal.js deck, dark theme, design-system teal.
HTML
04
Verbatim transcript with [SLIDE N] cues, ~2,700 words across 10 slides.
MD
05
22 cards. Mix of recall, application, analysis.
TSV
06
15 questions. 3 recall / 6 application / 6 analysis. 70% pass.
JSON
07
Build a TypeScript MCP server: two tools, schema validation, three-class error model, graceful shutdown, test harness.
MD
08
Module Web Page
This page.
HTML
--
Metadata, navigation, artifact index.
MD/JSON

Key Terms

MCP JSON-RPC 2.0 stdio transport HTTP+SSE transport capability negotiation additionalProperties: false three primitives registry pattern version drift stdout corruption subscription flood graceful shutdown