MCP Handler

v1.1.0Developer Toolsstable

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

mcpvercelnext.jsai
Share:
603
Stars
0
Downloads
0
Weekly
0/5

What is MCP Handler?

MCP Handler is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to easily spin up an mcp server on next.js, nuxt, svelte, and more

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

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

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

Use Cases

Spin up MCP server on Next.js
Nuxt and Svelte framework support
Vercel deployment ready
vercel

Maintainer

LicenseMIT
Languagetypescript
Versionv1.1.0
UpdatedMay 19, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y mcp-handler

Manual Installation

npx -y mcp-handler

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use MCP Handler

mcp-handler is a lightweight npm library by Vercel that provides framework adapters for embedding a full MCP server directly inside Next.js, Nuxt, Svelte, and other Node.js web frameworks — no separate process or infrastructure required. Developers define tools using the Model Context Protocol SDK's server.registerTool() API, and mcp-handler wires the transport layer to their existing HTTP route handler, making the MCP endpoint available at any path they choose. It supports Vercel's streaming infrastructure, SSE resumability via Redis, and works with stdio-only MCP clients through mcp-remote.

Prerequisites

  • Node.js 18 or later
  • An existing Next.js 13+ (App Router), Nuxt 3+, or SvelteKit project
  • npm, pnpm, or bun package manager
  • Optional: a Redis instance for SSE resumability in long-running connections
  • An MCP client such as Claude Desktop, or any MCP-compatible AI assistant
1

Install mcp-handler and required peer dependencies

Add the mcp-handler package along with the MCP SDK and Zod for tool schema validation.

npm install mcp-handler @modelcontextprotocol/[email protected] zod@^3
2

Create a route handler file

In Next.js App Router, create an API route at app/api/mcp/route.ts. In Nuxt, create a server route. The exact path becomes the MCP endpoint URL.

// app/api/mcp/route.ts (Next.js App Router)
import { createMcpHandler } from "mcp-handler";
import { z } from "zod";

const handler = createMcpHandler((server) => {
  server.registerTool(
    "roll_dice",
    { description: "Roll a dice", inputSchema: { sides: z.number().int().min(2) } },
    async ({ sides }) => ({
      content: [{ type: "text", text: `Rolled: ${Math.floor(Math.random() * sides) + 1}` }],
    })
  );
});

export { handler as GET, handler as POST };
3

Configure handler options

Pass an options object as the second argument to createMcpHandler to set the base path, request timeout, and verbose logging.

const handler = createMcpHandler(
  (server) => { /* register tools */ },
  {
    basePath: "/api",
    maxDuration: 60,
    verboseLogs: true,
  }
);
4

Add Redis for SSE resumability (optional)

For production deployments where connections may be interrupted, configure a Redis connection string in your environment variables to enable SSE event replay.

REDIS_URL=redis://localhost:6379
5

Point your MCP client at the endpoint

For HTTP-capable MCP clients, connect directly to your route URL. For stdio-only clients like Claude Desktop, use mcp-remote to bridge the connection.

# For stdio-only clients, use mcp-remote:
npx mcp-remote http://localhost:3000/api/mcp

MCP Handler Examples

Client configuration

Claude Desktop configuration using mcp-remote to connect to a locally running Next.js app that serves an MCP endpoint at /api/mcp.

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

Prompts to try

Example prompts assuming you have registered tools in your mcp-handler route.

- "Roll a 20-sided dice"
- "Call my custom summarize tool with this article text"
- "Use the search tool to find products matching 'blue sneakers'"
- "Trigger the send-notification tool with message 'Build complete'"
- "What tools are available on this MCP server?"

Troubleshooting MCP Handler

Claude Desktop cannot reach the MCP endpoint

Claude Desktop only supports stdio transport natively. Use mcp-remote ('npx mcp-remote http://localhost:3000/api/mcp') as the command in your config to bridge HTTP to stdio. Ensure your Next.js dev server is running before starting Claude Desktop.

Peer dependency conflict when installing mcp-handler

mcp-handler requires @modelcontextprotocol/sdk at version 1.26.0. Pin this exact version in your package.json to avoid conflicts with other packages that may depend on different MCP SDK versions.

SSE connections drop in Vercel deployments after the function timeout

Set maxDuration in the handler options to match your Vercel plan's maximum function duration. Enable Redis SSE resumability by setting the REDIS_URL environment variable so clients can reconnect and replay missed events.

Frequently Asked Questions about MCP Handler

What is MCP Handler?

MCP Handler is a Model Context Protocol (MCP) server that easily spin up an mcp server on next.js, nuxt, svelte, and more It connects AI assistants to external tools and data sources through a standardized interface.

How do I install MCP Handler?

Install via npm with the command: npx -y mcp-handler. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).

Which AI clients work with MCP Handler?

MCP Handler works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is MCP Handler free to use?

Yes, MCP Handler is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

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

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use MCP Handler?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides