typescript-sdk/examples/client
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Luis Reche 6bec24a14c
fix: validate clientMetadataUrl at construction time (fail-fast) (#1653)
Co-authored-by: Luis <reche@Luiss-MacBook-Pro.local>
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
2026-04-14 10:17:01 +00:00
..
src fix: validate clientMetadataUrl at construction time (fail-fast) (#1653) 2026-04-14 10:17:01 +00:00
eslint.config.mjs [v2] Мonorepo, sdk-client, sdk-server, sdk-core package split (#1279) 2025-12-19 14:19:02 +01:00
package.json remove references to npm, clean up package manager usage in workspaces (#1534) 2026-03-02 12:13:44 +00:00
README.md [v2] Мonorepo, sdk-client, sdk-server, sdk-core package split (#1279) 2025-12-19 14:19:02 +01:00
tsconfig.json v2: limit public exports (#1680) 2026-03-25 20:25:01 +00:00
tsdown.config.ts [v2] Мonorepo, sdk-client, sdk-server, sdk-core package split (#1279) 2025-12-19 14:19:02 +01:00
vitest.config.js [v2] Мonorepo, sdk-client, sdk-server, sdk-core package split (#1279) 2025-12-19 14:19:02 +01:00

MCP TypeScript SDK Examples (Client)

This directory contains runnable MCP client examples built with @modelcontextprotocol/client.

For server examples, see ../server/README.md. For guided docs, see ../../docs/client.md.

Running examples

From the repo root:

pnpm install
pnpm --filter @modelcontextprotocol/examples-client exec tsx src/simpleStreamableHttp.ts

Or, from within this package:

cd examples/client
pnpm tsx src/simpleStreamableHttp.ts

Most clients expect a server to be running. Start one from ../server/README.md (for example src/simpleStreamableHttp.ts in examples/server).

Example index

Scenario Description File
Interactive Streamable HTTP client CLI client that exercises tools/resources/prompts, notifications, elicitation, and tasks. src/simpleStreamableHttp.ts
Backwards-compatible client (Streamable HTTP → SSE) Tries Streamable HTTP first, falls back to legacy SSE on 4xx responses. src/streamableHttpWithSseFallbackClient.ts
SSE polling client (legacy) Polls a legacy HTTP+SSE server and demonstrates notification handling. src/ssePollingClient.ts
Parallel tool calls Runs multiple tool calls in parallel. src/parallelToolCallsClient.ts
Multiple clients in parallel Connects multiple clients concurrently to the same server. src/multipleClientsParallel.ts
OAuth client (interactive) OAuth-enabled client (dynamic registration, auth flow). src/simpleOAuthClient.ts
OAuth provider helper Demonstrates reusable OAuth providers. src/simpleOAuthClientProvider.ts
Client credentials (M2M) Machine-to-machine OAuth client credentials example. src/simpleClientCredentials.ts
URL elicitation client Drives URL-mode elicitation flows (sensitive input in a browser). src/elicitationUrlExample.ts
Task interactive client Demonstrates task-based execution + interactive server→client requests. src/simpleTaskInteractiveClient.ts

URL elicitation example (server + client)

Run the server first:

pnpm --filter @modelcontextprotocol/examples-server exec tsx src/elicitationUrlExample.ts

Then run the client:

pnpm --filter @modelcontextprotocol/examples-client exec tsx src/elicitationUrlExample.ts