NewAI Content Creation is now live in Early Access
Turning Point Training Instituteby Training Center
Skip to content
0%
Module 1 — Inside the protocol (2026-07-28)Lesson 3 of 4
7 min readIntermediate
Downloads & resources
Download this lesson's materials, ready to use.

Discovery and the request lifecycle

Where you are: Module 1, lesson 6. You have seen requests and results (L04, L05). Now you look at how a client and server agree on a protocol version and capabilities, per request, and how to interoperate with servers and clients that still use the legacy handshake.

Example prompt

What changed in V2: the earlier lesson taught the initialize handshake and a three-phase lifecycle as current. Revision 2026-07-28 removed the handshake; here it is the legacy mechanism (2025-11-25 and earlier) you fall back to.

What you will be able to do

  • Build a valid 2026-07-28 request with the required _meta fields, and predict the error when one is missing.
  • Use server/discover and read its result, knowing that servers MUST implement it and clients MAY call it.
  • Recover from UnsupportedProtocolVersionError (-32022) and MissingRequiredClientCapabilityError (-32021).
  • Detect a legacy server on stdio and on HTTP and fall back to initialize only when the rules say so.

The current model: every request stands alone

The base protocol says MCP "is a stateless protocol: all the information needed to process a request is contained in the request itself." Servers MUST NOT rely on earlier requests on the same connection to know the version, capabilities or client identity. An open stdio process is not a session.

So each client request carries these _meta keys:

KeyRequiredMeaning
io.modelcontextprotocol/protocolVersionYesVersion for this request, for example "2026-07-28"
io.modelcontextprotocol/clientCapabilitiesYesCapabilities relevant to this request ({} if none)
io.modelcontextprotocol/clientInfoNo (clients SHOULD send it)Client name and version
io.modelcontextprotocol/logLevelNoPer-request log level (part of deprecated Logging)

A request missing a required key is malformed: the server MUST reply -32602 (Invalid params), HTTP 400 on Streamable HTTP. Servers SHOULD put io.modelcontextprotocol/serverInfo in every result's _meta. clientInfo and serverInfo are self-reported; never base security decisions on them.

server/discover

Servers MUST implement server/discover. Clients MAY call it to learn supported versions, capabilities and identity in one round trip, but are not required to: "a client is free to invoke any RPC inline and handle UnsupportedProtocolVersionError".

Captured from the lab-l08 notes server over stdio (official Python SDK mcp 2.3.0):

json
{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{"_meta":{
  "io.modelcontextprotocol/protocolVersion":"2026-07-28",
  "io.modelcontextprotocol/clientCapabilities":{}}}}
json
{"jsonrpc":"2.0","id":1,"result":{
  "resultType":"complete",
  "supportedVersions":["2026-07-28"],
  "capabilities":{"prompts":{"listChanged":true},"resources":{"listChanged":true,"subscribe":true},"tools":{"listChanged":true}},
  "instructions":"A DEMO notes store with synthetic data. add_note changes state; get_note is read-only.",
  "ttlMs":0,"cacheScope":"private",
  "_meta":{"io.modelcontextprotocol/serverInfo":{"name":"demo-notes","version":"1.0.0"}}}}

supportedVersions lists the modern versions accepted per request. The same server also answers legacy initialize (below); that era is not listed here.

Errors that drive the lifecycle

Unsupported version. If the server does not implement the requested version it MUST return -32022 with the versions it supports. The client SHOULD retry with a common version or surface an error. Captured from the same server:

json
{"jsonrpc":"2.0","id":1,"error":{"code":-32022,"message":"Unsupported protocol version",
 "data":{"supported":["2026-07-28"],"requested":"2099-01-01"}}}

Missing capability. A server MUST NOT rely on capabilities the client has not declared. If a request needs one, it MUST return -32021 with data.requiredCapabilities (HTTP 400). In L05 the elicitation server returned {"code":-32021, ..., "data":{"requiredCapabilities":{"elicitation":{"form":{}}}}} to a client that declared {}.

HTTP only: a mismatch between headers and body is -32020 (HeaderMismatch), and an unknown method is HTTP 404 with JSON-RPC -32601. L07 covers the headers.

What "lifecycle" means now

There is no initialise, operate, shut down sequence at the protocol level. What remains:

  • Per request: the client sends a request with _meta; the server returns a result (resultType "complete" or "input_required") or an error. Long operations may stream request-scoped notifications such as notifications/progress before the final response.
  • Cancellation: on stdio the client sends notifications/cancelled with the requestId; on Streamable HTTP closing the response stream is the cancellation. Senders SHOULD set timeouts on every request.
  • Change notifications: the client opens a subscriptions/listen request and receives opted-in notifications (for example notifications/tools/list_changed) on that stream, each tagged with io.modelcontextprotocol/subscriptionId.
  • End: stdio follows the subprocess (L07); on HTTP each request ends with its response.
  • Removed in 2026-07-28: ping, logging/setLevel, notifications/initialized, notifications/roots/list_changed.

Legacy: the initialize handshake (2025-11-25 and earlier)

Legacy clients open a session: initialize (with protocolVersion, capabilities, clientInfo), the server's result (with its chosen protocolVersion, capabilities, serverInfo), then the client's notifications/initialized. Only then do normal requests flow, and they carry no _meta version. Captured from the same lab-l08 server, started fresh:

json
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25",
 "capabilities":{},"clientInfo":{"name":"x","version":"0"}}}
json
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-11-25",
 "capabilities":{"prompts":{"listChanged":false},"resources":{"listChanged":false,"subscribe":false},"tools":{"listChanged":false}},
 "instructions":"A DEMO notes store ...","serverInfo":{"name":"demo-notes","version":"1.0.0"}}}

There is no resultType; clients MUST treat its absence as "complete". This server is dual-era (an SDK compatibility layer, which the spec allows) and picks the era from how the client opens. On stdio the era is fixed per process: after a modern request, the SDK rejected a later initialize with -32022.

Fallback rules (current spec, Versioning and Compatibility)

  • stdio: a dual-era client SHOULD send server/discover first with its preferred modern version. A DiscoverResult means modern. A recognised modern error such as -32022 means modern with another version: do not fall back. Any other error, or no reply within a timeout, means legacy: fall back to initialize. The fallback MUST NOT be keyed to one specific error code.
  • Streamable HTTP: send a modern request. On 400, inspect the body: a recognised modern error means modern (fix the request or version); an empty or unrecognised body means legacy, so fall back to initialize, and possibly further to the deprecated HTTP+SSE transport.
  • Cache the era per server process (stdio) or origin (HTTP).
  • A modern-only server SHOULD name its supported versions in any error it returns to initialize, because legacy clients cannot move forward on their own.

Hosts differ today. Claude Code negotiates 2026-07-28 (force the handshake with MCP_PROTOCOL_NEGOTIATION=legacy); Cursor's client spoke 2025-11-25 and earlier per a staff post on 2026-09-21; other hosts are unknown. A modern-only server fails with every legacy host.

Practice task

In lab-l08, probe the server the way a dual-era client would. Create probe.jsonl with one line each:

code
{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2099-01-01","io.modelcontextprotocol/clientCapabilities":{}}}}
{"jsonrpc":"2.0","id":2,"method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{}}}}
{"jsonrpc":"2.0","id":3,"method":"tools/list","params":{}}

Run (cat probe.jsonl; sleep 3) | ./run.sh serve 2>/dev/null.

Then run a fresh process with a legacy opening, legacy.jsonl:

code
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"probe","version":"0"}}}

Run (cat legacy.jsonl; sleep 3) | ./run.sh serve 2>/dev/null.

Check your result: id 1 returns error -32022 listing "supported":["2026-07-28"] (a modern server, so a client would retry, not fall back); id 2 returns a DiscoverResult with supportedVersions and serverInfo demo-notes; id 3, which has no _meta, returns error -32602; and the fresh process answers initialize with "protocolVersion":"2025-11-25" and no resultType.

Check your understanding

  1. A client skips server/discover and sends tools/call straight away. Is it compliant? Yes. Servers MUST implement server/discover; clients MAY skip it and handle -32022 by retrying with a supported version. On stdio a dual-era client SHOULD still probe first, because some legacy servers would run tools/call under legacy rules instead of failing.

  2. Over stdio your probe gets -32601 Method not found. Fall back to initialize? Yes: -32601 is not a recognised modern error, so the server is treated as legacy. If the reply had been -32022 you would stay modern and retry with a supported version.

  3. Your server caches the client's capabilities from its first request and reuses them later in the same stdio process. What is wrong? Servers MUST NOT rely on prior requests to establish capabilities, version or identity. Each request declares its own, and a client may interleave unrelated requests on one process. Read capabilities from the current request's _meta every time.

Sources