docs/mcp/mcp-transport-mechanisms.mdx
Model Context Protocol (MCP) supports two primary transport mechanisms for communication between Cline and MCP servers: Standard Input/Output (STDIO) and Server-Sent Events (SSE). Each has distinct characteristics, advantages, and use cases.
STDIO transport runs locally on your machine and communicates via standard input/output streams.
Client Server
| |
|<---- JSON message ----->| (via STDIN)
| | (processes request)
|<---- JSON message ------| (via STDOUT)
| |
STDIO transport is ideal for:
import { Server } from "@modelcontextprotocol/sdk/server/index.js"
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
const server = new Server({ name: "local-server", version: "1.0.0" })
// Register tools...
// Use STDIO transport
const transport = new StdioServerTransport(server)
transport.listen()
Server-Sent Events (SSE) transport runs on a remote server and communicates over HTTP/HTTPS.
Client Server
| |
|---- HTTP GET /events ----------->| (establish SSE connection)
|<---- SSE event stream -----------| (persistent connection)
| |
|---- HTTP POST /message --------->| (client request)
|<---- SSE event with response ----| (server response)
| |
SSE transport is better for:
import { Server } from "@modelcontextprotocol/sdk/server/index.js"
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js"
import express from "express"
const app = express()
const server = new Server({ name: "remote-server", version: "1.0.0" })
// Register tools...
// Use SSE transport
const transport = new SSEServerTransport(server)
app.use("/mcp", transport.requestHandler())
app.listen(3000, () => {
console.log("MCP server listening on port 3000")
})
The choice between STDIO and SSE transports directly impacts how you'll deploy and manage your MCP servers.
STDIO servers run locally on the same machine as Cline, which has several important implications:
A local file search tool using STDIO would:
SSE servers can be deployed to remote servers and accessed over the network:
A database query tool using SSE would:
Some scenarios benefit from a hybrid approach:
| Consideration | STDIO | SSE |
|---|---|---|
| Location | Local machine only | Local or remote |
| Clients | Single client | Multiple clients |
| Performance | Lower latency | Higher latency (network overhead) |
| Setup Complexity | Simpler | More complex (requires HTTP server) |
| Security | Inherently secure | Requires explicit security measures |
| Network Access | Not needed | Required |
| Scalability | Limited to local machine | Can distribute across network |
| Deployment | Per-user installation | Centralized installation |
| Updates | Distributed updates | Centralized updates |
| Resource Usage | Uses client resources | Uses server resources |
| Dependencies | Client-side dependencies | Server-side dependencies |
For detailed information on configuring STDIO and SSE transports in Cline, including examples, see Configuring MCP Servers.