CONCEPT Two standard transports
The transport layer is how JSON-RPC messages actually travel. The spec defines two standard transports, and clients SHOULD support stdio whenever possible:
- stdio — for local servers. The client launches the server as a
subprocess; the server reads JSON-RPC from
stdinand writes JSON-RPC tostdout. No network, no overhead. Typically serves a single client. - Streamable HTTP — for remote servers. An independent process reachable at one HTTP MCP endpoint; the client POSTs JSON-RPC, and the server may optionally reply with Server-Sent Events (SSE) to stream multiple messages. Serves many clients, supports standard HTTP auth (bearer tokens, OAuth).
CONCEPT JSON-RPC message framing
Whatever the transport, JSON-RPC messages MUST be UTF-8 encoded. Framing differs per transport:
| stdio | Streamable HTTP | |
|---|---|---|
| Location | Local subprocess (same machine) | Remote/independent process |
| Channel | stdin / stdout | HTTP POST (+ optional GET/SSE) |
| Framing | One message per line, newline-delimited; no embedded newlines | HTTP request/response bodies; SSE events for streams |
| Streaming | Sequential messages | Optional SSE stream from server |
| Auth | Local process trust | Bearer / API keys / OAuth headers |
| Clients served | Usually one | Many |
stdout
that is not a valid MCP message — a stray print() corrupts the stream. Use stderr for
logging.Origin header
(DNS-rebinding defense), SHOULD bind to 127.0.0.1 when local, and
SHOULD require authentication.DIAGRAM Local subprocess vs. remote endpoint
CODE Registering local (stdio) vs remote (HTTP) servers
Same protocol, two transports. A local server is a command the host launches; a remote server is a URL. With the Claude CLI:
# Local server over stdio — the host launches it as a subprocess claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path # Remote server over Streamable HTTP — the host connects to a URL claude mcp add --transport http sentry https://mcp.sentry.dev/mcp # In the Messages API MCP connector, remote servers are declared by url: mcp_servers = [ { "type": "url", "name": "sentry", "url": "https://mcp.sentry.dev/mcp", "authorization_token": "Bearer <token>" } # HTTP auth ]
TRADE-OFFS stdio vs. Streamable HTTP
✅ stdio (local)
- Zero network overhead, lowest latency
- Simplest trust model — same machine, launched by the host
- Great for filesystem / local-tool servers; clients SHOULD prefer it
✅ Streamable HTTP (remote)
- Reachable over the network; one server serves many clients
- Standard HTTP auth (OAuth / bearer) and optional SSE streaming
- But: needs Origin validation, TLS, and auth to be safe
EXAM TRAPS
stdin/stdout — no network. Remote = Streamable HTTP.PRACTICE
Q1 · Which transport for a filesystem server on the user's laptop, and why?
stdio — it's local, so the host launches the server as a subprocess and exchanges JSON-RPC over stdin/stdout with no network overhead. The spec says clients SHOULD prefer stdio when possible.
Q2 · What did Streamable HTTP replace, and what may it use to stream?
It replaced the older HTTP+SSE transport (protocol version 2024-11-05). Streamable HTTP uses HTTP POST for client→server messages and may optionally open a Server-Sent Events (SSE) stream for multiple server→client messages.
Q3 · How are individual JSON-RPC messages framed over stdio?
Newline-delimited, one message per line, UTF-8, with no embedded newlines inside a message. The server must write nothing but valid MCP messages to stdout.