Skip to content

Commit fd01ec3

Browse files
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>
1 parent 508f86d commit fd01ec3

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

docs/server.md

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ title: Server
44

55
## Server overview
66

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/).
88

9-
- **Streamable HTTP** (for remote servers)
10-
- **stdio** (for local, process‑spawned integrations)
9+
Building a server takes three steps:
1110

12-
For a complete, runnable example server, see:
11+
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)`.
1314

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.
1716

1817
## Transports
1918

@@ -40,8 +39,8 @@ await server.connect(transport);
4039

4140
> [!NOTE]
4241
> 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.
4544
4645
#### Stateless vs stateful sessions
4746

@@ -93,19 +92,6 @@ const transport = new StdioServerTransport();
9392
await server.connect(transport);
9493
```
9594

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-
10995
## DNS rebinding protection
11096

11197
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(
162148

163149
> [!NOTE]
164150
> 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.
165153
166154
#### `ResourceLink` outputs
167155

@@ -226,6 +214,8 @@ server.registerTool(
226214

227215
> [!NOTE]
228216
> 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.
229219
230220
### Resources
231221

@@ -279,6 +269,8 @@ server.registerResource(
279269

280270
> [!NOTE]
281271
> 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.
282274
283275
### Prompts
284276

@@ -312,6 +304,8 @@ server.registerPrompt(
312304

313305
> [!NOTE]
314306
> 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.
315309
316310
### Completions
317311

0 commit comments

Comments
 (0)