Skip to content

Typescript SDK

The official TypeScript SDK for Model Context Protocol servers and clients

Install

$npm install @modelcontextprotocol/server

Install command taken from the project's README or registry entry. Always review code before running it.

MCP TypeScript SDK

[!IMPORTANT] This is the main branch: v2 of the SDK (@modelcontextprotocol/server, @modelcontextprotocol/client), the stable release line, implementing the 2026-07-28 MCP spec. Start with the v2 documentation; coming from v1, see the migration guide.

v1.x (@modelcontextprotocol/sdk) lives on the v1.x branch and continues to receive bug fixes and security updates for at least six months after the v2 release (2026-07-27). Its documentation is at ts.sdk.modelcontextprotocol.io.

Found a problem in v2? Open an issue.

[!NOTE] Contributors without write access can have one open pull request at a time. Draft pull requests don't count toward the limit. For a feature or a larger change, please open an issue first; see CONTRIBUTING.md.

Table of Contents

Overview

The Model Context Protocol (MCP) allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction.

This repository contains the TypeScript SDK implementation of the MCP specification. It runs on Node.js, Bun, and Deno, and ships:

  • MCP server libraries (tools/resources/prompts, Streamable HTTP, stdio, auth helpers)
  • MCP client libraries (transports, high-level helpers, OAuth helpers)
  • Optional middleware packages for specific runtimes/frameworks (Express, Fastify, Hono, Node.js HTTP)
  • Runnable examples (under examples/)

Packages

This monorepo publishes split packages:

  • @modelcontextprotocol/server: build MCP servers
  • @modelcontextprotocol/client: build MCP clients

Tool and prompt schemas use Standard Schema — bring Zod v4, Valibot, ArkType, or any compatible library.

Middleware packages (optional)

The SDK also publishes small "middleware" packages under packages/middleware/ that help you wire MCP into a specific runtime or web framework.

They are intentionally thin adapters: they should not introduce new MCP functionality or business logic. See packages/middleware/README.md for details.

  • @modelcontextprotocol/node: Node.js Streamable HTTP transport wrapper for IncomingMessage / ServerResponse
  • @modelcontextprotocol/express: Express helpers (app defaults + Host header validation)
  • @modelcontextprotocol/fastify: Fastify helpers (app defaults + Host header validation)
  • @modelcontextprotocol/hono: Hono helpers (app defaults + JSON body parsing hook + Host header validation)

Installation

Server

Similar plugs

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

Java 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype…

Explore related