Last 12 weeks · 10 commits
1 of 6 standards met
Hello, I am trying to create an MCP server in my Next.js application using createMcpHandler, but I am running into issues with the basePath option. Here is my code: Folder structure: What works: The handler works using Postman on /mcp/mcp: Problem / Unexpected behavior: The cannot be left empty. The must match the folder structure — it cannot be different. The MCP server is only accessible through , which feels restrictive. I would like clarification on whether it is intended that basePath must always match the folder route and cannot be empty or customized independently.
Repository: vercel/mcp-handler. Description: Easily spin up an MCP Server on Next.js, Nuxt, Svelte, and more Stars: 569, Forks: 75. Primary language: TypeScript. Languages: TypeScript (95%), JavaScript (5%). Homepage: https://www.npmjs.com/package/mcp-handler Latest release: v1.0.7 (1mo ago). Open PRs: 9, open issues: 13. Last activity: 1w ago. Community health: 50%. Top contributors: quuu, allenzhou101, vercel-release-bot, github-actions[bot], dclark27, markandrus, joelhooks, dvoytenko, ykaranke-allata, yordis and others.
TypeScript
Problem When a MCP server is built with latest versions and the Nextjs App router API endpoints throw below error Error: app/api/health/route.ts Same error persists for versions of along side of The only properly working version found - Expected NextJS API endpoints must keep functioning correctly along side of MCP routes in same app, when using and Reproducible Steps 1. Create a NextJS App Router project e.g. 2. Install dependencies with latest versions - and 3. Create a simple GET API endpoint e.g. as above 4. Create a simple MCP server e.g. follow mcp-handler example - https://www.npmjs.com/package/mcp-handler 5. Run the app and connect to the MCP Server from tools like Cursor or MCP Inspector (MUST connect to MCP first) 6. Ping the endpoint. Observe that server starts to throw error -