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
Dissolve Running your server section into Server overview
The `Running your server` section sat awkwardly between Transports and
DNS rebinding protection, containing no code and significant overlap
with the overview (duplicate `simpleStreamableHttp.ts` link, duplicate
Transports spec link, a 3-step list that recapped what the Transports
section already showed in code).
Rework the overview into a concise roadmap:
- Replace the bullet-list of transport choices and example links with a
3-step numbered list that names `McpServer`, links to both transport
sections, and forward-links to tools/resources/prompts
- Fold the "start from `simpleStreamableHttp.ts` and strip what you
don't need" advice into the overview's closing paragraph
- Tease stateless and JSON-response-mode variants with a sentence
pointing to Transports, rather than duplicating the example links
- Add section-specific spec links to NOTE callouts (Tools, Resources,
Prompts) following the established pattern
- Fix the Streamable HTTP spec link to use the standard NOTE callout
format instead of a bare URL in body text
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/server.md
+16-22Lines changed: 16 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,15 @@ title: Server
4
4
5
5
## Server overview
6
6
7
-
This SDK lets you build MCP servers in TypeScript and connect them to different transports. For most use cases you will use {@linkcode@modelcontextprotocol/server!server/mcp.McpServer | McpServer} from `@modelcontextprotocol/server` and choose one of:
7
+
This guide covers SDK usage for building MCP servers in TypeScript. For protocol-level details and message formats, see the [MCP specification](https://modelcontextprotocol.io/specification/latest/).
1. Create an {@linkcode@modelcontextprotocol/server!server/mcp.McpServer | McpServer} and register your [tools, resources, and prompts](#tools-resources-and-prompts).
12
+
2. Create a transport — [Streamable HTTP](#streamable-http) for remote servers or [stdio](#stdio) for local, process‑spawned integrations.
13
+
3. Wire the transport into your HTTP framework (or use stdio directly) and call `server.connect(transport)`.
13
14
14
-
-[`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts) – feature‑rich Streamable HTTP server
15
-
-[`jsonResponseStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/jsonResponseStreamableHttp.ts) – Streamable HTTP with JSON response mode
16
-
-[`simpleStatelessStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStatelessStreamableHttp.ts) – stateless Streamable HTTP server
15
+
The sections below cover each of these. For a feature‑rich starting point, see [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts) — remove what you don't need and register your own tools, resources, and prompts. For stateless or JSON‑response‑mode alternatives, see the examples linked in [Transports](#transports) below.
> For full runnable examples, see [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts) (sessions, logging, tasks, elicitation, auth hooks), [`jsonResponseStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/jsonResponseStreamableHttp.ts) (`enableJsonResponse: true`, no SSE), and [`standaloneSseWithGetStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/standaloneSseWithGetStreamableHttp.ts) (notifications with Streamable HTTP GET + SSE).
43
-
44
-
See the MCP spec for full transport details: `https://modelcontextprotocol.io/specification/2025-11-25/basic/transports`
42
+
>
43
+
> For protocol details, see [Transports](https://modelcontextprotocol.io/specification/latest/basic/transports) in the MCP specification.
45
44
46
45
#### Stateless vs stateful sessions
47
46
@@ -93,19 +92,6 @@ const transport = new StdioServerTransport();
93
92
awaitserver.connect(transport);
94
93
```
95
94
96
-
## Running your server
97
-
98
-
For a minimal "getting started" experience:
99
-
100
-
1. Register your tools, resources, and prompts (see [below](#tools-resources-and-prompts)).
101
-
2. Create a transport and connect it to your server.
102
-
3. Wire the transport into your HTTP framework or use stdio.
103
-
104
-
For more detailed patterns (stateless vs stateful, JSON response mode, CORS, DNS rebind protection), see the examples and the MCP spec sections on transports.
105
-
106
-
> [!NOTE]
107
-
> For a feature‑rich starting point, see [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts). Remove features you do not need (tasks, advanced logging, OAuth, etc.) and register your own tools, resources and prompts.
108
-
109
95
## DNS rebinding protection
110
96
111
97
MCP servers running on localhost are vulnerable to DNS rebinding attacks. Use `createMcpExpressApp()` from `@modelcontextprotocol/express` to create an Express app with DNS rebinding protection enabled by default:
@@ -162,6 +148,8 @@ server.registerTool(
162
148
163
149
> [!NOTE]
164
150
> For full runnable examples, see [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts) and [`toolWithSampleServer.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/toolWithSampleServer.ts).
151
+
>
152
+
> For protocol details, see [Tools](https://modelcontextprotocol.io/specification/latest/server/tools) in the MCP specification.
165
153
166
154
#### `ResourceLink` outputs
167
155
@@ -226,6 +214,8 @@ server.registerTool(
226
214
227
215
> [!NOTE]
228
216
> For logging in a full server, see [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts) and [`jsonResponseStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/jsonResponseStreamableHttp.ts).
217
+
>
218
+
> For protocol details, see [Logging](https://modelcontextprotocol.io/specification/latest/server/utilities/logging) in the MCP specification.
229
219
230
220
### Resources
231
221
@@ -279,6 +269,8 @@ server.registerResource(
279
269
280
270
> [!NOTE]
281
271
> For full runnable examples of resources, see [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts).
272
+
>
273
+
> For protocol details, see [Resources](https://modelcontextprotocol.io/specification/latest/server/resources) in the MCP specification.
282
274
283
275
### Prompts
284
276
@@ -312,6 +304,8 @@ server.registerPrompt(
312
304
313
305
> [!NOTE]
314
306
> For prompts integrated into a full server, see [`simpleStreamableHttp.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleStreamableHttp.ts).
307
+
>
308
+
> For protocol details, see [Prompts](https://modelcontextprotocol.io/specification/latest/server/prompts) in the MCP specification.
0 commit comments