Transport Layer
MCP supports two official transport methods and also allows custom transport implementations.3.1 stdio Transport
Principle: Communication via standard input (stdin) and standard output (stdout) streams. The Host launches the Server as a child process and exchanges JSON-RPC messages through pipes. Each message is delimited by a newline character. Use case: Server and Client are running on the same machine. Advantages:- Zero network overhead, lowest latency
- No need to configure ports or certificates
- Secure (no network interface exposed)
- Simple to implement
- Local use only
- One Server process serves only one Client
node /path/to/my-server/index.js as a child process and communicates via stdin/stdout. The Server’s stderr can be used for log output without interfering with the protocol.
3.2 Streamable HTTP Transport
Status: The currently recommended remote transport method (protocol version2025-11-25).
Principle: Client and Server communicate through a single HTTP endpoint. The Client sends JSON-RPC requests via POST, and the Server can use Server-Sent Events (SSE) for streaming responses and proactive pushes.
Use case: Server is deployed remotely (cloud servers, SaaS services, etc.).
Core Mechanism
Single MCP endpoint: The Server exposes one endpoint (e.g.,/mcp) that handles two HTTP methods:
- POST: The Client sends JSON-RPC requests. The Server can return a single JSON response or stream multiple messages via SSE.
- GET: The Client establishes an SSE connection to receive proactive pushes from the Server (notifications, requests, etc.).
Mcp-Session-Id HTTP header:
MCP-Protocol-Version header:
Last-Event-ID mechanism for reconnection. The Client sends the ID of the last received event when reconnecting, and the Server continues pushing from that point:
Advantages
- Supports remote access
- One Server can serve multiple Clients (distinguished by Session ID)
- Supports standard HTTP authentication (OAuth 2.1, API Keys, etc.)
- Supports load balancing and horizontal scaling
- Supports reconnection and message recovery
Disadvantages
- Network latency
- Requires HTTPS and authentication configuration
Configuration Example
3.3 Deprecated: HTTP+SSE Transport
Differences between the deprecated HTTP+SSE and the current Streamable HTTP:3.4 Custom Transports
MCP allows custom transport layer implementations as long as they meet the basic requirements for JSON-RPC 2.0 message exchange: bidirectional message passing, request-response matching, and notification pushing. For example, you could implement a transport based on WebSocket, gRPC, or a custom TCP protocol.3.5 Selection Guide
3.6 OAuth 2.1 Authentication
Authentication for remote MCP Servers is based on OAuth 2.1 (draft-ietf-oauth-v2-1-13), which is the standard authentication mechanism recommended by the MCP specification. See Chapter 7: Security and Authentication for details. Authentication flow overview:Next Chapter: Building an MCP Server — Complete development guide for TypeScript and Python