Skip to content

Rewrite docs/server.md as a code-heavy, prose-light how-to guide#1552

Draft
jonathanhefner wants to merge 4 commits intomodelcontextprotocol:mainfrom
jonathanhefner:server-how-to
Draft

Rewrite docs/server.md as a code-heavy, prose-light how-to guide#1552
jonathanhefner wants to merge 4 commits intomodelcontextprotocol:mainfrom
jonathanhefner:server-how-to

Conversation

@jonathanhefner
Copy link
Member

ℹ️ This is based on top of #1551.

Repositions the server guide from a mixed how-to/reference/overview document into a focused how-to guide that leads with type-checked code snippets and delegates conceptual content to the MCP overview docs on modelcontextprotocol.io.

Key changes to docs/server.md:

  • Rename heading to "Building MCP servers" (task framing)
  • Add snippet-synced imports block so readers know which packages to import
  • Cross-reference links now point to MCP overview/learn pages (server-concepts, client-concepts, architecture) instead of the specification, except for Logging and Tasks which have no dedicated learn pages
  • Replace > [!NOTE] callout blocks with inline example links
  • Add decision guidance to Resources and Prompts sections ("use a resource when the client needs to read data; use a tool when it needs to do something")
  • Add tool annotations snippet (destructiveHint, idempotentHint)
  • Add error handling subsection under Tools showing the isError: true pattern, with notes on auto-catch and output schema skip behavior
  • Add shutdown section with SIGINT handling for both multi-session HTTP (including httpServer.close()) and stdio servers
  • Condense three Streamable HTTP variant subsections into one snippet plus an Options paragraph
  • Promote Tools, Resources, Prompts to top-level sections
  • Replace "More server features" table with See Also list and Additional Examples table
  • Update docs/documents.md description to match

New example regions in serverGuide.examples.ts:

  • imports — synced into the Imports section
  • registerTool_annotations — tool with destructiveHint
  • registerTool_errorHandling — try/catch with isError: true
  • shutdown_statefulHttp — SIGINT + httpServer.close() + transport cleanup
  • shutdown_stdio — SIGINT + server.close()

@changeset-bot
Copy link

changeset-bot bot commented Feb 17, 2026

⚠️ No Changeset found

Latest commit: d4d8c64

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 17, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1552

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1552

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1552

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1552

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1552

commit: d4d8c64

jonathanhefner and others added 4 commits February 18, 2026 13:39
Restructure the document: action-oriented H1, Imports section,
section-opener concept links to the MCP overview docs (not the
specification), inline example-file references instead of `> [!NOTE]`
callouts, and a trailing "See also" section with cross-links plus an
"Additional examples" table.

New sections: Imports, Disconnecting (`terminateSession()` + `close()`),
Subscribing to resource changes
(`subscribeResource`/`unsubscribeResource`), Roots (`roots/list`
handler, `sendRootsListChanged()`), Error handling (tool errors vs
protocol errors, connection lifecycle callbacks, timeouts), and
`setLoggingLevel()` folded into Notifications.

All new code examples are type-checked regions in
`clientGuide.examples.ts` and synced via `pnpm sync:snippets`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Expand the client guide with four new topics and their companion
`.examples.ts` snippets:

- Server instructions: retrieving `getInstructions()` and folding it
  into a system prompt
- Pagination: `listTools()`, `listResources()`, and `listPrompts()`
  examples now loop on `nextCursor` to collect all pages
- Structured tool output: `structuredContent` for machine-readable
  results alongside LLM-facing `content`
- Progress tracking: `onprogress`, `resetTimeoutOnProgress`, and
  `maxTotalTimeout` options for long-running tool calls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Repositions the server guide from a mixed how-to/reference/overview
document into a focused how-to guide that leads with type-checked code
snippets and delegates conceptual content to the MCP overview docs on
modelcontextprotocol.io.

Key changes to `docs/server.md`:

- Rename heading to "Building MCP servers" (task framing)
- Add snippet-synced imports block so readers know which packages to
  import
- Cross-reference links now point to MCP overview/learn pages
  (server-concepts, client-concepts, architecture) instead of the
  specification, except for Logging and Tasks which have no dedicated
  learn pages
- Replace `> [!NOTE]` callout blocks with inline example links
- Add decision guidance to Resources and Prompts sections ("use a
  resource when the client needs to read data; use a tool when it needs
  to do something")
- Add tool annotations snippet (`destructiveHint`, `idempotentHint`)
- Add error handling subsection under Tools showing the `isError: true`
  pattern, with notes on auto-catch and output schema skip behavior
- Add shutdown section with SIGINT handling for both multi-session HTTP
  (including `httpServer.close()`) and stdio servers
- Condense three Streamable HTTP variant subsections into one snippet
  plus an Options paragraph
- Promote Tools, Resources, Prompts to top-level sections
- Replace "More server features" table with See Also list and Additional
  Examples table
- Update `docs/documents.md` description to match

New example regions in `serverGuide.examples.ts`:

- `imports` — synced into the Imports section
- `registerTool_annotations` — tool with `destructiveHint`
- `registerTool_errorHandling` — try/catch with `isError: true`
- `shutdown_statefulHttp` — SIGINT + `httpServer.close()` + transport
  cleanup
- `shutdown_stdio` — SIGINT + `server.close()`

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
`docs/server.md`

Three gaps identified in the server how-to guide, each with a
type-checked example in `serverGuide.examples.ts`:

- **Server instructions** — `McpServer` constructor `instructions`
  option for cross-tool relationships, workflow patterns, and
  constraints. Placed between Transports and Tools.
- **Progress** — sending `notifications/progress` via
  `ctx.mcpReq.notify()` during long-running tool execution, guarded by
  `progressToken`. Placed between Logging and Server-initiated requests.
- **Roots** — calling `server.server.listRoots()` to discover the
  client's workspace directories. Placed under Server-initiated requests
  alongside Sampling and Elicitation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments