fix(deps): migrate MCP route to mcp-handler v2 - #158
Open
Rinava wants to merge 1 commit into
Open
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)
basePath,maxDuration,sessionIdGenerator, …).createMcpHandleris 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.[transport]dynamic segment only existed to route/api/mcpvs/api/sse; with SSE gone it collapses to a static/api/mcp(v2's canonical mount — the public URL is unchanged).@modelcontextprotocol/server^2.0.0 (added explicitly for a deterministicnpm 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-shapeinputSchemastill type-check and serialize identically.Verification
next build(type-checks the full v2 integration),format:check, lint (0 errors — the lonereact-hooks/set-state-in-effectwarning pre-exists on main), 87/87 tests — all green locally./api/mcp:initializereturns a valid handshake (protocol 2025-06-18, tools capability), andtools/listserves all five tools with correct JSON schemas.Closes #155.