typescript-sdk/examples/subscriptions
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Felix Weinberger 1823aae891
Implement MCP 2026-07-28 (#2286)
Co-authored-by: Matt <77928207+mattzcarey@users.noreply.github.com>
Co-authored-by: Konstantin Konstantinov <KKonstantinov@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-06-26 14:01:10 +01:00
..
client.ts Implement MCP 2026-07-28 (#2286) 2026-06-26 14:01:10 +01:00
package.json Implement MCP 2026-07-28 (#2286) 2026-06-26 14:01:10 +01:00
README.md Implement MCP 2026-07-28 (#2286) 2026-06-26 14:01:10 +01:00
server.ts Implement MCP 2026-07-28 (#2286) 2026-06-26 14:01:10 +01:00

subscriptions

subscriptions/listen change-notification streams (protocol revision 2026-07-28). The server publishes tools/list_changed; the client receives it both via the auto-opened stream (ClientOptions.listChanged, the same option a 2025-era client sets) and a manual client.listen() call.

The publish surface differs by entry: over HTTP (createMcpHandler) the example calls handler.notify.toolsChanged() on the cross-request ServerEventBus; over stdio (serveStdio) it toggles a RegisteredTool on the pinned instance, whose tools/list_changed the entry's listen router fans onto every open subscription.

# stdio (the client spawns the server itself):
pnpm tsx examples/subscriptions/client.ts

# Streamable HTTP (two terminals):
pnpm tsx examples/subscriptions/server.ts --http --port 3000
pnpm tsx examples/subscriptions/client.ts --http http://127.0.0.1:3000/