Skip to content

fix(deps): migrate MCP route to mcp-handler v2 - #158

Open
Rinava wants to merge 1 commit into
mainfrom
fix/mcp-handler-v2
Open

fix(deps): migrate MCP route to mcp-handler v2#158
Rinava wants to merge 1 commit into
mainfrom
fix/mcp-handler-v2

Conversation

@Rinava

@Rinava Rinava commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Adopts mcp-handler 2.x properly — the migration #155 (Dependabot's blind bump to ^2.1.0) couldn't do on its own, since v2 is a breaking API change that failed the build at route.ts:125 ("Expected 1-2 arguments, but got 3").

What v2 changed (and how this adapts)

  • 3rd config arg removed (basePath, maxDuration, sessionIdGenerator, …). createMcpHandler is now (initializeServer, options?) — collapsed the call to its one-arg form.
  • maxDuration → re-expressed as a Next.js route-segment export (export const maxDuration = 60), so the Vercel function budget is unchanged.
  • SSE transport removed in 2.x. The [transport] dynamic segment only existed to route /api/mcp vs /api/sse; with SSE gone it collapses to a static /api/mcp (v2's canonical mount — the public URL is unchanged).
  • Peer-dep swap: v2 requires @modelcontextprotocol/server ^2.0.0 (added explicitly for a deterministic npm ci) and no longer uses @modelcontextprotocol/sdk ^1.x (removed — imported nowhere after this). Lockfile shrinks ~870 lines.

Tool registrations are untouched — v2's server.registerTool(name, { title, description, inputSchema }, handler) and the zod raw-shape inputSchema still type-check and serialize identically.

Verification

  • next build (type-checks the full v2 integration), format:check, lint (0 errors — the lone react-hooks/set-state-in-effect warning pre-exists on main), 87/87 tests — all green locally.
  • Runtime smoke test against the built /api/mcp: initialize returns a valid handshake (protocol 2025-06-18, tools capability), and tools/list serves all five tools with correct JSON schemas.

Closes #155.

mcp-handler 2.x drops the 3rd config arg (basePath/maxDuration) and the SSE transport, and swaps its required peer dep to @modelcontextprotocol/server v2. Move the handler to a static /api/mcp route (the [transport] dynamic segment only existed for the now-removed SSE transport), collapse createMcpHandler to its one-arg form, and re-express maxDuration as a Next.js route-segment export. Drop the orphaned @modelcontextprotocol/sdk v1 (imported nowhere after this). Verified: next build, 87/87 tests, plus a live initialize + tools/list against the built /api/mcp endpoint.
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mark-sight Ready Ready Preview Aug 14, 2026 12:55am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant