package
Model Context Protocol implementation for TypeScript
npm install @modelcontextprotocol/sdkGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
This is v1.x of the MCP TypeScript SDK, the maintenance line. It implements the MCP spec up to 2025-11-25. Support for the 2026-07-28 spec is not planned for v1.x: it is in v2, the current stable release, which ships as separate packages, and . See the and the .
pcarleton
paul@modelcontextprotocol.io
@modelcontextprotocol/serverStaying on v1.x? It continues to receive bug fixes and security updates for at least six months after the v2 release (2026-07-27). The v1 documentation is at https://ts.sdk.modelcontextprotocol.io/.
The Model Context Protocol allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction. This TypeScript SDK implements the 2025-11-25 MCP specification, making it easy to:
npm install @modelcontextprotocol/sdk zodThis SDK has a required peer dependency on zod for schema validation. The SDK internally imports from zod/v4, but maintains backwards compatibility with projects using Zod v3.25 or later. You can use either API in your code by importing from zod/v3 or zod/v4:
To see the SDK in action end-to-end, start from the runnable examples in src/examples:
Install dependencies (from the SDK repo root):
npm installRun the example Streamable HTTP server:
npx tsx src/examples/server/simpleStreamableHttp.tsRun the interactive client in another terminal:
npx tsx src/examples/client/simpleStreamableHttp.tsThis pair of examples demonstrates tools, resources, prompts, sampling, elicitation, tasks and logging. For a guided walkthrough and variations (stateless servers, JSON-only responses, SSE compatibility, OAuth, etc.), see docs/server.md and docs/client.md.
An MCP server is typically created with McpServer and connected to a transport such as Streamable HTTP or stdio. The SDK supports:
Runnable server examples live under src/examples/server and are documented in docs/server.md.
The detailed APIs, including ResourceTemplate, completions, and display-name metadata, are covered in docs/server.md, with runnable implementations in simpleStreamableHttp.ts.
The SDK includes higher-level capabilities for richer workflows:
Conceptual overviews and links to runnable examples are in:
Key example servers include:
The high-level Client class connects to MCP servers over different transports and exposes helpers like listTools, callTool, listResources, readResource, listPrompts, and getPrompt.
Runnable clients live under src/examples/client and are described in docs/client.md, including:
simpleStreamableHttp.ts)streamableHttpWithSseFallbackClient.ts)Some parts of the SDK (for example, JWT-based client authentication in auth-extensions.ts via jose) rely on the Web Crypto API exposed as globalThis.crypto.
See docs/faq.md for details on supported Node.js versions and how to polyfill globalThis.crypto when running on older Node.js runtimes.
The SDK ships runnable examples under src/examples. Use these tables to find the scenario you care about and jump straight to the corresponding code and docs.
| Scenario | Description | Example file(s) | Related docs |
|---|---|---|---|
| Streamable HTTP server (stateful) | Feature-rich server with tools, resources, prompts, logging, tasks, sampling, and optional OAuth. | simpleStreamableHttp.ts | server.md, capabilities.md |
| Streamable HTTP server (stateless) | No session tracking; good for simple API-style servers. | simpleStatelessStreamableHttp.ts | server.md |
| JSON response mode (no SSE) | Streamable HTTP with JSON responses only and limited notifications. | jsonResponseStreamableHttp.ts | server.md |
| Server notifications over Streamable HTTP | Demonstrates server-initiated notifications using SSE with Streamable HTTP. | standaloneSseWithGetStreamableHttp.ts | server.md |
| Deprecated HTTP+SSE server | Legacy HTTP+SSE transport for backwards-compatibility testing. | simpleSseServer.ts | server.md |
| Backwards-compatible server (Streamable HTTP + SSE) | Single server that supports both Streamable HTTP and legacy SSE clients. | sseAndStreamableHttpCompatibleServer.ts | server.md |
| Form elicitation server | Uses form elicitation to collect non-sensitive user input. | elicitationFormExample.ts | capabilities.md |
| URL elicitation server | Demonstrates URL-mode elicitation in an OAuth-protected server. | elicitationUrlExample.ts | capabilities.md |
| Sampling and tasks server | Combines tools, logging, sampling, and experimental task-based execution. | toolWithSampleServer.ts | capabilities.md |
| OAuth demo authorization server | In-memory OAuth provider used with the example servers. | demoInMemoryOAuthProvider.ts | server.md |
| Scenario | Description | Example file(s) | Related docs |
|---|---|---|---|
| Interactive Streamable HTTP client | CLI client that exercises tools, resources, prompts, elicitation, and tasks. | simpleStreamableHttp.ts | client.md |
| Backwards-compatible client (Streamable HTTP → SSE) | Tries Streamable HTTP first, then falls back to SSE on 4xx responses. | streamableHttpWithSseFallbackClient.ts | client.md, server.md |
| SSE polling client | Polls a legacy SSE server and demonstrates notification handling. | ssePollingClient.ts | client.md |
| Parallel tool calls client | Shows how to run multiple tool calls in parallel. | parallelToolCallsClient.ts | client.md |
| Multiple clients in parallel | Demonstrates connecting multiple clients concurrently to the same server. | multipleClientsParallel.ts | client.md |
| OAuth clients | Examples of client_credentials (basic and private_key_jwt) and reusable providers. | simpleOAuthClient.ts, simpleOAuthClientProvider.ts, simpleClientCredentials.ts | client.md |
| URL elicitation client | Works with the URL elicitation server to drive secure browser flows. | elicitationUrlExample.ts | capabilities.md |
Shared utilities:
inMemoryEventStore.ts (see server.md).For more details on how to run these examples (including recommended commands and deployment diagrams), see src/examples/README.md.
Issues and pull requests are welcome on GitHub at https://github.com/modelcontextprotocol/typescript-sdk.
This project is licensed under the MIT License—see the LICENSE file for details.
Estimated unpacked size across 61 packages.
15.6 MB+
Includes dependencies.
^7.0.5
7.0.6
^3.0.2
5.1.5
^1.0.5
3.1.1
^5.0.0
6.0.0
^1.19.9 || ^2.0.5
2.1.8
^8.0.2
9.0.0
^3.0.0
4.1.3
^8.2.1
8.7.4
^3.25.1
3.25.2