# MCP TypeScript SDK

> Build MCP servers and clients in TypeScript on Node.js, Bun or Deno

- Category: Agents & Automation / Agent Frameworks & Builders
- Language: TypeScript
- Licence: Apache-2.0 for new contributions, with existing code under MIT
- Repository: https://github.com/modelcontextprotocol/typescript-sdk
- Website: https://ts.sdk.modelcontextprotocol.io/v2
- Canonical page: https://ai-tldr.dev/tools/mcp-typescript-sdk/

## In short

MCP TypeScript SDK is Build MCP servers and clients in TypeScript on Node.js, Bun or Deno. The repository ships both halves of the protocol: server libraries for exposing capabilities, and client libraries for connecting to and consuming them. It sits in the Agent Frameworks & Builders category of the Agents & Automation tools and is open-source, written in TypeScript and licensed Apache-2.0 for new contributions, with existing code under MIT.

## Overview

The MCP TypeScript SDK is the official TypeScript implementation of the Model Context Protocol, the standard that lets an application supply an LLM with context — tools it can call, resources it can read, and prompts it can reuse — separately from the model interaction itself. The repository ships both halves of the protocol: server libraries for exposing capabilities, and client libraries for connecting to and consuming them.

It is published as a monorepo of split packages. `@modelcontextprotocol/server` is what you install to build a server; `@modelcontextprotocol/client` is what you install to build a client. Both run on Node.js, Bun and Deno. Tool and prompt schemas are declared through Standard Schema, so you can bring Zod v4, Valibot, ArkType or any other compatible validation library rather than being tied to one.

Alongside the two core packages the project publishes deliberately thin middleware adapters — `@modelcontextprotocol/node`, `/express`, `/fastify` and `/hono` — that wire the Streamable HTTP transport into a specific runtime or web framework without adding protocol features of their own. The `main` branch is the v2 line, implementing the 2026-07-28 MCP specification; the v1 generation continues to receive bug and security fixes on its own long-lived branch.

## What it does

- Server libraries covering tools, resources and prompts, with stdio and Streamable HTTP transports and auth helpers
- Client libraries with transports, high-level helpers and OAuth helpers for connecting to any MCP server
- Standard Schema support, so tool and prompt schemas can be written in Zod v4, Valibot, ArkType or another compatible library
- Runs on Node.js, Bun and Deno from the same packages
- Optional thin middleware packages for Node's http, Express, Fastify and Hono
- Runnable example client/server pairs in the repository's examples directory

## Getting started

Install the server package, register a tool, and connect the server to a transport. The example below is the minimal stdio server from the project README.

1. Install the server package

   Use npm, Bun or Deno — the SDK supports all three runtimes.

```bash
npm install @modelcontextprotocol/server
```

2. Write a server that exposes one tool

   Create an McpServer, register a tool with a schema and handler, then connect it over stdio.

```typescript
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();
```

3. Add a client, or serve over HTTP

   Install the client package to connect to a server, list its tools and call them. To serve over Streamable HTTP instead of stdio, add the middleware package for your framework.

```bash
npm install @modelcontextprotocol/client
# serving over HTTP with Express:
npm install @modelcontextprotocol/express express
```

## When to use it

- Expose an internal API or database to Claude, ChatGPT or any MCP-capable agent as a set of typed tools
- Build an MCP client so your own application can discover and call tools from third-party MCP servers
- Publish a server over Streamable HTTP inside an existing Express, Fastify or Hono service
- Prototype a local integration over stdio before deciding how to host it
