You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Headings are preferable compared to tabs because:
* The user can simply scroll to reveal information instead of having to
click.
* The page layout does not shift when switching between content that has
different lengths.
* The table of contents displays entries for headings.
Copy file name to clipboardExpand all lines: docs/docs/concepts/transports.mdx
+78-60Lines changed: 78 additions & 60 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,8 +62,10 @@ Use stdio when:
62
62
- Needing simple process communication
63
63
- Working with shell scripts
64
64
65
+
#### Server
66
+
65
67
<Tabs>
66
-
<Tabtitle="TypeScript (Server)">
68
+
<Tabtitle="TypeScript">
67
69
68
70
```typescript
69
71
const server =newServer({
@@ -78,7 +80,26 @@ Use stdio when:
78
80
```
79
81
80
82
</Tab>
81
-
<Tabtitle="TypeScript (Client)">
83
+
<Tabtitle="Python">
84
+
85
+
```python
86
+
app = Server("example-server")
87
+
88
+
asyncwith stdio_server() as streams:
89
+
await app.run(
90
+
streams[0],
91
+
streams[1],
92
+
app.create_initialization_options()
93
+
)
94
+
```
95
+
96
+
</Tab>
97
+
</Tabs>
98
+
99
+
#### Client
100
+
101
+
<Tabs>
102
+
<Tabtitle="TypeScript">
82
103
83
104
```typescript
84
105
const client =newClient({
@@ -96,21 +117,7 @@ Use stdio when:
96
117
```
97
118
98
119
</Tab>
99
-
<Tabtitle="Python (Server)">
100
-
101
-
```python
102
-
app = Server("example-server")
103
-
104
-
asyncwith stdio_server() as streams:
105
-
await app.run(
106
-
streams[0],
107
-
streams[1],
108
-
app.create_initialization_options()
109
-
)
110
-
```
111
-
112
-
</Tab>
113
-
<Tabtitle="Python (Client)">
120
+
<Tabtitle="Python">
114
121
115
122
```python
116
123
params = StdioServerParameters(
@@ -124,7 +131,6 @@ Use stdio when:
124
131
```
125
132
126
133
</Tab>
127
-
128
134
</Tabs>
129
135
130
136
### Streamable HTTP
@@ -149,8 +155,10 @@ Use Streamable HTTP when:
149
155
- SSE streams initiated by client requests
150
156
- SSE streams from HTTP GET requests to the MCP endpoint
151
157
158
+
#### Server
159
+
152
160
<Tabs>
153
-
<Tabtitle="TypeScript (Server)">
161
+
<Tabtitle="TypeScript">
154
162
155
163
```typescript
156
164
importexpressfrom"express";
@@ -188,24 +196,7 @@ Use Streamable HTTP when:
188
196
```
189
197
190
198
</Tab>
191
-
<Tabtitle="TypeScript (Client)">
192
-
193
-
```typescript
194
-
const client =newClient({
195
-
name: "example-client",
196
-
version: "1.0.0"
197
-
}, {
198
-
capabilities: {}
199
-
});
200
-
201
-
const transport =newHttpClientTransport(
202
-
newURL("http://localhost:3000/mcp")
203
-
);
204
-
awaitclient.connect(transport);
205
-
```
206
-
207
-
</Tab>
208
-
<Tabtitle="Python (Server)">
199
+
<Tabtitle="Python">
209
200
210
201
```python
211
202
from mcp.server.http import HttpServerTransport
@@ -238,7 +229,29 @@ Use Streamable HTTP when:
238
229
```
239
230
240
231
</Tab>
241
-
<Tabtitle="Python (Client)">
232
+
</Tabs>
233
+
234
+
#### Client
235
+
236
+
<Tabs>
237
+
<Tabtitle="TypeScript">
238
+
239
+
```typescript
240
+
const client =newClient({
241
+
name: "example-client",
242
+
version: "1.0.0"
243
+
}, {
244
+
capabilities: {}
245
+
});
246
+
247
+
const transport =newHttpClientTransport(
248
+
newURL("http://localhost:3000/mcp")
249
+
);
250
+
awaitclient.connect(transport);
251
+
```
252
+
253
+
</Tab>
254
+
<Tabtitle="Python">
242
255
243
256
```python
244
257
asyncwith http_client("http://localhost:8000/mcp") as transport:
@@ -247,7 +260,6 @@ Use Streamable HTTP when:
247
260
```
248
261
249
262
</Tab>
250
-
251
263
</Tabs>
252
264
253
265
#### Session Management
@@ -325,8 +337,10 @@ Previously used when:
325
337
326
338
The deprecated SSE transport had similar security considerations to Streamable HTTP, particularly regarding DNS rebinding attacks. These same protections should be applied when using SSE streams within the Streamable HTTP transport.
327
339
340
+
#### Server
341
+
328
342
<Tabs>
329
-
<Tabtitle="TypeScript (Server)">
343
+
<Tabtitle="TypeScript">
330
344
331
345
```typescript
332
346
importexpressfrom"express";
@@ -357,24 +371,7 @@ The deprecated SSE transport had similar security considerations to Streamable H
357
371
```
358
372
359
373
</Tab>
360
-
<Tabtitle="TypeScript (Client)">
361
-
362
-
```typescript
363
-
const client =newClient({
364
-
name: "example-client",
365
-
version: "1.0.0"
366
-
}, {
367
-
capabilities: {}
368
-
});
369
-
370
-
const transport =newSSEClientTransport(
371
-
newURL("http://localhost:3000/sse")
372
-
);
373
-
awaitclient.connect(transport);
374
-
```
375
-
376
-
</Tab>
377
-
<Tabtitle="Python (Server)">
374
+
<Tabtitle="Python">
378
375
379
376
```python
380
377
from mcp.server.sse import SseServerTransport
@@ -400,7 +397,29 @@ The deprecated SSE transport had similar security considerations to Streamable H
400
397
```
401
398
402
399
</Tab>
403
-
<Tabtitle="Python (Client)">
400
+
</Tabs>
401
+
402
+
#### Client
403
+
404
+
<Tabs>
405
+
<Tabtitle="TypeScript">
406
+
407
+
```typescript
408
+
const client =newClient({
409
+
name: "example-client",
410
+
version: "1.0.0"
411
+
}, {
412
+
capabilities: {}
413
+
});
414
+
415
+
const transport =newSSEClientTransport(
416
+
newURL("http://localhost:3000/sse")
417
+
);
418
+
awaitclient.connect(transport);
419
+
```
420
+
421
+
</Tab>
422
+
<Tabtitle="Python">
404
423
405
424
```python
406
425
asyncwith sse_client("http://localhost:8000/sse") as streams:
@@ -409,7 +428,6 @@ The deprecated SSE transport had similar security considerations to Streamable H
0 commit comments