Skip to content

feat!: move to MCP TypeScript SDK v2 - #142

Merged
mattpodwysocki merged 2 commits into
mainfrom
feat/mcp-sdk-v2
Oct 26, 2026
Merged

mattpodwysocki merged 2 commits into
mainfrom
feat/mcp-sdk-v2

Conversation

@mattpodwysocki

Copy link
Copy Markdown
Contributor

Part of mapbox/mcp-server#245, same move as mapbox/mcp-server#296.

Moves us from @modelcontextprotocol/sdk 1.x to the v2 SDK packages (@modelcontextprotocol/server and /core 2.3.1) and ext-apps 2.0.3.

What changed

Most of it is the official codemod (npx @modelcontextprotocol/codemod v1-to-v2 .). On top of that:

  • SDK patch replaced. v2 fails a tool call when structuredContent doesn't match the output schema or is missing, which is what our patch stopped in v1. lenientOutputSchema (same as mcp-server) keeps the real schema in tools/list and only warns. Text-only results from a tool with an output schema get structuredContent: {}. patches/ is now empty. New tests make real tools/call requests through McpServer and fail without the wrapper.
  • Prompt args now go in as z.object(...), since v2 deprecates bare Zod shapes there.
  • Test auth contexts moved to the v2 { http: { authInfo } } shape (path-traversal and map preview UI tests), so the token actually reaches the code under test.
  • @modelcontextprotocol/client is a dev dependency, tests only.

Clients

Nothing changes. It still negotiates 2025-11-25 and the MCP Apps UI resources serve the same way.

Heads up

  • Hosted has to move in the same release (mapbox/hosted-mcp-server, draft PR coming). installTo(server) needs a v2 McpServer. A v1 package still registers fine on a v2 server but reads the token from the wrong place, so hosted pins v2 releases of all three server packages together.
  • @mcp-ui/server 6.1.0 (latest) still depends on the v1 SDK, so v1 stays in node_modules under it. We only call createUIResource(), which builds a plain object, so the two SDKs never touch.

Testing

  • npm test: 51 files, 646 tests passing
  • Lint: 0 errors (124 warnings, same as main)
  • Build: ESM and CJS both build; the CJS dist installs all 23 tools on a v2 McpServer
  • stdio smoke test: handshake (2025-11-25), 23 tools (16 output schemas, all 2020-12), offline tool calls return structuredContent, 6 resources including both ui:// ones as text/html;profile=mcp-app, 7 prompts, clean stderr
  • Checked inside hosted-mcp-server against local v2 builds of all three servers: 153 tests passing

🤖 Generated with Claude Code

Swaps @modelcontextprotocol/sdk 1.x for the v2 packages
(@modelcontextprotocol/server and /core, plus /client for tests) and
ext-apps 2.0.3, same as mapbox/mcp-server#296. Ran the official
v1-to-v2 codemod, then:

- Replace the SDK output-validation patch with lenientOutputSchema, a
  Standard Schema wrapper that keeps the real schema in tools/list but only
  warns on a mismatch. Tools that return text only get structuredContent {}.
- Register prompt argument schemas as z.object(), since v2 deprecates raw
  shapes.
- Move test request contexts to the v2 shape (http.authInfo) so the token
  checks actually run.
- Add tests that make a real tools/call through McpServer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattpodwysocki
mattpodwysocki requested a review from a team as a code owner October 21, 2026 19:33
@mattpodwysocki mattpodwysocki added the enhancement New feature or request label Oct 21, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattpodwysocki
mattpodwysocki merged commit bf1752d into main Oct 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants