Discovery and the request lifecycle — Visual guide
MCP Engineering course · M1
This guide shows, step by step, how an MCP client and server agree on a protocol version and capabilities in revision 2026-07-28: per request, with no handshake. It also shows the legacy handshake (2025-11-25 and earlier) and the exact rules for falling back to it.
What changed in V2: the earlier version of this guide taught the initialize handshake and a three-phase lifecycle (initialization → operation → shutdown) as current. Revision 2026-07-28 removed the handshake. Here it appears only as the legacy mechanism you fall back to.
In one sentence
MCP is now a stateless protocol: "all the information needed to process a request is contained in the request itself." Every request names its own protocol version and client capabilities in _meta, and servers MUST NOT rely on earlier requests to know them. An open stdio process is not a session.
Step 1 — Every request carries its own _meta
| Key | Required | Meaning |
|---|---|---|
io.modelcontextprotocol/protocolVersion | Yes | Version for this request, for example "2026-07-28" |
io.modelcontextprotocol/clientCapabilities | Yes | Capabilities relevant to this request ({} if none) |
io.modelcontextprotocol/clientInfo | No (clients SHOULD send it) | Client name and version |
io.modelcontextprotocol/logLevel | No | Per-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.
Step 2 — server/discover (servers MUST, clients MAY)
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. Captured from the course's lab-l08 notes server over stdio (official Python SDK mcp 2.3.0):
{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{"_meta":{
"io.modelcontextprotocol/protocolVersion":"2026-07-28",
"io.modelcontextprotocol/clientCapabilities":{}}}}
{"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"}}}}
Step 3 — The errors that drive the lifecycle
| Code | Name | When | What the client does |
|---|---|---|---|
-32022 | UnsupportedProtocolVersionError | the server does not implement the requested version; data.supported lists the ones it does | retry with a common version, or surface an error. Do not fall back to legacy. |
-32021 | MissingRequiredClientCapabilityError | the request needs a capability the client did not declare; data.requiredCapabilities (HTTP 400) | declare the capability (if supported) and retry, or give up |
-32602 | Invalid params | a required _meta key is missing | fix the request |
-32020 | HeaderMismatch (HTTP only) | HTTP headers and body disagree | fix the headers (L07) |
Captured from the same server:
{"jsonrpc":"2.0","id":1,"error":{"code":-32022,"message":"Unsupported protocol version",
"data":{"supported":["2026-07-28"],"requested":"2099-01-01"}}}
Key example — a missing capability. A server MUST NOT rely on capabilities the client has not declared. In lesson L05, a tool that needs to ask the user (elicitation) replied to a client that declared {} with:
{"code":-32021, "...": "...", "data":{"requiredCapabilities":{"elicitation":{"form":{}}}}}
Step 4 — The life of one request (diagram)
client server
| request + _meta(protocolVersion, clientCapabilities) |
|------------------------------------------------------->|
| (optional) notifications/progress ... |
|<-------------------------------------------------------|
| result: resultType "complete" |
| or resultType "input_required" -> retry (L05) |
| or JSON-RPC error (-32022 / -32021 / -32602) |
|<-------------------------------------------------------|
What "lifecycle" means now:
- Per request: request with
_meta→ result or error. Long operations may stream request-scoped notifications such asnotifications/progressbefore the final response. - Cancellation: on stdio the client sends
notifications/cancelledwith therequestId; on Streamable HTTP closing the response stream is the cancellation. Set timeouts on every request. - Change notifications: the client opens a
subscriptions/listenrequest and receives opted-in notifications (for examplenotifications/tools/list_changed) on that stream, each tagged withio.modelcontextprotocol/subscriptionId. - End: there is no protocol shutdown phase. stdio follows the subprocess's lifecycle; on HTTP each request ends with its response stream.
- Removed in 2026-07-28:
initialize,notifications/initialized,ping,logging/setLevel,notifications/roots/list_changed.
Legacy: the initialize handshake (2025-11-25 and earlier)
Legacy clients open a session: initialize → the server's result → 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:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25",
"capabilities":{},"clientInfo":{"name":"x","version":"0"}}}
{"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: send server/discover (preferred modern version)
├─ DiscoverResult .................... modern
├─ recognised modern error (-32022) .. modern, retry with a supported version (NO fallback)
└─ any other error / timeout ......... legacy -> fall back to initialize
HTTP: send a modern request
├─ success ........................... modern
└─ 400: recognised modern error body . modern, fix the request or version
empty / unrecognised body .... legacy -> initialize (then, if needed, deprecated HTTP+SSE)
- The fallback MUST NOT be keyed to one specific error code.
- Cache the era per server process (stdio) or per origin (HTTP).
- A modern-only server SHOULD name its supported versions in any error it returns to
initialize.
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.
Glossary
_meta: the per-request metadata object carrying protocol version and client capabilities.server/discover: the discovery method servers MUST implement and clients MAY call.- Capability: a feature a client declares per request (for example
elicitation); servers must not rely on undeclared ones. - Dual-era server: a server that answers both 2026-07-28 requests and the legacy
initializehandshake. - Legacy: revisions 2025-11-25 and earlier, which use the
initializehandshake.
To remember
- No handshake in 2026-07-28: every request carries
protocolVersionandclientCapabilitiesin_meta. - Servers MUST implement
server/discover; clients MAY call it. -32022= unsupported version (retry, don't fall back);-32021= missing capability;-32602= missing_metakey.- No shutdown phase: stdio follows the process; HTTP requests end with their stream.
- Fall back to
initializeonly when the server is not recognisably modern, and never on one hard-coded error code.
Turning Point Academy · MCP Engineering course · Module 1 · Lesson 6 (L06) · V2, spec 2026-07-28