{"name":"@modelcontextprotocol/sdk","version":"1.24.3","keywords":["modelcontextprotocol","mcp"],"author":{"url":"https://anthropic.com","name":"Anthropic, PBC"},"license":"MIT","_id":"@modelcontextprotocol/sdk@1.24.3","maintainers":[{"name":"jspahrsummers","email":"justin@jspahrsummers.com"},{"name":"pcarleton","email":"paulcarletonjr@gmail.com"},{"name":"thedsp","email":"experimentalworks@gmail.com"},{"name":"ashwin-ant","email":"ashwin@anthropic.com"}],"homepage":"https://modelcontextprotocol.io","bugs":{"url":"https://github.com/modelcontextprotocol/typescript-sdk/issues"},"dist":{"shasum":"81a3fcc919cb4ce8630e2bcecf59759176eb331a","tarball":"http://registry-npm.ywwl.com/@modelcontextprotocol/sdk/download/@modelcontextprotocol/sdk-1.24.3.tgz","fileCount":653,"integrity":"sha512-YgSHW29fuzKKAHTGe9zjNoo+yF8KaQPzDC2W9Pv41E7/57IfY+AMGJ/aDFlgTLcVVELoggKE4syABCE75u3NCw==","signatures":[{"sig":"MEQCIDZqbxC5LLxn0UEuK0sFZddH5waJNn2tvMF0XZjTDSnaAiAG1lKlBJOUgqo3U5sR/EBiUUJfClBRpUwd1fR+Ue3gpQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@modelcontextprotocol%2fsdk@1.24.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":4050618,"size":539204,"noattachment":false,"key":"/@modelcontextprotocol/sdk/-/@modelcontextprotocol/sdk-1.24.3.tgz"},"type":"module","engines":{"node":">=18"},"exports":{".":{"import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"./*":{"import":"./dist/esm/*","require":"./dist/cjs/*"},"./client":{"import":"./dist/esm/client/index.js","require":"./dist/cjs/client/index.js"},"./server":{"import":"./dist/esm/server/index.js","require":"./dist/cjs/server/index.js"},"./validation":{"import":"./dist/esm/validation/index.js","require":"./dist/cjs/validation/index.js"},"./experimental":{"import":"./dist/esm/experimental/index.js","require":"./dist/cjs/experimental/index.js"},"./validation/ajv":{"import":"./dist/esm/validation/ajv-provider.js","require":"./dist/cjs/validation/ajv-provider.js"},"./experimental/tasks":{"import":"./dist/esm/experimental/tasks/index.js","require":"./dist/cjs/experimental/tasks/index.js"},"./validation/cfworker":{"import":"./dist/esm/validation/cfworker-provider.js","require":"./dist/cjs/validation/cfworker-provider.js"}},"gitHead":"724fe6eefeeb7f71328bc43c223fc9abd3df491e","scripts":{"lint":"eslint src/ && prettier --check .","test":"vitest run","build":"npm run build:esm && npm run build:cjs","check":"npm run typecheck && npm run lint","start":"npm run server","client":"tsx scripts/cli.ts client","server":"tsx watch --clear-screen=false scripts/cli.ts server","prepack":"npm run build:esm && npm run build:cjs","lint:fix":"eslint src/ --fix && prettier --write .","build:cjs":"mkdir -p dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json && tsc -p tsconfig.cjs.json","build:esm":"mkdir -p dist/esm && echo '{\"type\": \"module\"}' > dist/esm/package.json && tsc -p tsconfig.prod.json","typecheck":"tsgo --noEmit","test:watch":"vitest","build:cjs:w":"npm run build:cjs -- -w","build:esm:w":"npm run build:esm -- -w","fetch:spec-types":"tsx scripts/fetch-spec-types.ts","examples:simple-server:w":"tsx --watch src/examples/server/simpleStreamableHttp.ts --oauth"},"_npmUser":{"name":"pcarleton","email":"paulcarletonjr@gmail.com"},"repository":{"url":"git+https://github.com/modelcontextprotocol/typescript-sdk.git","type":"git"},"_npmVersion":"11.6.2","description":"Model Context Protocol implementation for TypeScript","directories":{},"resolutions":{"strip-ansi":"6.0.1"},"_nodeVersion":"24.11.1","dependencies":{"ajv":"^8.17.1","zod":"^3.25 || ^4.0","cors":"^2.8.5","jose":"^6.1.1","express":"^5.0.1","raw-body":"^3.0.0","ajv-formats":"^3.0.1","cross-spawn":"^7.0.5","eventsource":"^3.0.2","content-type":"^1.0.5","pkce-challenge":"^5.0.0","eventsource-parser":"^3.0.0","express-rate-limit":"^7.5.0","zod-to-json-schema":"^3.25.0"},"typesVersions":{"*":{"*":["./dist/esm/*"]}},"_hasShrinkwrap":false,"devDependencies":{"ws":"^8.18.0","tsx":"^4.16.5","eslint":"^9.8.0","vitest":"^4.0.8","prettier":"3.6.2","@types/ws":"^8.5.12","supertest":"^7.0.0","@eslint/js":"^9.39.1","typescript":"^5.5.4","@types/cors":"^2.8.17","@types/node":"^22.12.0","@types/express":"^5.0.0","eslint-plugin-n":"^17.23.1","@types/supertest":"^6.0.2","typescript-eslint":"^8.48.1","@types/cross-spawn":"^6.0.6","@types/eventsource":"^1.1.15","@types/content-type":"^1.1.8","@cfworker/json-schema":"^4.1.1","eslint-config-prettier":"^10.1.8","@typescript/native-preview":"^7.0.0-dev.20251103.1","@types/express-serve-static-core":"^5.1.0"},"peerDependencies":{"zod":"^3.25 || ^4.0","@cfworker/json-schema":"^4.1.1"},"peerDependenciesMeta":{"zod":{"optional":false},"@cfworker/json-schema":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sdk_1.24.3_1764858952451_0.0326481715652871","host":"s3://npm-registry-packages-npm-production"},"readme":"# MCP TypeScript SDK [![NPM Version](https://img.shields.io/npm/v/%40modelcontextprotocol%2Fsdk)](https://www.npmjs.com/package/@modelcontextprotocol/sdk) [![MIT licensed](https://img.shields.io/npm/l/%40modelcontextprotocol%2Fsdk)](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/LICENSE)\n\n<details>\n<summary>Table of Contents</summary>\n\n- [Overview](#overview)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Core Concepts](#core-concepts)\n- [Examples](#examples)\n- [Documentation](#documentation)\n- [Contributing](#contributing)\n- [License](#license)\n\n</details>\n\n## Overview\n\nThe 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\n[the full MCP specification](https://modelcontextprotocol.io/specification/draft), making it easy to:\n\n- Create MCP servers that expose resources, prompts and tools\n- Build MCP clients that can connect to any MCP server\n- Use standard transports like stdio and Streamable HTTP\n\n## Installation\n\n```bash\nnpm install @modelcontextprotocol/sdk zod\n```\n\nThis 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`:\n\n## Quick Start\n\nTo see the SDK in action end-to-end, start from the runnable examples in `src/examples`:\n\n1. **Install dependencies** (from the SDK repo root):\n\n    ```bash\n    npm install\n    ```\n\n2. **Run the example Streamable HTTP server**:\n\n    ```bash\n    npx tsx src/examples/server/simpleStreamableHttp.ts\n    ```\n\n3. **Run the interactive client in another terminal**:\n\n    ```bash\n    npx tsx src/examples/client/simpleStreamableHttp.ts\n    ```\n\nThis 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](docs/server.md) and\n[docs/client.md](docs/client.md).\n\n## Core Concepts\n\n### Servers and transports\n\nAn MCP server is typically created with `McpServer` and connected to a transport such as Streamable HTTP or stdio. The SDK supports:\n\n- **Streamable HTTP** for remote servers (recommended).\n- **HTTP + SSE** for backwards compatibility only.\n- **stdio** for local, process-spawned integrations.\n\nRunnable server examples live under `src/examples/server` and are documented in [docs/server.md](docs/server.md).\n\n### Tools, resources, prompts\n\n- **Tools** let LLMs ask your server to take actions (computation, side effects, network calls).\n- **Resources** expose read-only data that clients can surface to users or models.\n- **Prompts** are reusable templates that help users talk to models in a consistent way.\n\nThe detailed APIs, including `ResourceTemplate`, completions, and display-name metadata, are covered in [docs/server.md](docs/server.md#tools-resources-and-prompts), with runnable implementations in [`simpleStreamableHttp.ts`](src/examples/server/simpleStreamableHttp.ts).\n\n### Capabilities: sampling, elicitation, and tasks\n\nThe SDK includes higher-level capabilities for richer workflows:\n\n- **Sampling**: server-side tools can ask connected clients to run LLM completions.\n- **Form elicitation**: tools can request non-sensitive input via structured forms.\n- **URL elicitation**: servers can ask users to complete secure flows in a browser (e.g., API key entry, payments, OAuth).\n- **Tasks (experimental)**: long-running tool calls can be turned into tasks that you poll or resume later.\n\nConceptual overviews and links to runnable examples are in:\n\n- [docs/capabilities.md](docs/capabilities.md)\n\nKey example servers include:\n\n- [`toolWithSampleServer.ts`](src/examples/server/toolWithSampleServer.ts)\n- [`elicitationFormExample.ts`](src/examples/server/elicitationFormExample.ts)\n- [`elicitationUrlExample.ts`](src/examples/server/elicitationUrlExample.ts)\n\n### Clients\n\nThe high-level `Client` class connects to MCP servers over different transports and exposes helpers like `listTools`, `callTool`, `listResources`, `readResource`, `listPrompts`, and `getPrompt`.\n\nRunnable clients live under `src/examples/client` and are described in [docs/client.md](docs/client.md), including:\n\n- Interactive Streamable HTTP client ([`simpleStreamableHttp.ts`](src/examples/client/simpleStreamableHttp.ts))\n- Streamable HTTP client with SSE fallback ([`streamableHttpWithSseFallbackClient.ts`](src/examples/client/streamableHttpWithSseFallbackClient.ts))\n- OAuth-enabled clients and polling/parallel examples\n\n### Node.js Web Crypto (globalThis.crypto) compatibility\n\nSome 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`.\n\nSee [docs/faq.md](docs/faq.md) for details on supported Node.js versions and how to polyfill `globalThis.crypto` when running on older Node.js runtimes.\n\n## Examples\n\nThe 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.\n\n### Server examples\n\n| Scenario                                            | Description                                                                                       | Example file(s)                                                                                          | Related docs                                                             |\n| --------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |\n| Streamable HTTP server (stateful)                   | Feature-rich server with tools, resources, prompts, logging, tasks, sampling, and optional OAuth. | [`simpleStreamableHttp.ts`](src/examples/server/simpleStreamableHttp.ts)                                 | [`server.md`](docs/server.md), [`capabilities.md`](docs/capabilities.md) |\n| Streamable HTTP server (stateless)                  | No session tracking; good for simple API-style servers.                                           | [`simpleStatelessStreamableHttp.ts`](src/examples/server/simpleStatelessStreamableHttp.ts)               | [`server.md`](docs/server.md)                                            |\n| JSON response mode (no SSE)                         | Streamable HTTP with JSON responses only and limited notifications.                               | [`jsonResponseStreamableHttp.ts`](src/examples/server/jsonResponseStreamableHttp.ts)                     | [`server.md`](docs/server.md)                                            |\n| Server notifications over Streamable HTTP           | Demonstrates server-initiated notifications using SSE with Streamable HTTP.                       | [`standaloneSseWithGetStreamableHttp.ts`](src/examples/server/standaloneSseWithGetStreamableHttp.ts)     | [`server.md`](docs/server.md)                                            |\n| Deprecated HTTP+SSE server                          | Legacy HTTP+SSE transport for backwards-compatibility testing.                                    | [`simpleSseServer.ts`](src/examples/server/simpleSseServer.ts)                                           | [`server.md`](docs/server.md)                                            |\n| Backwards-compatible server (Streamable HTTP + SSE) | Single server that supports both Streamable HTTP and legacy SSE clients.                          | [`sseAndStreamableHttpCompatibleServer.ts`](src/examples/server/sseAndStreamableHttpCompatibleServer.ts) | [`server.md`](docs/server.md)                                            |\n| Form elicitation server                             | Uses form elicitation to collect non-sensitive user input.                                        | [`elicitationFormExample.ts`](src/examples/server/elicitationFormExample.ts)                             | [`capabilities.md`](docs/capabilities.md#elicitation)                    |\n| URL elicitation server                              | Demonstrates URL-mode elicitation in an OAuth-protected server.                                   | [`elicitationUrlExample.ts`](src/examples/server/elicitationUrlExample.ts)                               | [`capabilities.md`](docs/capabilities.md#elicitation)                    |\n| Sampling and tasks server                           | Combines tools, logging, sampling, and experimental task-based execution.                         | [`toolWithSampleServer.ts`](src/examples/server/toolWithSampleServer.ts)                                 | [`capabilities.md`](docs/capabilities.md)                                |\n| OAuth demo authorization server                     | In-memory OAuth provider used with the example servers.                                           | [`demoInMemoryOAuthProvider.ts`](src/examples/server/demoInMemoryOAuthProvider.ts)                       | [`server.md`](docs/server.md)                                            |\n\n### Client examples\n\n| Scenario                                            | Description                                                                        | Example file(s)                                                                                                                                                                                                                        | Related docs                                                 |\n| --------------------------------------------------- | ---------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |\n| Interactive Streamable HTTP client                  | CLI client that exercises tools, resources, prompts, elicitation, and tasks.       | [`simpleStreamableHttp.ts`](src/examples/client/simpleStreamableHttp.ts)                                                                                                                                                               | [`client.md`](docs/client.md)                                |\n| Backwards-compatible client (Streamable HTTP → SSE) | Tries Streamable HTTP first, then falls back to SSE on 4xx responses.              | [`streamableHttpWithSseFallbackClient.ts`](src/examples/client/streamableHttpWithSseFallbackClient.ts)                                                                                                                                 | [`client.md`](docs/client.md), [`server.md`](docs/server.md) |\n| SSE polling client                                  | Polls a legacy SSE server and demonstrates notification handling.                  | [`ssePollingClient.ts`](src/examples/client/ssePollingClient.ts)                                                                                                                                                                       | [`client.md`](docs/client.md)                                |\n| Parallel tool calls client                          | Shows how to run multiple tool calls in parallel.                                  | [`parallelToolCallsClient.ts`](src/examples/client/parallelToolCallsClient.ts)                                                                                                                                                         | [`client.md`](docs/client.md)                                |\n| Multiple clients in parallel                        | Demonstrates connecting multiple clients concurrently to the same server.          | [`multipleClientsParallel.ts`](src/examples/client/multipleClientsParallel.ts)                                                                                                                                                         | [`client.md`](docs/client.md)                                |\n| OAuth clients                                       | Examples of client_credentials (basic and private_key_jwt) and reusable providers. | [`simpleOAuthClient.ts`](src/examples/client/simpleOAuthClient.ts), [`simpleOAuthClientProvider.ts`](src/examples/client/simpleOAuthClientProvider.ts), [`simpleClientCredentials.ts`](src/examples/client/simpleClientCredentials.ts) | [`client.md`](docs/client.md)                                |\n| URL elicitation client                              | Works with the URL elicitation server to drive secure browser flows.               | [`elicitationUrlExample.ts`](src/examples/client/elicitationUrlExample.ts)                                                                                                                                                             | [`capabilities.md`](docs/capabilities.md#elicitation)        |\n\nShared utilities:\n\n- In-memory event store for resumability: [`inMemoryEventStore.ts`](src/examples/shared/inMemoryEventStore.ts) (see [`server.md`](docs/server.md)).\n\nFor more details on how to run these examples (including recommended commands and deployment diagrams), see `src/examples/README.md`.\n\n## Documentation\n\n- Local SDK docs:\n    - [docs/server.md](docs/server.md) – building and running MCP servers, transports, tools/resources/prompts, CORS, DNS rebinding, and multi-node deployment.\n    - [docs/client.md](docs/client.md) – using the high-level client, transports, backwards compatibility, and OAuth helpers.\n    - [docs/capabilities.md](docs/capabilities.md) – sampling, elicitation (form and URL), and experimental task-based execution.\n    - [docs/protocol.md](docs/protocol.md) – protocol features: ping, progress, cancellation, pagination, capability negotiation, and JSON Schema.\n    - [docs/faq.md](docs/faq.md) – environment and troubleshooting FAQs (including Node.js Web Crypto support).\n- External references:\n    - [V1 API reference](https://modelcontextprotocol.github.io/typescript-sdk/)\n    - [V2 API reference](https://modelcontextprotocol.github.io/typescript-sdk/v2/)\n    - [Model Context Protocol documentation](https://modelcontextprotocol.io)\n    - [MCP Specification](https://spec.modelcontextprotocol.io)\n    - [Example Servers](https://github.com/modelcontextprotocol/servers)\n\n## Contributing\n\nIssues and pull requests are welcome on GitHub at <https://github.com/modelcontextprotocol/typescript-sdk>.\n\n## License\n\nThis project is licensed under the MIT License—see the [LICENSE](LICENSE) file for details.\n","publish_time":1764858952609,"_cnpm_publish_time":1764858952609,"dist-tags":{"latest":"1.32.2"}}