Next.js

Plug xmcp into your existing Next.js application.

Installation

xmcp can work on top of your existing Next.js project. To get started, run the following command in your project directory:

On initialization, you'll see the following prompts:

? Tools directory path: (tools)
? Prompts directory path: (prompts)
? Resources directory path: (resources)
? Route directory path: (app/mcp)

The package manager and framework will be detected automatically.

After setting up the project, your build and dev commands should look like this:

Based on your configuration, it will create the tools, prompts, resources and route folders and add an endpoint to your Next.js app.

app/mcp/route.ts

middleware.ts and xmcp/headers are not supported since Next.js already supports those features.

Authentication

You can use the withAuth function to add authentication to your MCP server.

app/mcp/route.ts

On this page

One framework to rule them all

    Next.js | xmcp Documentation