Model Context Protocol SDK (JavaScript)
TypeScript SDK for building MCP servers and clients to extend AI agent capabilities.
3. Used by agents' projects
Dependency in 600 public GitHub projects set up for AI coding agents that we scanned (9.6%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
ts.sdk.modelcontextprotocol.io/v2/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Model Context Protocol SDK (JavaScript) does
The npm package <code>@modelcontextprotocol/sdk</code> is now the v1 line of the official TypeScript MCP SDK: new work goes to the split v2 packages <code>@modelcontextprotocol/server</code> and <code>@modelcontextprotocol/client</code>, and the maintainers ship a codemod that moves v1 code across.
Model Context Protocol SDK (JavaScript) popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Model Context Protocol SDK (JavaScript) is used
- Model Context Protocol SDK (JavaScript) is a dependency in 600 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (12.3% of the 4,867 JavaScript/TypeScript ones), #1 of 192 in agent, mcp and tool libraries.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,449; those are left out of every share on this page.
- The most used alternative in our scan is fastMCP (JavaScript) (32 projects).
- Projects that use it most often also use Zod (70.3%), TypeScript (81.5%), tsx (40.3%).
- It is more common in projects set up for GitHub Copilot (10.5%) than for Devin Desktop (5.7%).
By coding agent
Often used with
Model Context Protocol SDK (JavaScript) in practice
Strengths
You declare a tool's input with a <code>z.object(...)</code> schema. The docs say the SDK checks every call against that schema before your handler is invoked.
Tool and prompt schemas use Standard Schema. The README says you can use Zod v4, Valibot, ArkType or any compatible library.
The docs present this SDK as the TypeScript implementation of the MCP spec. It runs on Node.js, Bun and Deno, and the llms.txt index adds Workers.
Every example is a full client–server pair. CI runs each one on every pull request. <code>cli-client/</code> and <code>todos-server/</code> are the reference pair: a full LLM chat host and the server it drives.
Watch out for
<code>@modelcontextprotocol/sdk</code> is v1 and lives on the <code>v1.x</code> branch. The README promises bug fixes and security updates for at least six months after the v2 release.
Adopting the 2026-07-28 protocol revision is a separate, manual job. That covers <code>createMcpHandler</code>, multi-round-trip requests and <code>versionNegotiation</code>.
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.
A minimal stdio server with one tool (v2 packages)
import { McpServer } from '@modelcontextprotocol/server';
import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
import * as z from 'zod/v4';
const server = new McpServer({ name: 'greeting-server', version: '1.0.0' });
server.registerTool(
'greet',
{
description: 'Greet someone by name',
inputSchema: z.object({ name: z.string() })
},
async ({ name }) => ({ content: [{ type: 'text', text: `Hello, ${name}!` }] })
);
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
}
main();More about Model Context Protocol SDK (JavaScript)
Packages around it
- @modelcontextprotocol/server: v2 server package
- @modelcontextprotocol/inspector: @modelcontextprotocol/inspector
- @modelcontextprotocol/client: v2 client package
- @modelcontextprotocol/ext-apps: @modelcontextprotocol/ext-apps
- @modelcontextprotocol/server-filesystem: Reference filesystem server
- @modelcontextprotocol/node: Node.js HTTP transport adapter
More in Agent, MCP and tool libraries
Alternatives
Model Context Protocol SDK (JavaScript) This page
TypeScript framework for building Model Context Protocol servers.
Compare Model Context Protocol SDK (JavaScript) with another tool
Get started
Install it.
npm install @modelcontextprotocol/sdkRules for your agent
## 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.