Phase 13 · Tools & Protocols

Learn Tool Calling and MCP: 45 Free Lessons

The interfaces between AI and the real world.

  • 45 lessons
  • 38 build
  • 7 learn
  • ~76 hours
  • Python, TypeScript, Go, Rust

Cheat sheets: A2A and Agent Communication Protocols, Agent Skills: Discovery, Invocation, Routing, OpenTelemetry GenAI and Agent Observability, LLM Routing and AI Gateways Compared, MCP Clients and Transports, MCP Gateways, Registries and Conformance, MCP Security and Authorization, Building an MCP Server, MCP Tasks, Elicitation and Apps, Model Context Protocol (MCP), Binary Analysis Tools from Scratch, Reverse Engineering with rea, Skill Permissions, Evals and Supply Chain, Structured Outputs and Constrained Decoding, Tool Calling and Structured Outputs

This phase moves from function calls and tool schemas into interoperable protocols, Agent Skills, security, and production governance. Numeric order is useful for browsing.

Start Phase 13

First full-phase lesson The Tool Interface — Why Agents Need Structured I/O

Run this command from the repository root:

python3 phases/13-tools-and-protocols/01-the-tool-interface/code/main.py

Keep the command, exit code, describe-decide-execute-observe trace, rejected input evidence, and one sentence explaining the turn limit.

All 45 lessons in Phase 13

  1. The Tool Interface — Why Agents Need Structured I/O

    A language model produces tokens. A program takes actions. The gap between those two is the tool interface: a contract that lets the model request an action and the host execute it.

    Learn · Python, TypeScript · ~45 min

  2. Function Calling Deep Dive — OpenAI, Anthropic, Gemini

    The three frontier providers converged on the same tool-call loop in 2024 and then diverged on everything else. OpenAI uses tools and toolcalls. Anthropic uses tooluse and toolresult blocks.

    Build · Python, TypeScript · ~75 min

  3. Parallel Tool Calls and Streaming with Tools

    Three independent weather lookups serialized is three round trips. Run them in parallel and total time collapses to the slowest single call.

    Build · Python, TypeScript, Go · ~75 min

  4. Structured Output — JSON Schema, Pydantic, Zod, Constrained Decoding

    "Ask the model nicely to return JSON" fails 5 to 15 percent of the time, even on frontier models. Structured outputs close that gap with constrained decoding: the model is literally prevented from…

    Build · Python, TypeScript · ~75 min

  5. Tool Schema Design — Naming, Descriptions, Parameter Constraints

    A correct tool fails silently when the model cannot tell when to use it. Naming, descriptions, and parameter shapes drive 10 to 20 percentage-point swings in tool-selection accuracy on benchmarks…

    Learn · Python, TypeScript · ~45 min

  6. MCP Fundamentals: Stateless Requests and JSON-RPC

    Modern MCP has no handshake and no protocol session. Each request must carry enough metadata to be understood, authorized, routed, and retried on its own.

    Learn · Python, TypeScript · ~55 min

  7. Building an MCP Server: Stateless Python and TypeScript

    A modern MCP server does not remember a handshake. It validates the metadata on every request, runs one handler, and returns one typed result. Implement mandatory server/discover for MCP 2026-07-28.

    Build · Python, TypeScript, Go · ~85 min

  8. Building an MCP Client: Discovery, Routing, and Dual-Era Fallback

    A modern MCP client repeats its contract on every request. Its hardest compatibility decision is knowing when an old server is truly old and when a modern server is reporting a correctable error.

    Build · Python, TypeScript · ~85 min

  9. MCP Transports: stdio and Stateless Streamable HTTP

    Transport carries MCP messages. It does not supply missing protocol state. In 2026-07-28, local stdio and remote Streamable HTTP both carry self-describing requests.

    Learn · Python, TypeScript, Go · ~65 min

  10. MCP Resources and Prompts: Addressable Context for Stateless Servers

    Tools perform operations. Resources expose addressable content. Prompts package user-selected message templates. A good MCP server keeps those contracts separate and predictable.

    Build · Python, TypeScript · ~60 min

  11. MCP Model Input: Sampling Migration and Stateless MRTR

    MCP 2026-07-28 deprecates Sampling for new designs and removes the server-to-client request channel. If an existing workflow still needs the client's model, the server returns an inputrequired…

    Build · Python, TypeScript · ~75 min

  12. Explicit Scope and Stateless Elicitation

    Roots are deprecated in MCP 2026-07-28 and were never a security sandbox. Put scope in visible tool arguments or resource URIs, authorize it on the server, and use MRTR when a tool genuinely needs…

    Build · Python, TypeScript · ~60 min

  13. MCP Tasks Extension: Durable Work on a Stateless Core

    Stateless MCP does not mean every operation must finish in one request. The official Tasks extension gives long-running work an explicit durable handle.

    Build · Python, TypeScript · ~90 min

  14. MCP Apps on the Stateless Protocol

    An interactive result is still an MCP tool and resource exchange. The 2026-07-28 core makes that exchange self-contained, while the Apps extension adds the sandboxed browser surface.

    Build · Python, TypeScript · ~75 min

  15. MCP Security: Poisoned Metadata, Routing, and MRTR State

    Stateless does not mean trustless. It means every request exposes the evidence a server and gateway need to validate the call independently.

    Learn · Python, TypeScript · ~60 min

  16. MCP Authorization: CIMD, Issuer Binding, PKCE, and Step-Up

    A remote MCP request is stateless, but its authorization is not anonymous. Bind every credential to the issuer that created it and every token to the resource that receives it.

    Build · Python, TypeScript, Go · ~90 min

  17. Stateless MCP Gateways and Registry Admission

    A gateway should make every route explicit. The 2026-07-28 protocol gives it method, name, version, capability, identity, cache, and trace boundaries without a transport session.

    Learn · Python, TypeScript, Go · ~75 min

  18. MCP Auth in Production: Issuer-Bound Enrollment and Tokens

    Lesson 16 built the OAuth 2.1 state machine. This lesson hardens its production boundaries for MCP 2026-07-28: Client ID Metadata Documents first, deprecated dynamic registration only for…

    Build · Python, TypeScript, Go · ~90 min

  19. A2A — Agent-to-Agent Protocol

    MCP is agent-to-tool. A2A (Agent2Agent) is agent-to-agent — an open protocol for letting opaque agents built on different frameworks collaborate.

    Build · Python, TypeScript, Go · ~75 min

  20. OpenTelemetry GenAI — Tracing Tool Calls End-to-End

    An agent calls five tools, three MCP servers, and two sub-agents. You need one trace across all of it. The OpenTelemetry GenAI semantic conventions (stable attributes in v1.37 and up) are the 2026…

    Build · Python, TypeScript · ~75 min

  21. LLM Routing Layer — LiteLLM, OpenRouter, Portkey

    Provider lock-in is expensive. Different tool-calling workloads suit different models. Routing gateways give one API surface, retries, failover, cost tracking, and guardrails.

    Learn · Python, TypeScript, Go · ~45 min

  22. Agent Skills: Portable Contract and Runtime Boundary

    A skill is not a long prompt with a better filename. It is a discoverable package of instructions, resources, and executable helpers that enters an agent's context through a runtime contract.

    Build · Python, TypeScript · ~90 min

  23. Capstone: Stateless Tool Ecosystem

    A production agent system is a set of boundaries, not a pile of features. This capstone separates a readable in-process simulation from the protocol clients, authorization server, sandbox, and…

    Build · Python, TypeScript · ~120 min

  24. Skill Discovery and Progressive Disclosure

    A skill becomes useful before its body is loaded. Its name and description earn a place in the catalog; its deeper files earn context only when the task reaches them.

    Build · Python, TypeScript · ~105 min

  25. Skill Invocation and Routing

    Invocation is an authority decision followed by a relevance decision. A good description helps the model choose; a good policy decides whether that choice is allowed.

    Build · Python, TypeScript · ~105 min

  26. Skill Permissions, Sandboxes, and Trust

    A skill can suggest an action. Only the host can authorize it, only an isolation boundary can contain it, and only verification can tell you whether it worked.

    Build · Python, TypeScript · ~120 min

  27. Skill Evals, Packaging, and Portability

    A skill is finished when its package survives linting, routes on the right requests, improves a measured task, stays inside policy, and degrades honestly on another host.

    Build · Python, TypeScript · ~150 min

  28. MCP Tool Contracts and Content

    A tool is safe to automate only when discovery, arguments, results, pagination, and transport metadata agree on one contract. Define tool inputs and outputs with JSON Schema 2020-12.

    Build · Python, TypeScript · ~120 min

  29. MCP Reliability, Cancellation, and Flow Control

    A request ID correlates a message. It does not make a side effect safe, stop a worker, or protect a stream from a slow consumer.

    Build · Python, TypeScript · ~120 min

  30. MCP Registry Supply Chain: Admission, Drift, and Rollback

    A registry entry tells you what a publisher declared. Production admission proves what you fetched, what you observed, what you approved, and what you can safely restore.

    Build · Python, TypeScript · ~90 min

  31. MCP Conformance Engineering: Versioning, Evidence, and Operations

    A server is not conformant because its happy path worked through one SDK. Conformance lives at the wire, at version boundaries, through intermediaries, and during rollback.

    Build · Python, TypeScript · ~100 min

  32. Program Anatomy: An ELF Reader From Scratch

    A compiled program is a set of tables that point at each other. A reader you wrote gives output you can check byte by byte.

    Build · Python, TypeScript, Rust · ~120 min

  33. Disassembly and Control Flow: From Bytes to a Graph You Can Check

    A disassembly listing is a claim about which bytes are instructions, and this lesson builds the decoder and graph that check the claim.

    Build · Python, TypeScript, Rust · ~150 min

  34. Lifting to Pseudocode: IR, SSA, and Structuring From Scratch

    Decompiler output is a claim with a hidden derivation. When you build the derivation yourself, every line of that output becomes a thing you can check.

    Build · Python, TypeScript · ~150 min

  35. Evidence, Confidence, and Unknowns in Binary Analysis

    A finding about a compiled program is a record with a hash, a confidence, an authority, and a list of what it cannot show.

    Build · Python, TypeScript · ~105 min

  36. Rebuild and Prove Equal: Differential Tests, Byte Comparison, and the Evidence Loop

    Passing your tests proves agreement on your tests, so equality needs a grid that reaches every edge and bytes that match after relocation masking.

    Build · Python, TypeScript · ~110 min

  37. The Reverse Engineering Landscape: History, Tool Families, and How a Decompiler Is Built

    Five tools read the same object and give four addresses, three block counts, and two answers for one switch, and this lesson builds the harness that shows which is which.

    Build · Python, TypeScript · ~150 min

  38. Calling Conventions and Stack Frames: System V, Windows x64, and AArch64

    A disassembly shows which registers a function reads. Only the ABI says what those registers mean, and the ABI is chosen by the object header, so this lesson reads the header first and then checks…

    Build · Python, TypeScript · ~140 min

  39. Compiler Idioms: What Optimization Does to Your Code and How to Read It Back

    An optimizing compiler replaces source constructs with cheaper instruction shapes. Each shape has a derivation, and this lesson builds the recognizer that runs the derivation backwards and checks it…

    Build · Python, TypeScript · ~150 min

  40. Linking, Loading, and Stripped Binaries: PLT, GOT, Imports, Fixups, and Function Identification

    A linked program calls functions it does not contain. This lesson reads the tables the link editor wrote for those calls in three formats, follows one call to the slot the loader fills, and finds…

    Build · Python, TypeScript, Rust · ~160 min

  41. Recovering Data and Types: Structs, Arrays, C++ Objects, and DWARF

    A decompiler prints a->balance when it has a type table and (int )(param1 + 4) when it does not. This lesson builds the table from the accesses, reads the real one from DWARF 5, and shows where the…

    Build · Python, TypeScript · ~140 min

  42. Dynamic Analysis of Your Own Program: Debuggers, Traces, and Confirming Static Claims

    A breakpoint hit is an observation about one run of one build. This lesson builds the harness that turns those observations into confirmed, refuted, and not-observed verdicts on the claims the…

    Build · Python, TypeScript · ~130 min

  43. Beyond Native Code: Python, JVM, .NET, and WebAssembly Bytecode

    A bytecode file is a program plus the compiler's notes about it, and this lesson builds the readers that show which notes each container keeps.

    Build · Python, TypeScript · ~150 min

  44. Binary Diffing and Symbolic Execution: Matching Functions and Solving for Inputs

    A match between two functions is a claim made by one signature with one quality, and a solved input is one model of one path condition; this lesson builds both and checks them against radiff2,…

    Build · Python, TypeScript · ~150 min

  45. AI-Assisted Reverse Engineering: LLM Decompilers, Analysis Agents, and Ground Truth

    A model's reconstruction is a claim with a report attached, and this lesson builds the harness that scores both against bytes, runs, and DWARF you own.

    Build · Python, TypeScript · ~140 min

Glossary terms in this phase

  • AgentA software system that lets a model select actions toward a goal, observe tool or environment results, and continue under an orchestration…
  • Agent SkillA discoverable directory of procedural instructions whose entry point is `SKILL.md`, with optional references, scripts, and assets that a…
  • Circuit BreakerA reliability control that temporarily stops calls to a dependency after failures cross a threshold, then probes whether the dependency…
  • Coding AgentAn agent specialized for software work that can inspect a repository, edit files, run development tools, and use their outputs to advance…
  • DecoderA component that maps a representation into an output. In an encoder-decoder transformer, the decoder uses masked self-attention and…
  • Evaluation (Eval)A defined process for measuring model or system behavior on representative tasks using explicit success criteria, data, scorers, and…
  • FeatureAn individual measurable property of the data. In classical ML, you engineer features by hand.
  • Function CallingA provider or application interface through which a model emits a structured request naming a tool and its arguments.
  • GuardrailsSystem controls that constrain inputs, tool use, outputs, permissions, and escalation.
  • LLM (Large Language Model)A language model with enough capacity and broad training to perform many language tasks through prompting or adaptation.
  • MCP (Model Context Protocol)An open JSON-RPC protocol for a host to connect to servers that expose tools, resources, prompts, and extensions through defined request,…
  • Multi Round-Trip Request (MRTR)An MCP request pattern in which an operation returns `resultType: input_required` with one or more `inputRequests`, then the client…
  • OrchestrationThe control logic that sequences, branches, delegates, retries, pauses, resumes, and terminates work across model and tool steps.
  • ParameterA value learned during training, commonly a weight, bias, embedding element, or normalization parameter.
  • Progressive DisclosureSupplying a person or model with the minimum useful context first, then revealing deeper detail when the task or evidence requires it.
  • Rate LimitA policy that caps requests, tokens, concurrent work, or another resource within a defined time or capacity window.
  • Repository InstructionsVersion-controlled guidance that tells coding agents how a repository is organized, which commands and conventions apply, what boundaries…
  • RollbackRestoring a previously known deployment or configuration when the current release violates operational, quality, or safety criteria.
  • SandboxAn isolated execution environment that restricts an agent's access to files, processes, network destinations, credentials, and host…
  • Skill BundleThe complete installable skill directory, including `SKILL.md` and every reference, script, asset, fixture, or companion file required by…
  • Skill CatalogThe compact model-visible inventory of eligible skills, usually containing routing metadata such as name, description, and an internal…
  • Skill DiscoveryA runtime pipeline that searches configured roots, identifies candidate skill directories, validates their package contract, attaches…
  • Skill InvocationThe runtime-mediated process in which an eligible human, model, application, or other skill selects a skill and causes its instructions to…
  • Stateless MCPThe MCP 2026-07-28 request model in which every request carries the protocol version and client capabilities in `params._meta`, while…
  • StreamingDelivering incremental response events before the complete result is ready. A stream may contain token text, structured deltas, tool-call…
  • Structured OutputModel output constrained or validated against a machine-readable schema so application code can consume fields without parsing free-form…
  • TokenAn integer identifier produced by a model-specific tokenizer from text, bytes, images, audio, or another input representation.
  • Tool ContractThe complete agreement for a tool boundary: purpose, typed inputs, outputs, validation, permissions, side effects, errors, timeouts,…
  • TraceA correlated record of one request or task across model calls, retrieval, tools, state transitions, retries, approvals, and evaluations.
  • Trust BoundaryAn interface where data, instructions, identity, or authority crosses between components or principals that operate under different trust…

Frequently asked questions

How many lessons are in Phase 13: Tools & Protocols?

Phase 13 has 45 lessons: 38 Build lessons and 7 Learn lessons. The lesson code uses Python, TypeScript, Go and Rust.

What should I know before I start Phase 13?

The phase guide gives these prerequisites: Phase 11 LLM completion APIs. In the course roadmap, this phase builds on Phase 11: LLM Engineering.

Is Phase 13 free?

Yes. All 45 lessons are free to read on this site, and you do not need an account. The lesson code is open source under the MIT license.

How long does Phase 13 take?

The time estimates of all 45 lessons add up to about 76 hours.

What comes after Phase 13?

Phase 14: Agent Engineering builds on this phase.