Model Context Protocol (MCP) Coverage in Phase 13: A Complete Technical Curriculum

Phase 13 of the AI Engineering from Scratch curriculum delivers a comprehensive, end-to-end treatment of the Model Context Protocol (MCP), spanning 18 dedicated lessons that cover everything from core primitives to production security and capstone implementations.

The rohitg00/ai-engineering-from-scratch repository structures Phase 13 (Tools and Protocols) as the definitive deep-dive into MCP implementation. This phase transforms learners from protocol novices into architects capable of building secure, scalable MCP ecosystems. The curriculum follows a progressive learning path through four technical pillars: fundamentals, transport mechanics, security governance, and advanced application patterns.

Core MCP Fundamentals (Lessons 06–08)

The foundational lessons establish complete fluency with the MCP specification and basic implementation patterns.

Lesson 06: MCP Fundamentals (phases/13-tools-and-protocols/06-mcp-fundamentals/docs/en.md) introduces the 2025-11-25 specification, detailing the six primitives, three-phase lifecycle, and JSON-RPC 2.0 wire format. Students learn how servers advertise tool registries and how clients discover available capabilities.

Lesson 07: Building an MCP Server (phases/13-tools-and-protocols/07-building-an-mcp-server/docs/en.md) provides hands-on scaffolding for compliant server implementations. The lesson covers SDK selection (Python and TypeScript), tool registration APIs, and response serialization.

Lesson 08: Building an MCP Client (phases/13-tools-and-protocols/08-building-an-mcp-client/docs/en.md) teaches client-side discovery and invocation patterns. Students implement catalog parsing, tool selection logic, and error handling for JSON-RPC responses.

Transport and Runtime Architecture (Lessons 09–11)

These lessons address the networking layer and runtime behaviors essential for production deployments.

Lesson 09: MCP Transports (phases/13-tools-and-protocols/09-mcp-transports/docs/en.md) compares HTTP streaming, WebSocket, and gRPC transport options, including the "StreamableHTTP" revision used in modern production environments. The curriculum demonstrates transport-agnostic design patterns that allow runtime migration without client code changes.

Lesson 10: MCP Resources and Prompts (phases/13-tools-and-protocols/10-mcp-resources-and-prompts/docs/en.md) covers the separation of concerns between tools, resources, and prompts. Students learn to structure context windows and manage prompt templates as first-class MCP primitives.

Lesson 11: MCP Sampling (phases/13-tools-and-protocols/11-mcp-sampling/docs/en.md) explores advanced inference strategies, including temperature handling, top-p sampling, and multi-call orchestration within the protocol constraints.

Security, Authentication, and Governance (Lessons 15–18)

Phase 13 dedicates significant coverage to securing MCP implementations against production threats.

Lesson 15: MCP Security – Tool Poisoning (phases/13-tools-and-protocols/15-mcp-security-tool-poisoning/docs/en.md) presents the Unit 42 attack-vector taxonomy and mitigation strategies. Students analyze real vulnerability reports and implement input validation patterns.

Lesson 16: MCP Security – OAuth 2.1 (phases/13-tools-and-protocols/16-mcp-security-oauth-2-1/docs/en.md) covers modern authentication flows, token-based policy gating, and scope management for tool execution rights.

Lesson 17: MCP Gateways and Registries (phases/13-tools-and-protocols/17-mcp-gateways-and-registries/docs/en.md) teaches enterprise-scale discovery patterns, including registry design for vetting and cataloging organizational MCP servers.

Lesson 18: MCP Auth Production (phases/13-tools-and-protocols/18-mcp-auth-production/docs/en.md) provides deploy-time hardening guides for stateless container environments, featuring AWS ECS reference architectures and secret management strategies.

Advanced Patterns and Capstone Projects (Lessons 12–14, 23)

The advanced curriculum explores complex architectural patterns and culminates in a comprehensive capstone.

Lesson 12: MCP Roots and Elicitation (phases/13-tools-and-protocols/12-mcp-roots-and-elicitation/docs/en.md) covers designing root-level elicitation forms for complex tool contracts and multi-step reasoning workflows.

Lesson 13: MCP Async Tasks (phases/13-tools-and-protocols/13-mcp-async-tasks/docs/en.md) implements persistent task stores that survive model turn-taking, enabling long-running operations within stateless inference contexts.

Lesson 14: MCP Apps (phases/13-tools-and-protocols/14-mcp-apps/docs/en.md) demonstrates bundling multiple MCP-exposed services into single deployable "app" packages with unified manifest definitions.

Lesson 23: Capstone Tool Ecosystem (phases/13-tools-and-protocols/23-capstone-tool-ecosystem/docs/en.md) requires students to assemble a complete production ecosystem: a secured registry, multiple authenticated servers, client discovery mechanisms, and observability instrumentation.

Production-Grade Code Examples

Phase 13 ships executable artifacts for every lesson. The following snippets illustrate the progressive learning path from basic server implementation to hardened production security.

Server-Side Tool Registration

The Python SDK implementation in phases/13-tools-and-protocols/07-building-an-mcp-server/code/python/server.py demonstrates tool registration and the StreamableHTTP endpoint:

from mcp import Server, Tool

def read_file(path: str) -> str:
    with open(path, "r") as f:
        return f.read()

# Register the tool in the server's registry

server = Server()
server.register(Tool(
    name="read_file",
    description="Read a text file from the filesystem",
    parameters={"type": "object",
                "properties": {"path": {"type": "string"}},
                "required": ["path"]},
    function=read_file,
))

server.serve()          # Starts a StreamableHTTP endpoint

Client Discovery and Invocation

The TypeScript client implementation in phases/13-tools-and-protocols/08-building-an-mcp-client/code/ts/src/index.ts shows catalog discovery and tool execution:

import { MCPClient } from "@modelcontextprotocol/client";

async function main() {
  const client = new MCPClient("https://my-mcp-server.example.com");
  // Discover the catalogue
  const catalog = await client.listTools();

  // Call the `read_file` tool
  const result = await client.call("read_file", { path: "README.md" });
  console.log(result);
}

main();

Transport Migration Patterns

The migration example in phases/13-tools-and-protocols/09-mcp-transports/code/python/migrate.py illustrates transport abstraction:

from mcp import MCPClient, Transport

# Original HTTP client

http_client = MCPClient("https://mcp.example.com", transport=Transport.HTTP)

# Switch to WebSocket without changing any calls

ws_client = MCPClient("wss://mcp.example.com/ws", transport=Transport.WebSocket)

# Both clients expose the same `call` API

response = ws_client.call("list_tools", {})

OAuth 2.1 Security Implementation

The production security example in phases/13-tools-and-protocols/16-mcp-security-oauth-2-1/code/ts/src/server.ts implements scope-based access control:

import { Server, OAuth2Guard } from "@modelcontextprotocol/server";

const server = new Server();
server.use(new OAuth2Guard({
  issuer: "https://auth.example.com",
  requiredScopes: ["tools.read", "tools.exec"],
}));

server.register({
  name: "search",
  // …tool definition…
});

server.listen(8080);

Summary

Phase 13 provides near-complete coverage of the Model Context Protocol specification and implementation:

  • Fundamentals: Complete treatment of the 2025-11-25 specification, six primitives, and JSON-RPC 2.0 wire format through lessons 06–08.
  • Transport Layer: Comprehensive comparison of HTTP, WebSocket, and gRPC transports with migration patterns in lessons 09–11.
  • Security: Production-grade authentication using OAuth 2.1, threat mitigation for tool poisoning, and registry governance in lessons 15–18.
  • Advanced Patterns: Async task persistence, root elicitation, and bundled app architectures in lessons 12–14.
  • Capstone: End-to-end ecosystem assembly requiring registry deployment, multi-server orchestration, and client integration in lesson 23.

Frequently Asked Questions

What specific MCP primitives are taught in the fundamentals lessons?

The curriculum covers all six MCP primitives defined in the 2025-11-25 specification: tools, resources, prompts, roots, sampling, and completion. Lessons 06–08 specifically focus on tool registration, resource discovery, and prompt handling, with subsequent lessons expanding into sampling strategies and root-level elicitation forms.

How does Phase 13 address MCP security vulnerabilities?

Phase 13 dedicates four lessons (15–18) exclusively to security. Lesson 15 analyzes the Unit 42 tool poisoning attack vector and implements input validation mitigations. Lesson 16 integrates OAuth 2.1 with scope-based access control. Lesson 17 covers registry vetting patterns, while Lesson 18 provides container hardening strategies for AWS ECS deployments.

Which transport protocols are supported in the curriculum's MCP implementations?

The curriculum teaches three transport options: HTTP streaming (including the StreamableHTTP revision), WebSocket, and gRPC. Lesson 09 specifically demonstrates transport-agnostic design patterns that allow runtime migration between these protocols without requiring changes to client invocation code.

What deliverables are required for the Phase 13 capstone project?

The capstone (Lesson 23) requires students to deploy a complete MCP ecosystem including: a secured registry for tool discovery, multiple authenticated MCP servers with OAuth 2.1 protection, a client implementation capable of catalog browsing and tool execution, and observability instrumentation. This end-to-end project validates production readiness across all four curriculum pillars.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →