Module 6 · Lesson 5 · 15 min read

Transports in MCP: stdio and Streamable HTTP

MCP Transports: stdio and Streamable HTTP

Introduction

The same messages can travel in different ways: through the input and output of a process on the same machine, or over the network. This lesson explains the two transports adopted in MCP, the rules of each, and what has changed in them historically up to the 2026-07-28 specification.

Learning objectives

  • Explain how the stdio transport works and its message framing rules
  • Describe the Streamable HTTP transport, the single endpoint and the response types
  • Know what was removed or deprecated: HTTP+SSE and Mcp-Session-Id sessions
  • Choose the right transport for a given scenario

What is a transport?

A transport is the way JSON-RPC messages travel between the client and the server. The messages do not change when the transport changes; a tools/call request is the same, but the way it is delivered differs. The specification adopts two transports: stdio and Streamable HTTP.

The stdio transport

In this transport the host runs the server as a subprocess on the same machine, then:

  • The client writes messages to the server's standard input (stdin).
  • The server writes responses to its standard output (stdout).
  • Each JSON message is on a single line, ends with a newline, and contains no newlines inside it.
  • The server may write its logs to standard error (stderr), while stdout is reserved for protocol messages only.

stdio suits local tools: reading project files, or running a command-line tool. Its advantage is simplicity and no need for a network, and its limitation is that the server runs on the user's machine with the user's permissions.

The Streamable HTTP transport

Here the server works as an independent web service that many clients can connect to. The basic rules:

  1. The server has a single endpoint, such as /mcp.
  2. The client sends every JSON-RPC message in an HTTP POST request.
  3. The server responds either with application/json (a single response), or with text/event-stream to stream several messages in the same response, such as progress updates before the result.
  4. The protocol version is sent in the MCP-Protocol-Version header, in addition to being in _meta inside the message.

An example of an HTTP request as it appears on the network:

text
POST /mcp HTTP/1.1
Host: courses.example.edu
Content-Type: application/json
Accept: application/json, text/event-stream
MCP-Protocol-Version: 2026-07-28

{"jsonrpc":"2.0","id":4,"method":"tools/list","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28"}}}

What has changed historically?

ChangeSincePractical meaning
The old HTTP+SSE transport deprecated2025-03-26Replaced by Streamable HTTP with a single endpoint
Mcp-Session-Id sessions removed2026-07-28No session remembered by the server; every request is self-contained

Removing sessions is a direct result of the stateless design. Its practical benefit is that any instance of the server behind a load balancer can handle any request, because the request carries the version and the client's capabilities in _meta and does not depend on a session stored in a particular instance.

A practical example: message framing in stdio

A simple stdio server reads a line and writes a line. In the following simulation we replace stdin and stdout with io.StringIO objects so the code runs without starting a real process, and we compare a sound server with a server that prints debug messages to stdout:

python
import io, json

META = {"io.modelcontextprotocol/protocolVersion": "2026-07-28"}

def serve(stdin, stdout, stderr, noisy=False):
    for line in stdin:
        req = json.loads(line)
        if noisy:
            print("debug: got request", file=stdout)   # wrong: a log in stdout
        else:
            print("debug: got request", file=stderr)   # right: a log in stderr
        resp = {"jsonrpc": "2.0", "id": req["id"],
                "result": {"tools": [], "resultType": "complete"}}
        stdout.write(json.dumps(resp) + "\n")

def client_read(stdout_text):
    parsed, broken = 0, 0
    for line in stdout_text.splitlines():
        try:
            json.loads(line)
            parsed += 1
        except json.JSONDecodeError:
            broken += 1
    return parsed, broken

request = json.dumps({"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {"_meta": META}})
for noisy in (False, True):
    out, err = io.StringIO(), io.StringIO()
    serve(io.StringIO(request + "\n"), out, err, noisy=noisy)
    parsed, broken = client_read(out.getvalue())
    print("Noisy server" if noisy else "Sound server", "| Valid messages:", parsed, "| Broken lines:", broken)

The noisy server produced a broken line that the client cannot parse. In a real client this may mean the whole connection fails. (The empty tool list in the example is a simplification, and real list results also include the caching fields.)

How do you choose?

  • A local tool for a single user that reads their files or runs commands on their machine: stdio.
  • A shared service for several users or applications, or data on an institution's server: Streamable HTTP with authentication and encryption.

Summary

The transport determines how JSON-RPC messages are delivered without changing their content. In stdio the host runs the server as a subprocess, each message is a line in stdin or stdout, and logs go to stderr only. In Streamable HTTP a single endpoint receives POST and responds with JSON or with a text/event-stream stream, with the MCP-Protocol-Version header. The HTTP+SSE transport has been deprecated since 2025-03-26, and Mcp-Session-Id sessions were removed in 2026-07-28.

Terms

TermEnglishDefinition
TransportTransportThe way messages travel between the client and the server
Standard input and outputstdioCarrying messages through the stdin and stdout of a local subprocess
Streamable HTTPStreamable HTTPTransport through a single HTTP endpoint with the ability to stream responses
Single endpointSingle EndpointA single HTTP path that receives all protocol messages
Protocol version headerMCP-Protocol-VersionAn HTTP header that carries the MCP version in use
DeprecatedDeprecatedA feature that is still known but not recommended for new builds

Review questions

  1. Why must a stdio server not write its logs to stdout?
  2. What is the difference between an application/json response and a text/event-stream response in Streamable HTTP?
  3. How does removing Mcp-Session-Id sessions make it easier to spread the load across several server instances?
  4. Which transport would you choose for a server that provides university registration system data to all students, and why?

References