-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
Problem
When a MCP server is built with latest versions mcp-handler@1.0.6 and @modelcontextprotocol/sdk@1.25.2 the Nextjs App router API endpoints throw below error
Error:
Error: No response is returned from route handler '[project]/app/api/health/route.ts'. Ensure you return a `Response` or a `NextResponse` in all branches of your handler. at ignore-listed frames
app/api/health/route.ts
import { NextResponse } from "next/server"
export const GET = () => {
return NextResponse.json({
status: "Ok"
})
}
Same error persists for versions 1.25.X of @modelcontextprotocol/sdk along side of mcp-handler@1.0.6
The only properly working version found - mcp-handler@1.0.6 and @modelcontextprotocol/sdk@1.24.3
Expected
NextJS API endpoints must keep functioning correctly along side of MCP routes in same app, when using mcp-handler@1.0.6 and @modelcontextprotocol/sdk@1.25.x
Reproducible Steps
- Create a NextJS App Router project
e.g.npx create-next-app@latest my-app --yes - Install dependencies with latest versions -
mcp-handler@1.0.6and@modelcontextprotocol/sdk@1.25.2 - Create a simple GET API endpoint
e.g.app/api/health/route.tsas above - Create a simple MCP server
e.g. follow mcp-handler example - https://www.npmjs.com/package/mcp-handler - Run the app and connect to the MCP Server from tools like Cursor or MCP Inspector (MUST connect to MCP first)
- Ping the
api/healthendpoint. Observe that server starts to throw error -
Error: No response is returned from route handler '[project]/app/api/health/route.ts'. Ensure you return a `Response` or a `NextResponse` in all branches of your handler
thesandlord, balataca, HemangRajvanshy, ramana-pz and bencevansosman-unat-deel, ziad-ibrahim-deel, chdeskur, HemangRajvanshy and ramana-pz
Metadata
Metadata
Assignees
Labels
No labels