Skip to content

Commit f3c312d

Browse files
Use headings for splitting server and client code
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.
1 parent 01ae752 commit f3c312d

File tree

1 file changed

+78
-60
lines changed

1 file changed

+78
-60
lines changed

docs/docs/concepts/transports.mdx

Lines changed: 78 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ Use stdio when:
6262
- Needing simple process communication
6363
- Working with shell scripts
6464

65+
#### Server
66+
6567
<Tabs>
66-
<Tab title="TypeScript (Server)">
68+
<Tab title="TypeScript">
6769

6870
```typescript
6971
const server = new Server({
@@ -78,7 +80,26 @@ Use stdio when:
7880
```
7981

8082
</Tab>
81-
<Tab title="TypeScript (Client)">
83+
<Tab title="Python">
84+
85+
```python
86+
app = Server("example-server")
87+
88+
async with 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+
<Tab title="TypeScript">
82103

83104
```typescript
84105
const client = new Client({
@@ -96,21 +117,7 @@ Use stdio when:
96117
```
97118

98119
</Tab>
99-
<Tab title="Python (Server)">
100-
101-
```python
102-
app = Server("example-server")
103-
104-
async with 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-
<Tab title="Python (Client)">
120+
<Tab title="Python">
114121

115122
```python
116123
params = StdioServerParameters(
@@ -124,7 +131,6 @@ Use stdio when:
124131
```
125132

126133
</Tab>
127-
128134
</Tabs>
129135

130136
### Streamable HTTP
@@ -149,8 +155,10 @@ Use Streamable HTTP when:
149155
- SSE streams initiated by client requests
150156
- SSE streams from HTTP GET requests to the MCP endpoint
151157

158+
#### Server
159+
152160
<Tabs>
153-
<Tab title="TypeScript (Server)">
161+
<Tab title="TypeScript">
154162

155163
```typescript
156164
import express from "express";
@@ -188,24 +196,7 @@ Use Streamable HTTP when:
188196
```
189197

190198
</Tab>
191-
<Tab title="TypeScript (Client)">
192-
193-
```typescript
194-
const client = new Client({
195-
name: "example-client",
196-
version: "1.0.0"
197-
}, {
198-
capabilities: {}
199-
});
200-
201-
const transport = new HttpClientTransport(
202-
new URL("http://localhost:3000/mcp")
203-
);
204-
await client.connect(transport);
205-
```
206-
207-
</Tab>
208-
<Tab title="Python (Server)">
199+
<Tab title="Python">
209200

210201
```python
211202
from mcp.server.http import HttpServerTransport
@@ -238,7 +229,29 @@ Use Streamable HTTP when:
238229
```
239230

240231
</Tab>
241-
<Tab title="Python (Client)">
232+
</Tabs>
233+
234+
#### Client
235+
236+
<Tabs>
237+
<Tab title="TypeScript">
238+
239+
```typescript
240+
const client = new Client({
241+
name: "example-client",
242+
version: "1.0.0"
243+
}, {
244+
capabilities: {}
245+
});
246+
247+
const transport = new HttpClientTransport(
248+
new URL("http://localhost:3000/mcp")
249+
);
250+
await client.connect(transport);
251+
```
252+
253+
</Tab>
254+
<Tab title="Python">
242255

243256
```python
244257
async with http_client("http://localhost:8000/mcp") as transport:
@@ -247,7 +260,6 @@ Use Streamable HTTP when:
247260
```
248261

249262
</Tab>
250-
251263
</Tabs>
252264

253265
#### Session Management
@@ -325,8 +337,10 @@ Previously used when:
325337

326338
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.
327339

340+
#### Server
341+
328342
<Tabs>
329-
<Tab title="TypeScript (Server)">
343+
<Tab title="TypeScript">
330344

331345
```typescript
332346
import express from "express";
@@ -357,24 +371,7 @@ The deprecated SSE transport had similar security considerations to Streamable H
357371
```
358372

359373
</Tab>
360-
<Tab title="TypeScript (Client)">
361-
362-
```typescript
363-
const client = new Client({
364-
name: "example-client",
365-
version: "1.0.0"
366-
}, {
367-
capabilities: {}
368-
});
369-
370-
const transport = new SSEClientTransport(
371-
new URL("http://localhost:3000/sse")
372-
);
373-
await client.connect(transport);
374-
```
375-
376-
</Tab>
377-
<Tab title="Python (Server)">
374+
<Tab title="Python">
378375

379376
```python
380377
from mcp.server.sse import SseServerTransport
@@ -400,7 +397,29 @@ The deprecated SSE transport had similar security considerations to Streamable H
400397
```
401398

402399
</Tab>
403-
<Tab title="Python (Client)">
400+
</Tabs>
401+
402+
#### Client
403+
404+
<Tabs>
405+
<Tab title="TypeScript">
406+
407+
```typescript
408+
const client = new Client({
409+
name: "example-client",
410+
version: "1.0.0"
411+
}, {
412+
capabilities: {}
413+
});
414+
415+
const transport = new SSEClientTransport(
416+
new URL("http://localhost:3000/sse")
417+
);
418+
await client.connect(transport);
419+
```
420+
421+
</Tab>
422+
<Tab title="Python">
404423

405424
```python
406425
async with sse_client("http://localhost:8000/sse") as streams:
@@ -409,7 +428,6 @@ The deprecated SSE transport had similar security considerations to Streamable H
409428
```
410429

411430
</Tab>
412-
413431
</Tabs>
414432

415433
## Custom Transports

0 commit comments

Comments
 (0)