Interaction Patterns & Response Handling
Core patterns
Section titled “Core patterns”| Pattern | Direction | Description |
|---|---|---|
| Request → Response | Client → Server | Every request carries an id; the response echoes it |
| Notification | Both ways | Fire-and-forget, no id, no response |
| Streaming | Server → Client | Streamable HTTP can deliver progress/log notifications and the final response via a request-scoped SSE stream |
Session lifecycle
Section titled “Session lifecycle”How a “session” starts depends on the spec era:
- Modern (2026-07-28 and later) — MCP is stateless: there is no handshake and no protocol-level session. Every request carries the protocol version, client info, and client capabilities in
_metafields. Clients discover server capabilities with theserver/discoverrequest (mandatory for servers to implement). - Legacy (2025-11-25 and earlier) — a connection-scoped session was established via the
initializehandshake.
sequenceDiagram participant C as Client participant S as Server rect rgba(200, 200, 200, 0.15) note over C,S: Legacy (2025-11-25 and earlier) C->>S: initialize (version, capabilities, clientInfo) S->>C: InitializeResult (negotiated version, capabilities, serverInfo) C->>S: notifications/initialized note over C,S: Normal operation, then transport-level shutdown end rect rgba(200, 200, 200, 0.15) note over C,S: Modern (2026-07-28) C->>S: server/discover (version + capabilities in _meta) S->>C: supportedVersions, capabilities, serverInfo C->>S: any request (self-contained _meta on each one) S->>C: response end
Shutdown remains transport-level in both eras: on stdio the client closes the server’s stdin (then terminates the process if needed); on HTTP there is nothing to tear down — each request is independent.
Response handling
Section titled “Response handling”- Responses are matched to requests by
id - A response is either a result or an error — never both
- Tool results contain a
contentarray (text, image, audio, resource links, embedded resources), optionalstructuredContent, and anisErrorflag for in-band tool execution errors - In 2026-07-28, every result also carries a required
resultType:"complete"or"input_required"(MRTR) - Hosts feed tool results back into the model’s context for the next turn
Change notifications
Section titled “Change notifications”Servers with the listChanged capability notify clients when offerings change:
notifications/tools/list_changednotifications/resources/list_changednotifications/prompts/list_changed
Clients respond by re-fetching the corresponding list. In 2026-07-28, receiving these notifications requires the client to open a long-lived subscriptions/listen stream and opt into the notification types it wants.
Other patterns to know
Section titled “Other patterns to know”- Pagination — list operations (
tools/list,resources/list,resources/templates/list,prompts/list) return an opaquenextCursorfor fetching more items; clients pass it back ascursorand MUST NOT parse or modify it. A missingnextCursormeans the end of results. - Progress — the client puts a
progressTokenin the request’s_meta; the server MAY emitnotifications/progress(with aprogressvalue that must increase, optionaltotal, optionalmessage) while the request is in flight. - Cancellation — on stdio, the client sends
notifications/cancelledwith therequestId; on Streamable HTTP (2026-07-28), simply closing the SSE response stream is the cancellation signal. - Ping — a
pingrequest answered with an empty result existed through 2025-11-25 to verify liveness; it was removed in 2026-07-28. - Resource subscriptions — servers with the
subscribecapability sendnotifications/resources/updatedfor specific resources. In 2026-07-28 clients opt in via thesubscriptions/listenstream; the olderresources/subscribe/resources/unsubscribemethods belong to legacy revisions.
Key exam points
Section titled “Key exam points”- In the current revision, requests are stateless and self-contained; the
initializehandshake and protocol-level sessions belong to legacy revisions (2025-11-25 and earlier) list_changednotifications enable dynamic discovery at runtime- Servers no longer initiate requests in 2026-07-28 — server-to-client interactions use the MRTR pattern (
InputRequiredResult) - Pagination cursors are opaque; an invalid cursor yields error
-32602
Check your knowledge
Section titled “Check your knowledge”📝 Check your knowledge