Skip to content

Conversation

@jonathanhefner
Copy link
Member

ℹ️ This is based on top of #1487


Create companion .examples.ts files for JSDoc @example tags:

  • mcp.examples.tsMcpServer, registerTool(), registerResource(), registerPrompt(), connect(), sendLoggingMessage(), and tool logging
  • stdio.examples.tsStdioServerTransport
  • completable.examples.tscompletable() shown in prompt context
  • streamableHttp.examples.tsWebStandardStreamableHTTPServerTransport (stateful, stateless, Hono, Workers)
  • node/streamableHttp.examples.tsNodeStreamableHTTPServerTransport (stateful, stateless, Express)

Add @example tags (with titles) to the source files for McpServer, StdioServerTransport, completable(), and both Streamable HTTP transport classes. Prose bullet lists on the transport classes are placed before @example block tags so TypeDoc renders them in the description section.

jonathanhefner and others added 2 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) <noreply@anthropic.com>
Create companion `.examples.ts` files for JSDoc `@example` tags:

- `mcp.examples.ts` — `McpServer`, `registerTool()`,
  `registerResource()`, `registerPrompt()`, `connect()`,
  `sendLoggingMessage()`, and tool logging
- `stdio.examples.ts` — `StdioServerTransport`
- `completable.examples.ts` — `completable()` shown in prompt context
- `streamableHttp.examples.ts` —
  `WebStandardStreamableHTTPServerTransport` (stateful, stateless, Hono,
  Workers)
- `node/streamableHttp.examples.ts` —
  `NodeStreamableHTTPServerTransport` (stateful, stateless, Express)

Add `@example` tags (with titles) to the source files for `McpServer`,
`StdioServerTransport`, `completable()`, and both Streamable HTTP
transport classes. Prose bullet lists on the transport classes are
placed before `@example` block tags so TypeDoc renders them in the
description section.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Feb 12, 2026

⚠️ No Changeset found

Latest commit: 63b3560

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@1524

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 63b3560

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