TypeScript Framework

The MCP Toolkit for
TypeScript

From the creators of Next.js, mcp.js is a free open-source library that gives you the tools you need to build MCP-powered products.

Quick Start

Get up and running with mcp.js in minutes.

Terminal
npm install mcp-handler @modelcontextprotocol/sdk zod@^3

# or with yarn
yarn add mcp-handler @modelcontextprotocol/sdk zod@^3

# or with pnpm  
pnpm add mcp-handler @modelcontextprotocol/sdk zod@^3

# or with bun
bun add mcp-handler @modelcontextprotocol/sdk zod@^3

Why Choose mcp.js?

Built for developers who want to create robust, type-safe MCP servers with minimal boilerplate.

Type Safety First
Built with TypeScript from the ground up. Get full type safety for your tools, resources, and prompts.
Lightning Fast
Optimized for performance with minimal overhead. Deploy to Vercel, AWS, or any Node.js environment.
Production Ready
Built-in error handling, logging, and monitoring. Ready for production workloads out of the box.
Universal Compatibility
Works with any MCP-compatible client including Claude, Cursor, and custom AI applications.
Developer Experience
Intuitive APIs, comprehensive documentation, and excellent tooling for the best developer experience.
Extensible
Plugin system and middleware support. Extend functionality with custom transports and handlers.

Simple. Powerful. TypeScript.

Create MCP servers with just a few lines of code. Full type safety included.

server.ts
import { createMcpHandler } from "mcp-handler";
import { z } from "zod";

const handler = createMcpHandler(
  (server) => {
    server.tool(
      "roll_dice",
      "Rolls an N-sided die",
      {
        sides: z.number().int().min(2),
      },
      async ({ sides }) => {
        const value = 1 + Math.floor(Math.random() * sides);
        return {
          content: [{ type: "text", text: `🎲 You rolled a ${value}!` }],
        };
      }
    );
  },
  {},
  { basePath: "/api" },
);

export { handler as GET, handler as POST };

Get Started in Minutes

From zero to production-ready MCP server in just a few steps.

1

Install

Add Vercel's MCP adapter to your project with npm, yarn, or pnpm.

npm install mcp-handler
2

Build

Create your server with tools, resources, and prompts.

createMcpHandler(...)
3

Deploy

Deploy to Vercel, AWS, or any Node.js hosting platform.

vercel deploy
Built with v0