home / mcp / example next.js mcp server

Example Next.js MCP Server

Next.js MCP Server that routes prompts across routes using the MCP handler for group-based interactions.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "ee380-model-context-protocol-mcp-with-next-js": {
      "url": "https://mcp-for-next-js.vercel.app",
      "headers": {
        "REDIS_URL": "YOUR_REDIS_URL"
      }
    }
  }
}

You are working with an MCP Server built for Next.js that routes prompts across a group of routes using the MCP handler. It enables you to expose an MCP endpoint through a Next.js project and test client invocations against that endpoint.

How to use

To use this MCP Server, point your MCP client at the provided HTTP endpoint. A sample client command demonstrates how to invoke the server for testing.

Important notes for running on Vercel: you can use the SSE transport when a Redis instance is attached to your project (set process.env.REDIS_URL). If you enable SSE, ensure the disableSse flag is set to false in your Next.js route configuration. For efficient execution, enable Fluid compute. If you are on a Vercel Pro or Enterprise account, you may adjust maxDuration to 800. Finally, deploy the Next.js MCP template to your project. The sample client shows how to invoke the server using a test script.

Sample client invocation you can try now is shown here. It targets a live MCP server URL and runs a test client script against it.

node scripts/test-client.mjs https://mcp-for-next-js.vercel.app

Available tools

MCP Handler

Core MCP processing engine that routes client prompts to adapters and handlers within the MCP architecture.

Next.js MCP Adapter

Adapter that enables MCP servers to run on a group of Next.js routes, integrating MCP capabilities into a Next.js project.