Overview
The Model Context Protocol (MCP) uses transports to enable communication between MCP hosts (clients) and MCP servers. Transports define how messages are serialized and delivered between parties.
Transport Types
STDIO Transport
- Description: Uses standard input/output streams for communication
- Use case: Local server processes spawned by the host
- Message format: JSON-RPC 2.0 messages, one per line
- Advantages:
- Simple setup
- No network configuration needed
- Process lifecycle managed by host
- Limitations:
- Only works for local processes
- Bidirectional but single-client only
HTTP Transport
- Description: Uses HTTP requests for client-to-server communication
- Use case: Remote servers, web-based integrations
- Message format: JSON-RPC 2.0 over HTTP POST
- Advantages:
- Works across networks
- Firewall-friendly
- Stateless request/response model
- Limitations:
- Server cannot initiate messages to client
- Requires polling or complementary transport for server-initiated communication
SSE (Server-Sent Events) Transport
- Description: Uses SSE for server-to-client streaming combined with HTTP for client-to-server
- Use case: Real-time server notifications
- Message format: JSON-RPC 2.0 over SSE stream + HTTP POST
- Advantages:
- Server can push messages to client
- Real-time updates
- Works well with HTTP transport for bidirectional communication
- Limitations:
- Unidirectional (server to client only)
- Requires separate HTTP endpoint for client messages
Message Format
All MCP transports use [[JSON-RPC]] 2.0 as the message protocol:
{
"jsonrpc": "2.0",
"method": "method_name",
"params": {},
"id": 1
}
Transport Selection
- Local tools/servers: STDIO
- Remote APIs: HTTP + SSE
- Real-time notifications: SSE
- Simple integrations: STDIO