vercel

mcp handler

Built by vercel 576 stars

What is mcp handler?

Easily spin up an MCP Server on Next.js, Nuxt, Svelte, and more

How to use mcp handler?

1. Install a compatible MCP client (like Claude Desktop). 2. Open your configuration settings. 3. Add mcp handler using the following command: npx @modelcontextprotocol/mcp-handler 4. Restart the client and verify the new tools are active.
🛡️ Scoped (Restricted)
npx @modelcontextprotocol/mcp-handler --scope restricted
🔓 Unrestricted Access
npx @modelcontextprotocol/mcp-handler

Key Features

Native MCP Protocol Support
Real-time Tool Activation & Execution
Verified High-performance Implementation
Secure Resource & Context Handling

Optimized Use Cases

Extending AI models with custom local capabilities
Automating system workflows via natural language
Connecting external data sources to LLM context windows

mcp handler FAQ

Q

Is mcp handler safe?

Yes, mcp handler follows the standardized Model Context Protocol security patterns and only executes tools with explicit user-granted permissions.

Q

Is mcp handler up to date?

mcp handler is currently active in the registry with 576 stars on GitHub, indicating its reliability and community support.

Q

Are there any limits for mcp handler?

Usage limits depend on the specific implementation of the MCP server and your system resources. Refer to the official documentation below for technical details.

Official Documentation

View on GitHub

mcp-handler

A Vercel adapter for the Model Context Protocol (MCP), enabling real-time communication between your applications and AI models. Supports Next.js and Nuxt.

Installation

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

Note: Versions of @modelcontextprotocol/sdk prior to 1.26.0 have a security vulnerability. Use version 1.26.0 or later.

Quick Start (Next.js)

// app/api/[transport]/route.ts
import { createMcpHandler } from "mcp-handler";
import { z } from "zod";

const handler = createMcpHandler(
  (server) => {
    server.registerTool(
      "roll_dice",
      {
        title: "Roll Dice",
        description: "Roll a dice with a specified number of sides.",
        inputSchema: {
          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", // must match where [transport] is located
    maxDuration: 60,
    verboseLogs: true,
  }
);

export { handler as GET, handler as POST };

Connecting Clients

If your client supports Streamable HTTP, connect directly:

{
  "remote-example": {
    "url": "http://localhost:3000/api/mcp"
  }
}

For stdio-only clients, use mcp-remote:

{
  "remote-example": {
    "command": "npx",
    "args": ["-y", "mcp-remote", "http://localhost:3000/api/mcp"]
  }
}

Documentation

Features

  • Framework Support: Next.js and Nuxt
  • Multiple Transports: Streamable HTTP and Server-Sent Events (SSE)
  • Redis Integration: Optional, for SSE transport resumability
  • TypeScript Support: Full type definitions included

Requirements

  • Next.js 13+ or Nuxt 3+
  • Node.js 18+
  • Redis (optional, for SSE)

License

Apache-2.0

Global Ranking

-
Trust ScoreMCPHub Index

Based on codebase health & activity.

Manual Config

{ "mcpServers": { "mcp-handler": { "command": "npx", "args": ["mcp-handler"] } } }