{"name":"@modelcontextprotocol/sdk","version":"0.6.0","author":{"url":"https://anthropic.com","name":"Anthropic, PBC"},"license":"MIT","_id":"@modelcontextprotocol/sdk@0.6.0","maintainers":[{"name":"thedsp","email":"experimentalworks@gmail.com"},{"name":"jspahrsummers","email":"justin@jspahrsummers.com"}],"homepage":"https://modelcontextprotocol.github.io","bugs":{"url":"https://github.com/modelcontextprotocol/typescript-sdk/issues"},"dist":{"shasum":"a691c0aa634a2ac4b61ee7cb4a24603120fc1f4f","tarball":"http://registry-npm.ywwl.com/@modelcontextprotocol/sdk/download/@modelcontextprotocol/sdk-0.6.0.tgz","fileCount":79,"integrity":"sha512-9rsDudGhDtMbvxohPoMMyAUOmEzQsOK+XFchh6gZGqo8sx9sBuZQs+CUttXqa8RZXKDaJRCN2tUtgGof7jRkkw==","signatures":[{"sig":"MEYCIQDsoKrbVKvHroxyMlWvsXh0yvwMshvuItjcnEYklQqPOgIhAL5oLIcE+IHhX4eX1lgIB08qR+2JOneL9lV0bb7/WZhr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1659551,"size":81861,"noattachment":false,"key":"/@modelcontextprotocol/sdk/-/@modelcontextprotocol/sdk-0.6.0.tgz"},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{"./*":"./dist/*"},"gitHead":"1cb92b6246868666f160dc7cb66e789d02b2b182","scripts":{"lint":"eslint src/","test":"jest","build":"tsc","start":"npm run server","client":"tsx src/cli.ts client","server":"tsx watch --clear-screen=false src/cli.ts server","prepack":"tsc"},"_npmUser":{"name":"jspahrsummers","email":"justin@jspahrsummers.com"},"_npmVersion":"10.7.0","description":"Model Context Protocol implementation for TypeScript","directories":{},"resolutions":{"strip-ansi":"6.0.1"},"_nodeVersion":"18.20.4","dependencies":{"zod":"^3.23.8","raw-body":"^3.0.0","content-type":"^1.0.5"},"typesVersions":{"*":{"*":["./dist/*"]}},"_hasShrinkwrap":false,"devDependencies":{"ws":"^8.18.0","tsx":"^4.16.5","jest":"^29.7.0","eslint":"^9.8.0","express":"^4.19.2","ts-jest":"^29.2.4","@types/ws":"^8.5.12","@eslint/js":"^9.8.0","typescript":"^5.5.4","@types/jest":"^29.5.12","@types/node":"^22.0.2","eventsource":"^2.0.2","@types/express":"^4.17.21","@types/eslint__js":"^8.42.3","typescript-eslint":"^8.0.0","@types/eventsource":"^1.1.15","@types/content-type":"^1.1.8"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.6.0_1731775385937_0.11203307324985978","host":"s3://npm-registry-packages"},"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":1731775386119,"_cnpm_publish_time":1731775386119,"dist-tags":{"latest":"1.32.2"}}