Get up and running with mcp.js in minutes.
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
Built for developers who want to create robust, type-safe MCP servers with minimal boilerplate.
Create MCP servers with just a few lines of code. Full type safety included.
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 };
From zero to production-ready MCP server in just a few steps.
Add Vercel's MCP adapter to your project with npm, yarn, or pnpm.
npm install mcp-handler
Create your server with tools, resources, and prompts.
createMcpHandler(...)
Deploy to Vercel, AWS, or any Node.js hosting platform.
vercel deploy