Skip to content

Commit 0eaee87

Browse files
committed
Address comments
1 parent ec19392 commit 0eaee87

File tree

2 files changed

+32
-27
lines changed

2 files changed

+32
-27
lines changed

docs/docs/concepts/architecture.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ The transport layer handles the actual communication between clients and servers
108108
- Uses standard input/output for communication
109109
- Ideal for local processes
110110

111-
2. **HTTP with SSE transport**
112-
- Uses Server-Sent Events for server-to-client messages
111+
2. **Streamable HTTP transport**
112+
- Uses HTTP with optional Server-Sent Events for streaming
113113
- HTTP POST for client-to-server messages
114114

115115
All transports use [JSON-RPC](https://www.jsonrpc.org/) 2.0 to exchange messages. See the [specification](/specification/) for detailed information about the Model Context Protocol message format.
@@ -295,7 +295,7 @@ Here's a basic example of implementing an MCP server:
295295
- Simple process management
296296

297297
2. **Remote communication**
298-
- Use SSE for scenarios requiring HTTP compatibility
298+
- Use Streamable HTTP for scenarios requiring HTTP compatibility
299299
- Consider security implications including authentication and authorization
300300

301301
### Message handling

docs/docs/concepts/transports.mdx

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ SSE transport enables server-to-client streaming with HTTP POST requests for cli
141141

142142
Use Streamable HTTP when:
143143

144-
- Building web-based integrations
144+
- Building web-based integrations
145145
- Needing client-server communication over HTTP
146146
- Requiring stateful sessions
147147
- Supporting multiple concurrent clients
@@ -162,21 +162,21 @@ Use Streamable HTTP when:
162162

163163
```typescript
164164
import express from "express";
165-
165+
166166
const app = express();
167-
167+
168168
const server = new Server({
169-
name: "example-server",
169+
name: "example-server",
170170
version: "1.0.0"
171171
}, {
172172
capabilities: {}
173173
});
174-
174+
175175
// MCP endpoint handles both POST and GET
176176
app.post("/mcp", async (req, res) => {
177177
// Handle JSON-RPC request
178178
const response = await server.handleRequest(req.body);
179-
179+
180180
// Return single response or SSE stream
181181
if (needsStreaming) {
182182
res.setHeader("Content-Type", "text/event-stream");
@@ -185,13 +185,13 @@ Use Streamable HTTP when:
185185
res.json(response);
186186
}
187187
});
188-
188+
189189
app.get("/mcp", (req, res) => {
190190
// Optional: Support server-initiated SSE streams
191191
res.setHeader("Content-Type", "text/event-stream");
192192
// Send server notifications/requests...
193193
});
194-
194+
195195
app.listen(3000);
196196
```
197197

@@ -205,7 +205,7 @@ Use Streamable HTTP when:
205205
}, {
206206
capabilities: {}
207207
});
208-
208+
209209
const transport = new HttpClientTransport(
210210
new URL("http://localhost:3000/mcp")
211211
);
@@ -219,25 +219,25 @@ Use Streamable HTTP when:
219219
from mcp.server.http import HttpServerTransport
220220
from starlette.applications import Starlette
221221
from starlette.routing import Route
222-
222+
223223
app = Server("example-server")
224-
224+
225225
async def handle_mcp(scope, receive, send):
226226
if scope["method"] == "POST":
227227
# Handle JSON-RPC request
228228
response = await app.handle_request(request_body)
229-
229+
230230
if needs_streaming:
231231
# Return SSE stream
232232
await send_sse_response(send, response)
233233
else:
234234
# Return JSON response
235235
await send_json_response(send, response)
236-
236+
237237
elif scope["method"] == "GET":
238238
# Optional: Support server-initiated SSE streams
239239
await send_sse_stream(send)
240-
240+
241241
starlette_app = Starlette(
242242
routes=[
243243
Route("/mcp", endpoint=handle_mcp, methods=["POST", "GET"]),
@@ -284,9 +284,9 @@ fetch("/mcp", {
284284
method: "POST",
285285
headers: {
286286
"Content-Type": "application/json",
287-
"Mcp-Session-Id": sessionId
287+
"Mcp-Session-Id": sessionId,
288288
},
289-
body: JSON.stringify(request)
289+
body: JSON.stringify(request),
290290
});
291291
```
292292

@@ -315,7 +315,10 @@ Without these protections, attackers could use DNS rebinding to interact with lo
315315
### Server-Sent Events (SSE) - Deprecated
316316

317317
<Note>
318-
SSE as a standalone transport is deprecated as of protocol version 2024-11-05. It has been replaced by Streamable HTTP, which incorporates SSE as an optional streaming mechanism. For backwards compatibility information, see the [backwards compatibility](#backwards-compatibility) section below.
318+
SSE as a standalone transport is deprecated as of protocol version 2024-11-05.
319+
It has been replaced by Streamable HTTP, which incorporates SSE as an optional
320+
streaming mechanism. For backwards compatibility information, see the
321+
[backwards compatibility](#backwards-compatibility) section below.
319322
</Note>
320323

321324
The legacy SSE transport enabled server-to-client streaming with HTTP POST requests for client-to-server communication.
@@ -662,30 +665,32 @@ async function detectTransport(serverUrl: string): Promise<TransportType> {
662665
method: "POST",
663666
headers: {
664667
"Content-Type": "application/json",
665-
"Accept": "application/json, text/event-stream"
668+
Accept: "application/json, text/event-stream",
666669
},
667670
body: JSON.stringify({
668671
jsonrpc: "2.0",
669672
method: "initialize",
670-
params: { /* ... */ }
671-
})
673+
params: {
674+
/* ... */
675+
},
676+
}),
672677
});
673-
678+
674679
if (response.ok) {
675680
return "streamable-http";
676681
}
677682
} catch (error) {
678683
// Fall back to legacy SSE
679684
const sseResponse = await fetch(serverUrl, {
680685
method: "GET",
681-
headers: { "Accept": "text/event-stream" }
686+
headers: { Accept: "text/event-stream" },
682687
});
683-
688+
684689
if (sseResponse.ok) {
685690
return "legacy-sse";
686691
}
687692
}
688-
693+
689694
throw new Error("Unsupported transport");
690695
}
691696
```

0 commit comments

Comments
 (0)