CONCEPT MCP is a stateful, lifecycle-managed protocol
MCP is a stateful protocol: a connection isn't just "send whatever" — it has a defined lifecycle. Every connection goes through three phases:
- Initialization — an
initializehandshake that negotiates the protocol version and each side's capabilities, followed by aninitializednotification. - Operation — normal request/response/notification traffic:
tools/list,tools/call,resources/read, notifications, etc. - Shutdown — the connection is closed (for stdio, the client closes the server's
stdinand terminates the subprocess).
CONCEPT The initialize handshake in detail
The client opens with an initialize request carrying a protocolVersion, its
capabilities, and clientInfo. The server replies with its
protocolVersion, capabilities, and serverInfo. Three things happen:
| Step | Field | Purpose |
|---|---|---|
| Version negotiation | protocolVersion | Ensure compatible versions. "If a mutually compatible version is not negotiated, the connection should be terminated." |
| Capability discovery | capabilities | Each side declares what it supports (tools, resources, prompts, notifications) so neither calls unsupported methods |
| Identity exchange | clientInfo / serverInfo | Name + version, for debugging and compatibility |
A capability can carry sub-flags — e.g. "tools": {"listChanged": true} means the server will
emit notifications/tools/list_changed when its tool set changes. After a successful handshake, the
client sends notifications/initialized to signal it's ready — then normal
operation begins.
resources/read against a server that never declared a resources capability, and
a server won't push list_changed notifications a client can't handle.DIAGRAM The connection lifecycle
CODE The initialize request & response
The literal JSON-RPC handshake — version + capability negotiation, then the ready notification:
// Client → Server { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": "2025-06-18", "capabilities": { "elicitation": {} }, "clientInfo": { "name": "example-client", "version": "1.0.0" } } } // Server → Client (declares its own capabilities) { "jsonrpc": "2.0", "id": 1, "result": { "protocolVersion": "2025-06-18", "capabilities": { "tools": { "listChanged": true }, "resources": {} }, "serverInfo": { "name": "example-server", "version": "1.0.0" } } } // Client → Server : ready — now normal operation may begin { "jsonrpc": "2.0", "method": "notifications/initialized" }
TRADE-OFFS Negotiated handshake vs. assume-everything
✅ Explicit initialize + capability negotiation
- Version mismatches fail fast and cleanly (terminate, don't misbehave)
- Each side only calls methods the other declared — no wasted round-trips
- Optional features (list-changed notifications, sampling) gate cleanly on capability
⚠️ Skipping the handshake / assuming support
- Slightly less ceremony up front
- But: silent failures when versions differ or a feature is unsupported
- Breaks the stateful contract — operation before initialize is invalid
EXAM TRAPS
tools/list immediately." → Not until after the
initialize handshake completes and the client sends notifications/initialized.listChanged: true tools capability is what authorizes the server to send
tools/list_changed notifications; undeclared features must not be used.PRACTICE
Q1 · What are the three phases of an MCP connection lifecycle?
Initialization (the initialize handshake + initialized
notification), operation (normal request/response/notification traffic), and shutdown (connection
close / subprocess termination).
Q2 · What three things does the initialize exchange accomplish?
Protocol-version negotiation (compatible versions or terminate), capability
discovery (each side declares what it supports), and identity exchange (clientInfo /
serverInfo for debugging/compatibility).
Q3 · A server declares "tools": {"listChanged": true}. What does that authorize?
It authorizes the server to send notifications/tools/list_changed whenever its
available tool set changes, prompting the client to re-fetch tools/list. Without that declared
capability, the server must not send those notifications.