Skip to content
Back to search

typescript-sdk

The official TypeScript SDK for Model Context Protocol servers and clients

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/modelcontextprotocol--typescript-sdk/badge.svg)](/listings/modelcontextprotocol--typescript-sdk)

HTML

<a href="/listings/modelcontextprotocol--typescript-sdk"><img src="/api/listings/modelcontextprotocol--typescript-sdk/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Server

npm install @modelcontextprotocol/server
# or
bun add @modelcontextprotocol/server
# or
deno add npm:@modelcontextprotocol/server

Client

npm install @modelcontextprotocol/client
# or
bun add @modelcontextprotocol/client
# or
deno add npm:@modelcontextprotocol/client

Optional middleware packages

The SDK also publishes optional “middleware” packages that help you **wire MCP into a specific runtime or web framework** (for example Express, Fastify, Hono, or Node.js `http`).

These packages are intentionally thin adapters and should not introduce additional MCP features or business logic. See [`packages/middleware/README.md`](packages/middleware/README.md) for details.

# Node.js HTTP (IncomingMessage/ServerResponse) Streamable HTTP transport:
npm install @modelcontextprotocol/node

# Express integration:
npm install @modelcontextprotocol/express express

# Fastify integration:
npm install @modelcontextprotocol/fastify fastify

# Hono integration:
npm install @modelcontextprotocol/hono hono

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 177 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # MCP TypeScript SDK
  2. <!-- prettier-ignore -->
  3. > [!IMPORTANT]
  4. > **This is the `main` branch: v2 of the SDK** (`@modelcontextprotocol/server`, `@modelcontextprotocol/client`), the stable release line, implementing the [2026-07-28 MCP spec](https://modelcontextprotocol.io/specification/2026-07-28). Start with the [v2 documentation](https://ts.sdk.modelcontextprotocol.io/v2/); coming from v1, see the [migration guide](https://ts.sdk.modelcontextprotocol.io/v2/migration/upgrade-to-v2).
  5. >
  6. > **v1.x** (`@modelcontextprotocol/sdk`) lives on the [`v1.x` branch](https://github.com/modelcontextprotocol/typescript-sdk/tree/v1.x) 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](https://ts.sdk.modelcontextprotocol.io/).
  7. >
  8. > Found a problem in v2? [Open an issue](https://github.com/modelcontextprotocol/typescript-sdk/issues/new?template=v2-feedback.yml).
  9. <!-- prettier-ignore -->
  10. > [!NOTE]
  11. > **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](https://github.com/modelcontextprotocol/typescript-sdk/issues/new/choose) first; see [CONTRIBUTING.md](CONTRIBUTING.md).
  12. [![NPM Version - Server](https://img.shields.io/npm/v/%40modelcontextprotocol%2Fserver?label=%40modelcontextprotocol%2Fserver)](https://www.npmjs.com/package/@modelcontextprotocol/server)
  13. [![NPM Version - Client](https://img.shields.io/npm/v/%40modelcontextprotocol%2Fclient?label=%40modelcontextprotocol%2Fclient)](https://www.npmjs.com/package/@modelcontextprotocol/client) ![Apache-2.0 licensed](https://img.shields.io/npm/l/%40modelcontextprotocol%2Fserver)
  14. <details>
  15. <summary>Table of Contents</summary>
  16. - [Overview](#overview)
  17. - [Packages](#packages)
  18. - [Installation](#installation)
  19. - [Getting Started](#getting-started)
  20. - [Documentation](#documentation)
  21. - [Contributing](#contributing)
  22. - [License](#license)
  23. </details>
  24. ## Overview
  25. 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.
  26. This repository contains the TypeScript SDK implementation of the MCP specification. It runs on **Node.js**, **Bun**, and **Deno**, and ships:
  27. - MCP **server** libraries (tools/resources/prompts, Streamable HTTP, stdio, auth helpers)
  28. - MCP **client** libraries (transports, high-level helpers, OAuth helpers)
  29. - Optional **middleware packages** for specific runtimes/frameworks (Express, Fastify, Hono, Node.js HTTP)
  30. - Runnable **examples** (under [`examples/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples))
  31. ## Packages
  32. This monorepo publishes split packages:
  33. - **`@modelcontextprotocol/server`**: build MCP servers
  34. - **`@modelcontextprotocol/client`**: build MCP clients
  35. Tool and prompt schemas use [Standard Schema](https://standardschema.dev/) — bring Zod v4, Valibot, ArkType, or any compatible library.
  36. ### Middleware packages (optional)
  37. The SDK also publishes small "middleware" packages under [`packages/middleware/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/packages/middleware) that help you **wire MCP into a specific runtime or web framework**.
  38. They are intentionally thin adapters: they should not introduce new MCP functionality or business logic. See [`packages/middleware/README.md`](packages/middleware/README.md) for details.
  39. - **`@modelcontextprotocol/node`**: Node.js Streamable HTTP transport wrapper for `IncomingMessage` / `ServerResponse`
  40. - **`@modelcontextprotocol/express`**: Express helpers (app defaults + Host header validation)
  41. - **`@modelcontextprotocol/fastify`**: Fastify helpers (app defaults + Host header validation)
  42. - **`@modelcontextprotocol/hono`**: Hono helpers (app defaults + JSON body parsing hook + Host header validation)
  43. ## Installation
  44. ### Server
  45. ```bash
  46. npm install @modelcontextprotocol/server
  47. # or
  48. bun add @modelcontextprotocol/server
  49. # or
  50. deno add npm:@modelcontextprotocol/server
  51. ```
  52. ### Client
  53. ```bash
  54. npm install @modelcontextprotocol/client
  55. # or
  56. bun add @modelcontextprotocol/client
  57. # or
  58. deno add npm:@modelcontextprotocol/client
  59. ```
  60. ### Optional middleware packages
  61. The SDK also publishes optional “middleware” packages that help you **wire MCP into a specific runtime or web framework** (for example Express, Fastify, Hono, or Node.js `http`).
  62. These packages are intentionally thin adapters and should not introduce additional MCP features or business logic. See [`packages/middleware/README.md`](packages/middleware/README.md) for details.
  63. ```bash
  64. # Node.js HTTP (IncomingMessage/ServerResponse) Streamable HTTP transport:
  65. npm install @modelcontextprotocol/node
  66. # Express integration:
  67. npm install @modelcontextprotocol/express express
  68. # Fastify integration:
  69. npm install @modelcontextprotocol/fastify fastify
  70. # Hono integration:
  71. npm install @modelcontextprotocol/hono hono
  72. ```
  73. ## Getting Started
  74. Here is what an MCP server looks like. This minimal example exposes a single `greet` tool over stdio:
  75. ```typescript
  76. import { McpServer } from '@modelcontextprotocol/server';
  77. import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
  78. import * as z from 'zod/v4';
  79. const server = new McpServer({ name: 'greeting-server', version: '1.0.0' });
  80. server.registerTool(
  81. 'greet',
  82. {
  83. description: 'Greet someone by name',
  84. inputSchema: z.object({ name: z.string() })
  85. },
  86. async ({ name }) => ({
  87. content: [{ type: 'text', text: `Hello, ${name}!` }]
  88. })
  89. );
  90. async function main() {
  91. const transport = new StdioServerTransport();
  92. await server.connect(transport);
  93. }
  94. main();
  95. ```
  96. Ready to build something real? Follow the step-by-step tutorials:
  97. - [Build your first server](docs/get-started/first-server.md) — a stdio weather-alert server, from `npm init` to a tool call
  98. - [Build your first client](docs/get-started/first-client.md) — connect to that server, list its tools, and call them
  99. For runnable, end-to-end examples beyond the tutorials, see:
  100. - [`examples/README.md`](examples/README.md) — runnable, self-verifying client/server example pairs (one story per directory)
  101. ## Documentation
  102. - [Build a server](docs/get-started/first-server.md) — your first MCP server, step by step
  103. - [Build a client](docs/get-started/first-client.md) — your first MCP client, step by step
  104. - [Documentation site](https://ts.sdk.modelcontextprotocol.io/v2/) — the full guides: tools, resources, prompts, serving over HTTP and stdio, clients, OAuth, and migration
  105. - [Troubleshooting](docs/troubleshooting.md) — common errors and their fixes
  106. - [API reference](https://ts.sdk.modelcontextprotocol.io/v2/api/)
  107. - [MCP documentation](https://modelcontextprotocol.io/docs)
  108. - [MCP specification](https://modelcontextprotocol.io/specification/latest)
  109. ### Building docs locally
  110. To work on the documentation site locally:
  111. ```bash
  112. pnpm docs:api # Generate the API reference markdown (output: docs/api/)
  113. pnpm docs:dev # Start the VitePress dev server for the V2 site
  114. pnpm docs:build # Build the V2 site (output: docs/.vitepress/dist/)
  115. pnpm docs:multi # Build the combined V1 + V2 site (output: tmp/docs-combined/)
  116. ```
  117. The `docs:multi` script builds the V2 site from the current checkout, checks out the `v1.x` branch via a git worktree to build the V1 site, and produces a combined site with V1 docs at the root and V2 docs under `/v2/`.
  118. ## v1 (legacy) documentation and fixes
  119. If you are using the **v1** generation of the SDK, the **v1 API documentation** is available at [`https://ts.sdk.modelcontextprotocol.io/`](https://ts.sdk.modelcontextprotocol.io/). The v1 source code and any v1-specific fixes live on the long-lived
  120. [`v1.x` branch](https://github.com/modelcontextprotocol/typescript-sdk/tree/v1.x). V2 API docs are at [`/v2/`](https://ts.sdk.modelcontextprotocol.io/v2/).
  121. ## Contributing
  122. Issues and pull requests are welcome on GitHub at <https://github.com/modelcontextprotocol/typescript-sdk>.
  123. ## License
  124. This project is licensed under the Apache License 2.0 for new contributions, with existing code under MIT. See the [LICENSE](LICENSE) file for details.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.