|
1 | 1 | --- |
2 | 2 | title: MCP Server Transports |
3 | | -sidebar_label: STDIO & SSE Transports |
| 3 | +sidebar_label: STDIO, Streamable HTTP & SSE Transports |
4 | 4 | --- |
5 | 5 |
|
6 | | -# MCP Server Transports: STDIO & SSE |
| 6 | +# MCP Server Transports: STDIO, Streamable HTTP & SSE |
7 | 7 |
|
8 | | -Model Context Protocol (MCP) supports two primary transport mechanisms for communication between Roo Code and MCP servers: Standard Input/Output (STDIO) and Server-Sent Events (SSE). Each has distinct characteristics, advantages, and use cases. |
| 8 | +Model Context Protocol (MCP) supports three primary transport mechanisms for communication between Roo Code and MCP servers: Standard Input/Output (STDIO), Streamable HTTP (the modern standard), and Server-Sent Events (SSE) (for legacy use). Each has distinct characteristics, advantages, and use cases. |
9 | 9 |
|
10 | 10 | ## STDIO Transport |
11 | 11 |
|
@@ -58,10 +58,71 @@ const server = new Server({name: 'local-server', version: '1.0.0'}); |
58 | 58 | const transport = new StdioServerTransport(server); |
59 | 59 | transport.listen(); |
60 | 60 | ``` |
| 61 | +## Streamable HTTP Transport |
61 | 62 |
|
62 | | -## SSE Transport |
| 63 | +Streamable HTTP transport is the modern standard for remote MCP server communication, replacing the older HTTP+SSE transport. It operates over HTTP/HTTPS and allows for more flexible server implementations. |
63 | 64 |
|
64 | | -Server-Sent Events (SSE) transport runs on a remote server and communicates over HTTP/HTTPS. |
| 65 | +### How Streamable HTTP Transport Works |
| 66 | + |
| 67 | +1. The server provides a single HTTP endpoint (MCP endpoint) that supports both POST and GET methods. |
| 68 | +2. The client (Roo Code) sends requests to this MCP endpoint using HTTP POST. |
| 69 | +3. The server processes the request and sends back a response. |
| 70 | +4. Optionally, the server can use Server-Sent Events (SSE) over the same connection to stream multiple messages or notifications to the client. This allows for basic request-response interactions as well as more advanced streaming and server-initiated communication. |
| 71 | + |
| 72 | +``` |
| 73 | +Client Server |
| 74 | + | | |
| 75 | + |---- HTTP POST /mcp_endpoint ---->| (client request) |
| 76 | + | | (processes request) |
| 77 | + |<--- HTTP Response / SSE Stream --| (server response / stream) |
| 78 | + | | |
| 79 | +``` |
| 80 | + |
| 81 | +### Streamable HTTP Characteristics |
| 82 | + |
| 83 | +* **Modern Standard**: Preferred method for new remote MCP server implementations. |
| 84 | +* **Remote Access**: Can be hosted on a different machine from Roo Code. |
| 85 | +* **Scalability**: Can handle multiple client connections concurrently. |
| 86 | +* **Protocol**: Works over standard HTTP/HTTPS. |
| 87 | +* **Flexibility**: Supports simple request-response and advanced streaming. |
| 88 | +* **Single Endpoint**: Uses a single URL path for all MCP communication. |
| 89 | +* **Authentication**: Can use standard HTTP authentication mechanisms. |
| 90 | +* **Backwards Compatibility**: Servers can maintain compatibility with older HTTP+SSE clients. |
| 91 | + |
| 92 | +### When to Use Streamable HTTP |
| 93 | + |
| 94 | +Streamable HTTP transport is ideal for: |
| 95 | + |
| 96 | +* All new remote MCP server developments. |
| 97 | +* Servers requiring robust, scalable, and flexible communication. |
| 98 | +* Integrations that might involve streaming data or server-sent notifications. |
| 99 | +* Public services or centralized tools. |
| 100 | +* Replacing legacy SSE transport implementations. |
| 101 | + |
| 102 | +### Streamable HTTP Implementation Example |
| 103 | + |
| 104 | +Configuration in `settings.json`: |
| 105 | +```json |
| 106 | +"mcp.servers": { |
| 107 | + "StreamableHTTPMCPName": { |
| 108 | + "type": "streamable-http", |
| 109 | + "url": "http://localhost:8080/mcp" |
| 110 | + } |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +For server-side implementation, refer to the MCP SDK documentation for `StreamableHTTPClientTransport`. |
| 115 | + |
| 116 | +### Backwards Compatibility with HTTP+SSE |
| 117 | + |
| 118 | +Clients and servers can maintain backwards compatibility with the deprecated HTTP+SSE transport (from protocol version 2024-11-05). |
| 119 | + |
| 120 | +Servers wanting to support older clients should: |
| 121 | +* Continue to host both the SSE (`/events`) and POST (`/message`) endpoints of the old transport, alongside the new “MCP endpoint” defined for the Streamable HTTP transport. |
| 122 | + |
| 123 | +## SSE Transport (Legacy) |
| 124 | + |
| 125 | +Server-Sent Events (SSE) transport is a legacy method for remote server communication over HTTP/HTTPS. For new implementations, **Streamable HTTP transport is recommended.** SSE remains available for compatibility with older MCP servers. |
65 | 126 |
|
66 | 127 | ### How SSE Transport Works |
67 | 128 |
|
@@ -145,9 +206,9 @@ A local file search tool using STDIO would: |
145 | 206 | * Not require network configuration |
146 | 207 | * Need to be installed alongside Roo Code or via a package manager |
147 | 208 |
|
148 | | -### SSE: Hosted Deployment Model |
| 209 | +### Streamable HTTP / SSE (Legacy): Hosted Deployment Model |
149 | 210 |
|
150 | | -SSE servers can be deployed to remote servers and accessed over the network: |
| 211 | +Streamable HTTP (recommended) and legacy SSE servers can be deployed to remote servers and accessed over the network: |
151 | 212 |
|
152 | 213 | * **Installation**: Installed once on a server, accessed by many users |
153 | 214 | * **Distribution**: Single deployment serves multiple clients |
@@ -175,22 +236,23 @@ Some scenarios benefit from a hybrid approach: |
175 | 236 | 2. **SSE with Local Commands**: A remote SSE server that can trigger operations on the client machine through callbacks |
176 | 237 | 3. **Gateway Pattern**: STDIO servers for local operations that connect to SSE servers for specialized functions |
177 | 238 |
|
178 | | -## Choosing Between STDIO and SSE |
179 | | - |
180 | | -| Consideration | STDIO | SSE | |
181 | | -|---------------|-------|-----| |
182 | | -| **Location** | Local machine only | Local or remote | |
183 | | -| **Clients** | Single client | Multiple clients | |
184 | | -| **Performance** | Lower latency | Higher latency (network overhead) | |
185 | | -| **Setup Complexity** | Simpler | More complex (requires HTTP server) | |
186 | | -| **Security** | Inherently secure | Requires explicit security measures | |
187 | | -| **Network Access** | Not needed | Required | |
188 | | -| **Scalability** | Limited to local machine | Can distribute across network | |
189 | | -| **Deployment** | Per-user installation | Centralized installation | |
190 | | -| **Updates** | Distributed updates | Centralized updates | |
191 | | -| **Resource Usage** | Uses client resources | Uses server resources | |
192 | | -| **Dependencies** | Client-side dependencies | Server-side dependencies | |
| 239 | +## Choosing Between Transports |
| 240 | + |
| 241 | +| Consideration | STDIO | Streamable HTTP | SSE (Legacy) | |
| 242 | +|---------------|-------|-----------------|--------------| |
| 243 | +| **Location** | Local machine only | Local or remote | Local or remote | |
| 244 | +| **Clients** | Single client | Multiple clients | Multiple clients | |
| 245 | +| **Performance** | Lower latency | Higher latency (network overhead) | Higher latency (network overhead) | |
| 246 | +| **Setup Complexity** | Simpler | More complex (requires HTTP server) | More complex (requires HTTP server, potentially two endpoints) | |
| 247 | +| **Security** | Inherently secure | Requires explicit security measures | Requires explicit security measures | |
| 248 | +| **Network Access** | Not needed | Required | Required | |
| 249 | +| **Scalability** | Limited to local machine | Can distribute across network | Can distribute across network | |
| 250 | +| **Deployment** | Per-user installation | Centralized installation | Centralized installation | |
| 251 | +| **Updates** | Distributed updates | Centralized updates | Centralized updates | |
| 252 | +| **Resource Usage** | Uses client resources | Uses server resources | Uses server resources | |
| 253 | +| **Dependencies** | Client-side dependencies | Server-side dependencies | Server-side dependencies | |
| 254 | +| **Recommendation** | Ideal for local, secure, single-client tools | **Modern standard for all new remote servers** | Legacy, for existing older servers | |
193 | 255 |
|
194 | 256 | ## Configuring Transports in Roo Code |
195 | 257 |
|
196 | | -For detailed information on configuring STDIO and SSE transports in Roo Code, including example configurations, see the [Understanding Transport Types](/features/mcp/using-mcp-in-roo#understanding-transport-types) section in the Using MCP in Roo Code guide. |
| 258 | +For detailed information on configuring STDIO, Streamable HTTP, and SSE (Legacy) transports in Roo Code, including example configurations, see the [Understanding Transport Types](/features/mcp/using-mcp-in-roo#understanding-transport-types) section in the Using MCP in Roo Code guide. |
0 commit comments