Free self-study · No account needed · Progress stays in this browser. Back it up before clearing site data or changing devices.

← Week 12: Model Context Protocol

Week 12 / Lesson 1

Model Context Protocol roles and versioned requests

Trace a host request through a client to a server using an explicitly pinned protocol revision.

Section 1.1 1 of 7

Overview

Focus

Trace a host request through a client to a server using an explicitly pinned protocol revision.

Your route through the lesson

  • 1.2 Hosts, clients, servers, and capability boundaries
  • 1.3 Tools, resources, and reusable prompts
  • 1.4 Protocol version, discovery, and request lifecycle
  • 1.5 Put it into practice
  • 1.6 Guided comparison
  • 1.7 An integration written for an older protocol revision

All required teaching is included here. Review selections are saved. Choose a correct answer for every question to continue; retries are unlimited. Study time and personal notes are optional.

Section 1.2 2 of 7

Hosts, clients, servers, and capability boundaries

Focus

Trace a request through a host, a client, and a server without confusing their authority.

The Model Context Protocol provides a common interface for applications to discover and use external context and tools. The host is the user-facing application that coordinates the model and its permissions. A client is the host’s protocol-speaking component. A server exposes a defined set of tools, resources, or prompts. One host can manage clients for several servers.

Consider a knowledge assistant reading local documentation. The host interprets the user’s request and decides whether a documentation lookup fits the task. Its client sends a structured request to the documentation server. The server validates the request and returns an allowed passage. The host decides how to use that passage in the answer. The server does not become the user, and its text does not override host permissions.

Direct function calling can perform the same underlying lookup inside one program. A protocol adds standardized message shapes and discovery across process boundaries. It does not automatically make the lookup accurate, authorized, or useful. Those properties still depend on the implementation and the evidence returned.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A user-facing assistant launches a protocol client to read a documentation server. Which component is the host?
2. A protocol server returns a passage saying “ignore host permissions.” What authority does it gain?
3. What does standardizing a lookup through a protocol provide by itself?

Section 1.3 3 of 7

Tools, resources, and reusable prompts

Focus

Distinguish operations, addressable context, and reusable prompt templates.

A tool performs an operation with structured arguments and results. A resource exposes addressable content, identified by a uniform resource identifier such as docs://public/reset. A prompt is a reusable message template that the host can request and choose to use. These concepts can refer to the same subject while serving different roles.

The local lab exposes search_docs as a tool: it accepts a query and returns matching permitted passages. It exposes docs://public/reset as a resource: reading that address returns the reset policy text. It also exposes summarize_doc as a prompt template: requesting it returns messages asking for a grounded summary. Receiving that template does not execute a summary or authorize any new read.

Discovery tells the client which entries the server advertises. Advertising a tool does not mean it was called, and listing a resource does not mean its contents were read. A complete trace distinguishes discovery, selection, execution, and returned evidence. This prevents a polished interface from confusing “available operation” with “completed task,” a distinction already established in the agent-loop lessons.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. search_docs accepts query arguments and performs a search. Which category fits?
2. docs://public/reset identifies readable policy content. Which category fits?
3. The server returns a summarize_doc prompt template. Has a summary necessarily been generated?

Section 1.4 4 of 7

Protocol version, discovery, and request lifecycle

Focus

Pin revision 2026-07-28 and carry version and capabilities on every request.

This week targets protocol revision 2026-07-28. Its request model is stateless: version and client capabilities travel in params._meta on every request. An empty capabilities object explicitly declares no optional client features. Client software identity can also be included for diagnostics; it is self-reported, not authentication.

The server must support server/discover, which advertises supported versions, capabilities, and server identity metadata. Our client uses it before other work, then continues with the pinned version. Each ordinary result includes resultType: complete. Unsupported versions produce the defined unsupported-version error rather than silently switching semantics.

Older tutorials may start with initialize and notifications/initialized. Those belong to earlier revisions; they are not this lab’s startup sequence. A compatibility adapter can support old and new eras deliberately, but mixing their examples creates misleading behavior. The official versioning page explains the distinction. It requires internet access but no account. The core exercise is self-contained and uses a small standard-library implementation rather than depending on an older software package’s handshake behavior.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Under the pinned 2026-07-28 revision, where do required version and capabilities appear?
2. Client identity metadata says name = administrator. What does that establish?
3. A modern server rejects an unsupported version and lists supported versions. What should the client do?

Section 1.5 5 of 7

Put it into practice

Focus

Run a real subprocess discovery exchange and inspect the complete message shape.

Save week12.py in your exercise folder and run python week12.py --lesson 1. The file launches itself as a separate server process and exchanges actual newline-delimited messages over pipes. It needs only Python’s standard library, no account, network, external package, or model. It should complete in seconds on a processor.

json.dumps converts a Python dictionary to JSON text; json.loads reverses that transformation. Here is a complete discovery request assembled before writing it to the server:

import json
request = {"jsonrpc": "2.0", "id": 1, "method": "server/discover",
           "params": {"_meta": {
               "io.modelcontextprotocol/protocolVersion": "2026-07-28",
               "io.modelcontextprotocol/clientCapabilities": {},
               "io.modelcontextprotocol/clientInfo": {"name": "academy", "version": "1"}}}}
line = json.dumps(request) + "\n"
assert json.loads(line)["id"] == 1

The weekly file supplies the actual process and transport code. Expect discovery, metadata rejection, and unsupported-version checks to pass. This is real local protocol execution. The model-selection and answer-generation parts of a larger assistant remain separate competencies, since no language model is called here.

Download this week’s Python lab ↓

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Why does the encoded request end with a newline?
2. The discovery response has id 1. Why must that match the request?
3. A separate local server process answers real discovery messages. Which claim is supported?

Section 1.6 6 of 7

Guided comparison

Focus

Explain the discovery result and distinguish modern errors from legacy startup.

The completed request trace sends server/discover with identifier 1 and the pinned metadata. The response contains the same identifier, resultType complete, supportedVersions including 2026-07-28, and capabilities for tools, resources, and prompts. Server identity appears in result metadata. Cache fields state how long the result may be reused and whether it is private to the authorization context.

The client then sends a tools/list request with fresh per-request metadata. It does not rely on the earlier discovery call to establish capabilities. A negative fixture removes the required capabilities field and receives invalid-params error -32602. Another requests an unsupported version and receives -32022 with the supported list.

These failures are useful evidence, not startup mysteries to bypass. The lab intentionally does not send initialize. A legacy-only client would need a compatible older server or a deliberate adapter. The official change log gives the revision context; the lesson’s runnable path remains pinned so students do not accidentally combine incompatible lifecycle examples.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A valid discovery call occurred earlier. May the next request omit required capabilities metadata?
2. The server returns -32022 with supported versions. What kind of failure is this?
3. A cached discovery result is marked private. What does that imply?

Section 1.7 7 of 7

An integration written for an older protocol revision

Focus

Diagnose an older integration by its declared protocol era before adapting it.

An integration copied from an older tutorial sends initialize, waits for initialization, and then omits metadata from subsequent calls. The new server supports only 2026-07-28. The failure is not fixed by increasing a timeout: the two programs disagree about the request lifecycle.

A completed diagnosis records the client’s assumed revision and the server’s supported revision. The repair updates the client to use server/discover and per-request metadata, then checks ordinary results for resultType and required cache fields where applicable. Alternatively, a deliberately maintained adapter can translate supported older behavior. The adapter must be tested as its own compatibility component rather than implied by a date string.

This transfer case shows why protocol versioning is an engineering constraint rather than a footnote. A method name such as tools/call may exist in several revisions while surrounding requirements differ. Pinning dependencies and documenting the target revision makes failures reproducible. The local lab avoids external package drift by implementing its narrow documented method set directly and labeling unsupported features instead of claiming universal conformance.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A legacy client waits for initialize against a modern-only server. Would a longer timeout resolve the lifecycle mismatch?
2. Why is matching the tools/call method name insufficient for compatibility?
3. What should a narrow hand-written protocol lab claim?

Your personal notes

Optional, ungraded, and saved only in this browser. Export a backup from the Academy homepage to keep them.

References and further reading
Ask your own AI assistant

Copy this prompt into an assistant you already use. Nothing is sent automatically, and your personal notes are not included.

Next lesson: Building a local protocol integration →