Model Context Protocol tutorial

Learn how AI apps connect to tools and data with MCP, then design, build and run your own servers safely.

Start the course

Course contents

Foundations

  1. MCP Basics — What the Model Context Protocol is, why it was made, the open spec and its 2026-07-28 version, the standard shape of every setup, and the three things a server can offer: tools, resources and prompts.
  2. MCP Mental Model — The five roles in every MCP setup (user, host, client, server, backend), why each server gets its own client, and the main duties of hosts and servers.
  3. Connected Protocol Workflows — Custom integrations versus MCP, hardcoded versus discovered tools, the steps of one connected request from discovery to answer, context assembly, interoperable servers, and governance basics.

Protocol Architecture

  1. Protocol Architecture — The three layers of MCP (application, message, transport), the three kinds of messages, progress updates, cancellation on each transport, and how server requests became Multi Round-Trip Requests.
  2. JSON-RPC Messages — Every field of MCP requests, responses and notifications, id matching, the core methods, _meta and resultType, error codes, tool errors versus protocol errors, and why servers are now stateless.
  3. Transports — How MCP messages travel: stdio with process lifecycle, line framing and sandboxing; Streamable HTTP with one POST per request, SSE streams and MCP headers; legacy HTTP+SSE; and local versus remote trade-offs.
  4. Discovery and Versioning — server/discover, per-request versions in _meta, the -32022 unsupported version error, server and client capabilities, list changes through subscriptions/listen, the legacy initialize handshake, and clean shutdown.

Core Primitives

  1. Tools — How to define MCP tools well: name, title, description, JSON Schema 2020-12 input schemas, atomic single-verb design, strict types, and annotations for side effects.
  2. Resources — The MCP resource model: URIs, names and MIME types, text and base64 blob contents, resource templates, common kinds of resources, and why reads must be read-only and deterministic.
  3. Prompts — MCP prompts: names, titles, descriptions and arguments; prompts/get messages with embedded resources; argument completion; safe interpolation; and prompts versus server instructions.

Execution and Context

  1. Tool Call Execution — The steps of an MCP tool call: catalog, inspection, selection, approval, tools/call and results, with content blocks, outputSchema and structuredContent, isError, progress and cancellation.
  2. Tool Schema Validation — Validating MCP tool calls on client and server: missing, wrong-type, out-of-range and unknown arguments; schema design; error frames; output validation; and partial results.
  3. Resource URIs — Resource URI parts and schemes, path and query templates, text and base64 contents with MIME types, the resource methods, and freshness with ttlMs, cacheScope and update notices.
  4. Resource Context Assembly — Turning MCP resources into safe, useful context: source tags, freshness, field filtering, truncation, redaction, read-only enforcement and scope validation.

Client Interaction

  1. Multi Round-Trip Requests — How servers ask for input in 2026-07-28: input_required results, inputRequests and inputResponses, the client retry loop, requestState and how to protect it, round limits, and the Tasks extension.
  2. Elicitation — How MCP servers ask users for input: elicitation/create in form and URL mode, client capabilities, flat form schemas, host and server validation, accept, decline and cancel, and keeping secrets out of forms.
  3. Roots, Sampling and Logging — The three client features deprecated in 2026-07-28, why they were deprecated, the 12-month window, and migration paths: tool arguments and scopes, the host's model or your own model API, and stderr with OpenTelemetry.

Server Development

  1. Server Architecture — Designing MCP servers: one domain per server, modular handlers with handler, service and backend layers, atomic tools, least privilege, and explicit approval contracts for risky tools.
  2. Development Environment — The tools for building MCP servers: the TypeScript and Python SDKs, the MCP Inspector, project structure, environment variables and secrets, pinned dependencies, and publishing to the MCP Registry.
  3. Host Configuration — Connecting MCP servers to hosts: stdio and HTTP entries, VS Code mcp.json with inputs and dev mode, Visual Studio config locations, servers vs mcpServers, keeping secrets out, and start-up checks.
  4. Building Servers with SDKs — Building a complete MCP server: McpServer setup, registering tools, resources and prompts, stdio and HTTP transports, the same server in Python, and testing with handler tests, the Inspector and CI.

Enterprise MCP

  1. Multi-Server Architectures — How hosts connect to many MCP servers at once: one client per server, tool name prefixes, routing calls, cross-server policy, rate limits and audit logs.
  2. Remote MCP and Authorization — How remote MCP servers use OAuth 2.1: 401 challenges, protected resource metadata, auth server discovery, client registration, PKCE, the resource parameter, scopes and audience checks.
  3. Performance, Caching and Extensions — Keeping MCP fast: pagination with cursors, deterministic tool order, ttlMs and cacheScope caching, list-changed invalidation, lazy tool groups and extension negotiation.

Production

  1. Security — Defending MCP setups: over-broad tools, prompt injection, tool poisoning, confused deputy, token passthrough, SSRF, state handle hijacking, local server compromise and unsafe URLs.
  2. Reliability and Operations — Running MCP in production: classifying failures, error frames, safe retries, versioning and deprecation, health checks, audit logs, emergency disable, evaluation, cost and an improvement loop.
  3. MCP Reference — A quick-reference page for MCP 2026-07-28: MCP vs alternatives, roles, methods, error codes, HTTP statuses, headers, result fields, auth and security checklists, deprecations and a glossary.

Development Workflows

  1. Host Experience Design — Designing the user experience of MCP hosts: approval policies from tool annotations, approval dialogs, remembered decisions, accessible elicitation forms, progress and cancellation, errors and multi-server display.
  2. Developer Tool Servers — Connecting development workflows through MCP: a design-system server for UI/UX and frontend, a read-only database server for backend work, repository resources, guards inside tools and clear tool descriptions.
  3. Testing and Security Workflows — Testing and security through MCP: test-runner and secret-scanner tools, unit and contract tests for MCP servers, end-to-end checks, and securing dev-tool servers with scopes, guards and least privilege.