Skip to content

feat: MCP v2 (draft)#2843

Open
KKonstantinov wants to merge 1 commit into
upstash:masterfrom
KKonstantinov:feature/mcp-v2-migration-draft
Open

feat: MCP v2 (draft)#2843
KKonstantinov wants to merge 1 commit into
upstash:masterfrom
KKonstantinov:feature/mcp-v2-migration-draft

Conversation

@KKonstantinov

Copy link
Copy Markdown

Migrate @upstash/context7-mcp to MCP TypeScript SDK v2

Summary

This PR migrates the packages/mcp server (@upstash/context7-mcp) from the MCP
TypeScript SDK v1 (@modelcontextprotocol/sdk) to v2
(@modelcontextprotocol/server + @modelcontextprotocol/node).

It is a mechanical, behavior-preserving migration — no tool logic, prompts, transport
wiring, or runtime behavior changed. The bulk of it was produced by the official
@modelcontextprotocol/codemod and then reviewed by hand.

Why v2

v2 replaces the single monolithic @modelcontextprotocol/sdk package with a set of
focused, ESM-only packages:

  • @modelcontextprotocol/server — the runtime-neutral server API (McpServer,
    stdio transport, shared types).
  • @modelcontextprotocol/node — the Node.js HTTP transport
    (NodeStreamableHTTPServerTransport).

The result is a smaller dependency surface, a cleaner public API, and first-class
support for non-Node runtimes. v1 is being superseded, so new work should target v2.

What changed (high level)

Area Before (v1) After (v2)
Dependencies @modelcontextprotocol/sdk @modelcontextprotocol/server + @modelcontextprotocol/node
Imports deep paths under @modelcontextprotocol/sdk/... the two new packages
Tool input schemas raw Zod shape { query: z.string() } wrapped z.object({ query: z.string() })
Low-level handlers setRequestHandler(ListPromptsRequestSchema, …) setRequestHandler("prompts/list", …)
HTTP transport StreamableHTTPServerTransport NodeStreamableHTTPServerTransport

Two concrete illustrations:

// Tool schemas now use Standard Schema — raw shapes are wrapped in z.object()
inputSchema: z.object({
  query: z.string().describe("…"),
  libraryName: z.string().describe("…"),
}),

// Low-level handlers take a method string instead of a Zod request schema
server.server.setRequestHandler("prompts/list", async () => ({ prompts: [] }));
server.server.setRequestHandler("resources/list", async () => ({ resources: [] }));
server.server.setRequestHandler("resources/templates/list", async () => ({ resourceTemplates: [] }));

What did NOT change

  • Tool names, descriptions, annotations, and arguments.
  • The Express/Streamable-HTTP and stdio serving logic.
  • Auth, JWT handling, session store, and API-call code.
  • The zod dependency (already ^4.4.3; v2's Standard Schema requirement is satisfied
    by Zod v4).

How this was produced

Generated with the official MCP v1→v2 codemod and reviewed by hand:

npx @modelcontextprotocol/codemod packages/mcp/src

Verification

All package checks pass after the migration:

  • typecheck (tsc --noEmit)
  • build (tsc)
  • test (vitest run) — 12/12 passing
  • lint (eslint .)

Before merging

  • v2 is currently pre-release (2.0.0-alpha.3). The dependency pins reflect that.
    Recommend merging once v2 reaches a stable release and re-pinning to the GA version.
  • The minimumReleaseAgeExclude: ['@modelcontextprotocol/*'] entry added to
    pnpm-workspace.yaml exempts the SDK packages from this repo's 7-day
    minimumReleaseAge gate so the pre-release versions can be installed. It can be
    removed once the depended-on v2 release is older than that window.

Roadmap

  • Initial alpha draft
  • Update to beta (legacy era MCP on modern interfaces)
  • Update to stable - backwards compatible with legacy era MCP clients; enabling Modern stateless MCP will need context7 maintainers support

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