Why it matters
A protocol that only works in-process cannot support a hosted integration, and one that only works over HTTP cannot run a local filesystem server. MCP keeps the message layer identical and swaps the transport, which is why the same server logic can ship as a local process and a remote service. The transport then determines the operational questions: who authenticates, where the session lives, how cancellation works and what a reconnect means.
Mental model
The data layer is a language and the transport is the postal service: the same letter travels by hand or by air mail. The metaphor breaks because the postal service can lose ordering, duplicate delivery and change the sender's identity, all of which the letter's content does not anticipate.
How it works
Two independent connections, not one session that changes transport. The 2025-06-18 handshake is shown, which is where framing and session headers are visible; the 2026-07-28 revision removes initialize and carries metadata per request.
Client
one connection
Server
same handlers
one line on the wire (wrapped here for display):
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{"listChanged":true}},"serverInfo":{"name":"issues","version":"0.9"}}}
No HTTP status; stdout carries the frame.Step 1: stdio initialize. Hover, tap or tab to any message to inspect its payload.
Figure. The data layer is identical: initialize, the initialized notification, tools/call and its result carry the same fields and ids. The figure shows two independent connections — stdio first, then an HTTP session opened by its own initialize. Only framing, authentication and session headers change; neither connection continues the other.
What to notice. The failure is framing. On stdio, one log line written to stdout corrupts the JSON stream, and the server looks broken while it is only noisy. On HTTP, accepting a session identifier without binding it to the authenticated principal is session fixation — the session identifies state, it does not authenticate the caller.
Text version
Sequence across two lifelines, Client and Server, in two independent sessions. Session 1, stdio: Client to Server initialize as one newline-delimited JSON line with protocolVersion 2025-06-18, roots capability and clientInfo; Server to Client the initialize result as one line; Client to Server notifications/initialized; Client to Server tools/call for issues_search; Server to Client the result content with isError false. A divider marks an alternative transport and a new connection. Session 2, HTTP: Client to Server POST /mcp initialize with Content-Type, Accept, Authorization and the same body; Server to Client HTTP 200 with Mcp-Session-Id 7f3c9a2e and the same result; Client to Server notifications/initialized with MCP-Protocol-Version 2025-06-18 and the session header; Client to Server tools/call with MCP-Protocol-Version, Mcp-Session-Id and the same body; Server to Client the same result as a JSON body or request-scoped SSE event. The two sessions are not one conversation that changes transport.
- Start with an initialise request that carries the protocol version, client capabilities and client info, and check the server's response for the negotiated version.
- Send an initialised notification before issuing ordinary requests, so the server knows the handshake completed.
- For stdio, spawn the process, frame messages as newline-delimited JSON on stdin and stdout, and send logs to stderr.
- For Streamable HTTP, POST each message to the endpoint and accept either a JSON response or an SSE stream carrying related messages.
- Propagate cancellation and timeouts to the underlying work, and close the stream or terminate the process on shutdown.
- Authenticate the HTTP transport with OAuth, validate the token audience and bind any session identifier to the authenticated principal.
Trade-offs
| Choice | Good for | Cost | Fails when |
|---|---|---|---|
| stdio | Local tools, no network exposure | One client per process, no built-in auth | The host runs remotely |
| Streamable HTTP | Remote and multi-client | Auth, session and load-balancer complexity | The server needs server-initiated messages without SSE support |
| Stateful session id | Cheap continuity for a conversation | Sticky routing and session hijack risk | Requests are spread across instances |
| Stateless requests | Any instance can serve any call | State must be carried explicitly | The workflow spans many steps |
Good for
Local tools, no network exposure
Cost
One client per process, no built-in auth
Fails when
The host runs remotely
- The host runs remotely
- The server needs server-initiated messages without SSE support
- Requests are spread across instances
- The workflow spans many steps
Figure. Each choice with what it buys, what it costs, and the case where it loses.
What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.
Text version
Four trade-offs: stdio is good for Local tools, no network exposure, costs One client per process, no built-in auth, and fails when The host runs remotely. Streamable HTTP is good for Remote and multi-client, costs Auth, session and load-balancer complexity, and fails when The server needs server-initiated messages without SSE support. Stateful session id is good for Cheap continuity for a conversation, costs Sticky routing and session hijack risk, and fails when Requests are spread across instances. Stateless requests is good for Any instance can serve any call, costs State must be carried explicitly, and fails when The workflow spans many steps
Failure modes
- Handshake skipped. The client sends requests before initialise and the server rejects or misbehaves. Debug: capture the first three frames on the wire and check the order.
- Framing error on stdio. A log line is written to stdout and corrupts the JSON stream. Debug: run the server and pipe stdout through a JSON parser, failing on the first non-JSON line.
- Session fixation. A session id is accepted without binding to the authenticated user. Debug: replay a session id with a different token and confirm the server rejects it.
In production
Monitor initialise failures, transport-level disconnects and SSE stream duration. The specification mandates the handshake and message framing, while sticky sessions and gateway timeouts are deployment choices, so cap concurrent streams per client and test reconnection against a load balancer without sticky sessions.
Common misconceptions
People think: stdio and HTTP servers are different protocols.
Actually: They share the data layer; only framing, auth and session behaviour differ.
People think: A session id authenticates the caller.
Actually: It identifies state; authentication comes from the token and must be checked independently.
Interview angle
Strong answers separate the data layer from the transport and explain what each transport costs operationally. They mention auth only on HTTP and the session binding problem. Weak answers treat stdio as a legacy mode without saying what it is good for.
Sources
- MCP specification, Transports — stdio framing and Streamable HTTP.
- MCP specification, Lifecycle — initialise, capability negotiation and shutdown.
- RFC 9110, HTTP Semantics — the HTTP semantics the remote transport builds on.