CourseModel Context Protocol · Module 2: The Protocol and Its Transports · part 12 of 83
Part 12 · Module 2: The Protocol and Its Transports

Topic 4: Transports

23 min read·22 Sept 2026

A transport carries the JSON-RPC messages between client and server. The messages are the same on every transport; the transport decides framing, where extra metadata travels, and how cancellation is signaled. The 2026-07-28 revision defines two standard transports, stdio and Streamable HTTP.

stdio: the subprocess model

With stdio, the client launches the server as a child process and they talk over its standard streams:

  • The client writes messages to the server's stdin, one JSON object per line. Messages must not contain raw newlines.
  • The server writes messages to its stdout, one per line. Nothing else may ever appear there.
  • The server may write anything to stderr: logs, warnings, tracebacks. Clients may capture, forward, or ignore it, and should not treat it as a sign of failure.
  • Closing stdin asks the server to shut down, and it should exit promptly. If it does not, the client escalates to SIGTERM and then SIGKILL.

The raw run in Part A showed all of this: messages as single lines, logs on stderr, and exit code 0 after stdin closed.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.