Skip to content
mentoor

Topic 4 of 5 · 5 min read

Local stdio versus remote Streamable HTTP transports

Goal: Choose stdio or Streamable HTTP for a described deployment and explain the security and operational consequences of the choice.

A transport is only the way MCP messages travel: stdio runs the server as a subprocess of the client and talks over its standard streams, while Streamable HTTP puts the server behind a URL that many clients can reach.

Check yourself · 1 of 3

In a stdio MCP server, where should debugging log lines be written?

Choose one answer

Why it matters

The message meaning is identical on both. What changes is deployment, authentication, logging and what can go wrong. Picking the wrong one means either exposing a local tool to the network or forcing every user to install your server by hand.

stdio

The client launches the server as a subprocess. The server reads JSON-RPC messages from stdin and writes them to stdout, one message per line, with no embedded newlines. The server may write logs to stderr. It must not write anything to stdout that is not a valid MCP message, so a stray print("starting") breaks the connection.

A host config for a local server typically looks like this:

{
  "mcpServers": {
    "files": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/ana/projects"]
    }
  }
}

The server runs with the user's own rights and normally serves one client. No network port is opened.

Streamable HTTP

The server is an independent process with a single MCP endpoint, for example https://example.com/mcp. The client sends each JSON-RPC message as its own HTTP POST. The server answers with one JSON object or an event stream (SSE) scoped to that request. One remote server typically serves many clients, so you need real authentication and Origin validation: the specification requires servers to validate the Origin header to prevent DNS rebinding attacks.

The older HTTP+SSE transport

Protocol version 2024-11-05 used a different HTTP+SSE design. Streamable HTTP replaced it from 2025-03-26, and the current specification lists the old transport as deprecated. New servers should not use it; clients keep a fallback only to reach older servers.

How to choose

  1. One developer, one machine, access to local files or tools: stdio.
  2. A shared service, many users, centrally updated, behind authentication: Streamable HTTP.
  3. Both: keep the handlers in one module and mount two entry points.

Before and after

Weak: a team ships a database server over stdio and asks forty analysts to install it and its credentials on their laptops. Updates need forty reinstalls.

Better: run it once as a remote server with per-user OAuth and audit logs, and let analysts add its URL to their hosts.

What goes wrong

  • Printing to stdout in a stdio server. One log line corrupts the stream. Log to stderr.
  • Binding a local HTTP server to all interfaces. Bind to 127.0.0.1 and validate Origin.
  • Assuming sessions exist. The 2026-07-28 revision removed protocol-level sessions and Mcp-Session-Id.

Examples

Why the client shows 'invalid JSON'

A Python stdio server calls print("server ready") at startup. The client reads that line from stdout, cannot parse it as JSON-RPC and drops the connection. The fix is print("server ready", file=sys.stderr) or a logger configured to use stderr.

Picking for a deployment

A solo developer wants an assistant to read files in one repo: stdio, launched by the host, no network exposure. A company wants 200 staff to query a CRM through their assistants: Streamable HTTP behind OAuth, deployed once, with access logs.

Key points

  • The two standard transports are stdio and Streamable HTTP; message meaning is identical on both.
  • A stdio server must write only valid MCP messages to stdout and send logs to stderr.
  • Streamable HTTP uses one POST endpoint, and servers must validate the Origin header against DNS rebinding.
  • The HTTP+SSE transport from 2024-11-05 is deprecated; build new servers on Streamable HTTP.
  • stdio suits a single local user; Streamable HTTP suits shared, centrally updated, authenticated services.

Common mistakes

  • Logging to stdout in a stdio server and then blaming the client for invalid messages.
  • Exposing a local Streamable HTTP server on all network interfaces without Origin checks or authentication.
  • Building a new server on the deprecated HTTP+SSE transport because an old tutorial used it.
  • Expecting the same server to behave identically in stdio and HTTP without checking auth and logging differences.

Check yourself · 2 of 3

A company wants 200 employees to query one central CRM through their AI hosts, with per-user access control and a single place to deploy updates. Which transport fits best?

Choose one answer

Check yourself · 3 of 3

A developer runs a local Streamable HTTP server bound to 0.0.0.0 with no Origin check. What risk does the specification's Origin rule address?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic