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:
Before using the @xmcp/adapter import, you need to:
- Run
npx xmcp buildto generate the.xmcpfolder - Update your
tsconfig.jsonto include the path mapping:
After these steps, TypeScript errors will be resolved.
Based on your configuration, it will create the tools, prompts, resources and route folders and add an endpoint to your Next.js app.
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.