Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Run a stateless Model Context Protocol (MCP) server on Next.js App Router, deployable to Vercel.
The Next.js MCP Server template is a boilerplate for adding a stateless Model Context Protocol (MCP) server to a Next.js App Router application, deployable to Vercel.
This template uses mcp-handler 2 and the MCP TypeScript SDK v2 to serve MCP tools, prompts, and resources from a Next.js route handler. It takes MCP client requests over HTTP and returns MCP protocol responses, running at http://localhost:3000/mcp in development. The template is designed for developers who want to expose MCP capabilities from a Next.js application without managing a separate server process.
mcp-handler 2 and the MCP TypeScript SDK v2.scripts/test-client.mjs connects over Streamable HTTP, lists available tools, and calls an echo tool, runnable with pnpm test:client.app/mcp/route.ts following the MCP TypeScript SDK v2 documentation, then serve them from the same route.Edit app/mcp/route.ts to add your MCP tools, prompts, and resources. Start the Next.js application and point an MCP client to http://localhost:3000/mcp. On Vercel, deploy with Fluid compute enabled and Node.js 20 or later, then use your deployed URL as the MCP endpoint.
No, Redis is not required. The server is stateless and uses mcp-handler 2, so no external storage or caching layer is needed.
The current 2026-07-28 MCP protocol is served natively. Stateless clients using the 2025-era Streamable HTTP transport are supported via a compatibility layer. The deprecated HTTP+SSE transport is not supported.
Node.js 20 or later is required, and Vercel deployments should enable Fluid compute for efficient execution.
Run pnpm test:client -- https://your-deployed-url to connect over Streamable HTTP, list tools, and call the echo tool. The sample client script is located at scripts/test-client.mjs.
