MCP TypeScript SDK Examples (Client)

December 19, 2025 · View on GitHub

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

ScenarioDescriptionFile
Interactive Streamable HTTP clientCLI 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 callsRuns multiple tool calls in parallel.src/parallelToolCallsClient.ts
Multiple clients in parallelConnects 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 helperDemonstrates reusable OAuth providers.src/simpleOAuthClientProvider.ts
Client credentials (M2M)Machine-to-machine OAuth client credentials example.src/simpleClientCredentials.ts
URL elicitation clientDrives URL-mode elicitation flows (sensitive input in a browser).src/elicitationUrlExample.ts
Task interactive clientDemonstrates 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