The SDK provides a high-level Client class that connects to MCP servers over different transports:
StdioClientTransport – for local processes you spawn.StreamableHTTPClientTransport – for remote HTTP servers.SSEClientTransport – for legacy HTTP+SSE servers (deprecated).Runnable client examples live under:
simpleStreamableHttp.tsstreamableHttpWithSseFallbackClient.tsssePollingClient.tsmultipleClientsParallel.tsparallelToolCallsClient.tsA typical flow:
Client with name, version and capabilities.client.connect(transport).listTools, callToollistPrompts, getPromptlistResources, readResourceSee simpleStreamableHttp.ts for an interactive CLI client that exercises these methods and shows how to handle notifications, elicitation and tasks.
To support both modern Streamable HTTP and legacy SSE servers, use a client that:
StreamableHTTPClientTransport.SSEClientTransport on a 4xx response.Runnable example:
For OAuth-secured MCP servers, the client auth module exposes:
ClientCredentialsProviderPrivateKeyJwtProviderStaticPrivateKeyJwtProviderExamples:
simpleOAuthClient.tssimpleOAuthClientProvider.tssimpleClientCredentials.tsdemoInMemoryOAuthProvider.ts (tests live under examples/shared/test/demoInMemoryOAuthProvider.test.ts)These examples show how to: