Learn Model Context Protocol (MCP)

The open protocol for plugging tools and data into AI apps

25 lessons · 5 hours · 4 levels · covers Model Context Protocol (MCP) spec 2026-07-28, Python SDK 2.x (mcp 2.3)

The Model Context Protocol (MCP) is an open standard that lets AI applications such as Claude, IDEs and agent frameworks connect to external tools and data through one common interface. You write a server once and every MCP-capable app can use it. Learn it to give models safe, reusable access to your systems, or to build apps and agents that can use the large ecosystem of existing servers.

Before you start

Model Context Protocol (MCP) builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics8 lessons · 1 hour in total
2. PracticalUse it productively at work, with the usual idioms16 lessons · 3 hours in total
3. AdvancedThe less common features, performance and trade-offs21 lessons · 4 hours in total
4. ExpertInternals and the edge cases experts know25 lessons · 5 hours in total

The Model Context Protocol (MCP) tree

Model Context Protocol (MCP)What MCP is and why it existsWhat MCP is andwhy it existsHosts, clients and serversHosts, clients andserversTools, resources and promptsTools, resources andpromptsTransports: stdio and Streamable HTTPTransports: stdio andStreamable HTTPAdding servers to Claude, Claude Code, CursorAdding servers toClaude, Claude Co…Your first server with MCPServerYour first server withMCPServerTool arguments and input schemasTool arguments andinput schemasTesting by hand with the MCP InspectorTesting by hand withthe MCP InspectorTool results, structured output and errorsTool results,structured output a…Resources and resource templatesResources andresource templatesPrompts as user commandsPrompts as usercommandsContext, progress and lifespanContext, progressand lifespanServing over Streamable HTTPServing overStreamable HTTPBuilding a client in PythonBuilding a client inPythonAutomated tests with an in-memory clientAutomated tests withan in-memory clientFinding and publishing servers: the RegistryFinding andpublishing servers:…Tool calling (function calling)Tool calling (functioncalling)Defining functionsDefining functionsVirtual environments and pipVirtual environmentsand pipType hints basicsType hints basicsExceptions in depthExceptions in depthContext managers and withContext managersand withTesting with pytest and unittestTesting with pytestand unittest
Essentials and Practical shown (16 of 25 lessons); the full list is below. Click a lesson to read it.

All 25 lessons, in order

What MCP is

  1. What MCP is and why it exists · Essentials · 8 min

    MCP is a shared standard for connecting AI apps to tools and data, so one integration works everywhere.

  2. Hosts, clients and servers · Essentials · 8 min

    The three roles in MCP: the AI app (host), its connector (client) and the program offering tools (server).

  3. Tools, resources and prompts · Essentials · 10 min

    The three things a server can offer, told apart by who decides to use them: the model, the app or the user.

  4. Transports: stdio and Streamable HTTP · Essentials · 9 min

    How MCP messages travel: through a local program's input/output (stdio) or over HTTP to a remote server.

Using MCP servers

  1. Adding servers to Claude, Claude Code, Cursor · Essentials · 10 min

    Connect existing local and remote MCP servers to popular hosts with a config file or one CLI command.

  2. Finding and publishing servers: the Registry · Practical · 9 min

    The official MCP Registry lists public servers as metadata pointing at packages on npm, PyPI, Docker or a URL.

Building servers in Python

  1. Your first server with MCPServer · Essentials · 12 min

    Build a working MCP server in a few lines with the official Python SDK's MCPServer class and decorators.

  2. Tool arguments and input schemas · Essentials · 12 min

    Type hints become a JSON Schema the model fills in; defaults, Field and Pydantic models shape and validate arguments.

  3. Testing by hand with the MCP Inspector · Essentials · 8 min

    Run your server in the MCP Inspector to list and call its tools, read resources and watch the raw messages.

  4. Tool results, structured output and errors · Practical · 12 min

    What a tool call returns: content for the model, structured_content for code, and is_error for failures.

  5. Resources and resource templates · Practical · 10 min

    Expose read-only data at URIs, with templates for parameterized addresses and MIME types for non-text data.

  6. Prompts as user commands · Practical · 8 min

    Publish reusable message templates with arguments that users pick by name, such as slash commands.

  7. Context, progress and lifespan · Practical · 12 min

    Use the Context object for request info and progress updates, and a lifespan to share resources like DB pools.

Protocol, HTTP and authorization

  1. Serving over Streamable HTTP · Practical · 12 min

    Run the same server on a port with mcp.run(transport='streamable-http'), or mount it in an existing web app.

  2. Messages, discovery and versioning · Advanced · 14 min

    How MCP looks on the wire: JSON-RPC requests, per-request version and capabilities in _meta, and server/discover.

  3. Authorization with OAuth for remote servers · Advanced · 16 min

    Remote MCP servers act as OAuth resource servers: clients discover the auth server, get a scoped token, and send it on every request.

  4. Deploying and scaling remote servers · Expert · 15 min

    Run many replicas behind a load balancer: stateless requests, sealed request_state, shared subscriptions, caching hints.

Clients and talking to the user

  1. Building a client in Python · Practical · 12 min

    Use the SDK's Client to connect by URL, by launching a subprocess, or in memory, then list and call tools.

  2. Automated tests with an in-memory client · Practical · 10 min

    Test servers with pytest by connecting Client(mcp) in memory and asserting on real protocol results.

  3. Wiring MCP tools into an agent loop · Advanced · 15 min

    Turn MCP tool listings into model tool definitions, run the model's tool calls through call_tool, and loop.

  4. Asking the user: elicitation · Advanced · 14 min

    Let a tool pause to ask the user for input or confirmation, via form or URL mode, using Resolve and Elicit.

  5. Sampling, roots and logging (deprecated) · Advanced · 10 min

    The older client features let servers borrow the host's model, see allowed folders and send logs; know them, avoid them in new code.

Security and design

  1. Tool poisoning and prompt injection · Expert · 15 min

    Tool descriptions and tool outputs are text the model obeys; attackers use both. Defend with isolation, review and least privilege.

  2. Confused deputy, token passthrough, SSRF · Expert · 15 min

    Server-side attacks on remote MCP deployments and the spec's required mitigations.

  3. Designing servers models use well · Expert · 14 min

    Design tools around tasks, keep outputs small and clear, and reduce the context cost of large tool catalogs.