# Model Context Protocol SDK (JavaScript) — card for AI agents

TypeScript SDK for building MCP servers and clients to extend AI agent capabilities.

Category: Agent, MCP and tool libraries · npm package `@modelcontextprotocol/sdk` · latest version 1.32.2 (checked 2026-11-01)
Install: `npm install @modelcontextprotocol/sdk`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## MCP TypeScript SDK
- For new code, install `@modelcontextprotocol/server` or `@modelcontextprotocol/client` (v2). `@modelcontextprotocol/sdk` is the v1 package.
- Define a tool with `registerTool(name, config, handler)` and a `z.object(...)` `inputSchema`. Serve it over stdio with `serveStdio`.
- Import types and error classes from the client or server package you depend on. Never import `@modelcontextprotocol/core-internal`.
- To upgrade v1 code, run `npx @modelcontextprotocol/codemod@latest v1-to-v2 .` at the package root, not `./src`. Then run `grep -rn '@mcp-codemod-error' .` and `tsc --noEmit`, and run the formatter on the changed files.
- Grep files that receive the SDK by injection for `setRequestHandler(`, `ErrorCode.` and `extra.`. The codemod skips them, and they fail at runtime.
- Report tool failures as a successful result with `isError: true`, so the model can read the error and recover.
- Fetch docs as markdown: every page in `https://ts.sdk.modelcontextprotocol.io/v2/llms.txt` is served at its `.md` URL.

## Docs written for agents
- [llms.txt (index of the docs)](https://ts.sdk.modelcontextprotocol.io/v2/llms.txt)

## What it is
- This is the official TypeScript implementation of the Model Context Protocol (MCP). The README says MCP lets applications provide context for LLMs in a standard way, kept separate from the LLM interaction itself. You write a server that exposes tools, resources and prompts. A host such as Claude Code, VS Code or Cursor connects to it and lets a model use them. The SDK also ships client libraries for programs that launch servers and call their tools.
- The package tracked here, `@modelcontextprotocol/sdk`, is the single monolithic v1 package. The main branch is now v2, the stable line implementing the 2026-07-28 spec. v2 is split into separate packages: `@modelcontextprotocol/server`, `@modelcontextprotocol/client`, `@modelcontextprotocol/core`, plus thin middleware adapters for Node.js HTTP, Express, Fastify and Hono.
- It is for anyone exposing an API or data to AI applications, or building an app that talks to MCP servers. If you already have v1 code, the migration guide covers the move from `@modelcontextprotocol/sdk` to the v2 packages.

## Caveats
- This package is the legacy line: `@modelcontextprotocol/sdk` is v1 and lives on the `v1.x` branch. The README promises bug fixes and security updates for at least six months after the v2 release.
- The codemod stops at the API surface: Adopting the 2026-07-28 protocol revision is a separate, manual job. That covers `createMcpHandler`, multi-round-trip requests and `versionNegotiation`.
- Injected SDK code breaks at runtime: The codemod only rewrites files that import the SDK. Code that receives the SDK as a parameter keeps its v1 idioms. Those idioms then fail at runtime, not at compile time.
- Monorepos need hand edits: The codemod rewrites only one manifest. For workspace members, it prints the dependency changes each one needs, and you apply them yourself.
- Node.js 20 and a mixed license: v2 requires Node.js 20+. Existing code is MIT, but the README says new contributions are licensed under Apache 2.0.

## Numbers (AgentGid data)
- Gid Score: 81.9 (#70 of all tools, 3 of 192 in its category)
- Used in 600 public projects set up for AI coding agents (9.6%)
- Downloads last week: 93,779,332 (as of 2026-11-24), +41.8% over 4 weeks
- GitHub stars: 13,814 (as of 2026-11-24)
- Last push: 2026-11-19

## Often used with
Zod 70.3%, TypeScript 81.5%, tsx 40.3%, Express 22.7%, Vitest 35.3%, dotenv 28.8%

## Checked alternatives (same job)
- fastMCP (JavaScript): https://agentgid.com/tools/fastmcp-npm/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/modelcontextprotocol/
- Homepage: https://modelcontextprotocol.io
- Repository: https://github.com/modelcontextprotocol/typescript-sdk
- Source: https://github.com/modelcontextprotocol/typescript-sdk#readme
- Source: https://github.com/modelcontextprotocol/typescript-sdk
- Source: https://github.com/modelcontextprotocol/typescript-sdk/releases
- Source: https://ts.sdk.modelcontextprotocol.io/v2
- Source: https://ts.sdk.modelcontextprotocol.io/v2/llms.txt
- Source: https://ts.sdk.modelcontextprotocol.io/v2/get-started/examples.md
- Source: https://ts.sdk.modelcontextprotocol.io/v2/migration/index.md
- Source: https://ts.sdk.modelcontextprotocol.io/v2/migration/upgrade-to-v2.md

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
