Skip to content

Next.js Starter

A full-stack MCP server built with Next.js and xmcp

Categories
Share
Post on X

A full-stack MCP server built with Next.js, exposing tools via the /mcp route.

Features

  • Next.js app with MCP endpoint at /mcp
  • File-based tool discovery from src/tools/
  • Concurrent dev server (xmcp + Next.js)
  • Example tools: greet (sync) and weather (async with external API)
  • Ready for authentication via withAuth

Getting Started

1. Create the project

Shell

2. Install & run

Shell

Requires Node.js 22.12 or newer. pnpm install also installs @xmcp-dev/compiler, the dev dependency that runs xmcp dev and xmcp build.

This starts both the xmcp dev server and Next.js dev server concurrently. Open http://localhost:3000 to see your app, and the MCP endpoint will be available at /mcp.

Project Structure

Text

MCP Endpoint

The MCP server is exposed at /mcp via the Next.js adapter in app/mcp/route.ts:

TypeScript

Adding Tools

Create a new .ts file in src/tools/. The tool is automatically discovered:

TypeScript

Authentication

Add authentication to your MCP server using the withAuth function. See the xmcp Next.js documentation for details.

Deploy

Shell

Deploy to Vercel or any Node.js hosting platform.

Learn More

Other templates

One framework to rule them all