MCP Handler
Easily spin up an MCP Server on Next.js, Nuxt, Svelte, and more
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
Maintainer
Works with
Installation
NPM
npx -y mcp-handlerManual Installation
npx -y mcp-handlerConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
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
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@^3Create 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 };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,
}
);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:6379Point 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/mcpMCP 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.
MCP Handler Alternatives — Similar Developer Tools Servers
Looking for alternatives to MCP Handler? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
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.
Set Up MCP Handler in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
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.