Skip to content

Conversation

@jonathanhefner
Copy link
Member

ℹ️ This is based on top of #1487


  • Type-checked code snippets: All inline code blocks now pull from a new examples/server/src/serverGuide.examples.ts file via the snippet sync system, so every example in the guide is compiled and stays in sync with the SDK.
  • Remove deprecated SSE content: Dropped vestigial references to the deprecated HTTP+SSE transport and the backwards-compatibility section (SSE → Streamable HTTP migration is already covered in the migration guide).
  • Remove client-side content: Moved client-focused sections (display names, completions client usage, SSE fallback client) out of the server guide; these belong in the client guide.
  • Add {@linkcode} cross-references: Key types and methods (McpServer, registerTool, ResourceTemplate, StdioServerTransport, completable, ServerContext) now link to API docs.
  • New sections: Added coverage for ResourceLink tool outputs, server-side logging (ctx.mcpReq.log), dynamic resources with ResourceTemplate, completable prompt arguments, JSON response mode, and stdio transport — all with type-checked examples.
  • "More server features" reference table: Replaces scattered sections (multi-node deployment, backwards compatibility, etc.) with a single table linking to runnable examples and spec/guide pages for advanced features like resumability, CORS, elicitation, sampling, tasks, and multi-node deployment.

I still want to improve this document more in the future, but I think this is in a mergeable state.

jonathanhefner and others added 7 commits February 11, 2026 17:23
JSDoc `@example` code blocks were previously inlined and not
type-checked, meaning they could silently drift from the actual API.
This adds a `scripts/sync-snippets.ts` script (`pnpm sync:snippets`)
that extracts code from co-located `.examples.ts` files — using
`//#region` markers — and syncs them into JSDoc `@example` fences and
markdown files.

The script supports a `--check` mode (wired into `lint:all`) to catch
drift in CI. Code fences use a `source="./file.examples.ts#regionName"`
attribute to reference their source of truth.

Includes `.examples.ts` companion files for:

- `packages/core`: `SdkError`, validation providers
  (`AjvJsonSchemaValidator`, `CfWorkerJsonSchemaValidator`,
  `jsonSchemaValidator`), and module-level validator examples
- `packages/client`: `Client` options, `fetchToken`, auth extensions
  (`createPrivateKeyJwtAuth`, `ClientCredentialsProvider`,
  `PrivateKeyJwtProvider`), client middleware (`applyMiddlewares`,
  `createMiddleware`), and experimental task streaming
- `packages/server`: `hostHeaderValidation` response helper
- `packages/middleware/express`: `createMcpExpressApp` and host header
  validation middleware

Also removes the duplicate `@example` from `Protocol.requestStream()`
(now covered by `ExperimentalClientTasks.requestStream()`), adds ESLint
overrides for `.examples.ts` files (`no-unused-vars`, `no-console`), and
updates `CLAUDE.md` with snippet conventions.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Use the `sync-snippets` mechanism to inject type-checked code from
`serverGuide.examples.ts` into `docs/server.md`.

10 snippet regions covering transports, tools, resources, prompts,
`completable()`, `ResourceLink`, `ResourceTemplate`, and DNS rebinding.

Fixes three bugs in existing illustrative snippets where `inputSchema`,
`outputSchema`, and `argsSchema` used raw objects instead of
`z.object()`.

Removes four broken links to `simpleSseServer.ts` and
`sseAndStreamableHttpCompatibleServer.ts` (deleted in v2 when
`SSEServerTransport` was removed). Updates the deprecated SSE section to
reflect this. Adds `> [!NOTE]` callouts linking to full runnable
examples alongside each inline snippet.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
`docs/server.md`

The SSE-only server transport was removed from the SDK, but the server
guide still had subtle language implying it existed as an alternative:

- "recommended for remote servers" → "for remote servers" (it is the
  only remote transport, not merely recommended)
- "modern, fully featured transport" → "HTTP‑based transport" (no older
  alternative to contrast against)
- Removed the "Deprecated HTTP + SSE" section entirely — this is a
  client‑side concern already covered in `docs/client.md`
- Removed the "Backwards compatibility" section — also a client‑side
  concern already covered in `docs/client.md`

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The Completions section included a paragraph about `client.complete()`
and a link to a client example — replaced with a brief cross-reference
to the Client guide. The "Display names and metadata" subsection only
described the client-side `getDisplayName` helper; every inline example
already demonstrates the `title` field, so the section was redundant for
server authors. Dropped it entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Replace plain backtick code references with TypeDoc `{@linkcode}` links
for `McpServer`, `McpServer#registerTool`, `ResourceTemplate`, and
`completable()`. Also add backtick formatting to the `ResourceLink`
heading. These link to the `@modelcontextprotocol/server` package using
fully-qualified module paths required by TypeDoc's
`entryPointStrategy: "packages"` mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Expand `docs/server.md` with three new inline sections:

- `#### JSON response mode` — `enableJsonResponse: true` transport
  option
- `### stdio` — `StdioServerTransport` pattern with `{@linkcode}`
- `#### Logging` — `ctx.mcpReq.log()` in tool handlers, with `logging`
  capability snippet

Add a "More server features" table at the end of `docs/server.md`
linking eight additional capabilities (elicitation, sampling, tool
annotations, Web Standard transport, session management, resumability,
CORS, tasks) to runnable examples and `docs/capabilities.md`.

Demote "Stateless vs stateful sessions" and "JSON response mode" from
`h3` to `h4` so they nest under the `### Streamable HTTP` parent.

Add three new synced regions to `serverGuide.examples.ts`:
`logging_capability`, `registerTool_logging`,
`streamableHttp_jsonResponse`, `stdio_basic`.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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) <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Feb 12, 2026

⚠️ No Changeset found

Latest commit: 6c9dbfe

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 12, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 6c9dbfe

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