Index of every page on this site: llms.txt
All skills
modelcontextprotocol avatar

/mcp-typescript-sdk-upgrade-to-v2

@5ee54ee
Run it yourself

Upgrades TypeScript code from v1 of the MCP TypeScript SDK (`@modelcontextprotocol/sdk`) to v2 (`@modelcontextprotocol/client`, `/server`, `/core` and the middleware packages): runs the official codemod, then works through what it cannot rewrite. Use whenever a project depends on `@modelcontextprotocol/sdk` and the user wants to migrate, upgrade, port or bump it to v2, or is fixing v1-to-v2 breakage such as missing `McpError`, `RequestHandlerExtra` or `*Schema` exports, `@mcp-codemod-error` markers, or changed auth, error, transport or handler behavior, even if they do not say "migration".

Use this Skill: https://skilld.dev/gh/modelcontextprotocol/typescript-sdk/mcp-typescript-sdk-upgrade-to-v2

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesunchanged-apis.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Unchanged APIs

The following are unchanged between v1 and v2 apart from the import path — except where an entry notes its own signature change:

  • Client constructor and connect, close, and the typed verbs (listTools, listPrompts, listResources, readResource, …) — note callTool() and request() signatures changed (schema parameter dropped for spec methods).
  • McpServer constructor, server.connect(transport), server.close(), and the McpServer.server accessor — still the supported way to call the low-level Server's push verbs (createMessage / listRoots / sendLoggingMessage — ⚠ @deprecated, see §Deprecated in v2) outside a handler context.
  • The server Streamable HTTP transports' constructor options (sessionIdGenerator, onsessioninitialized, onsessionclosed, enableJsonResponse, eventStore, retryInterval) and the handleRequest surface — only the class name and import moved: StreamableHTTPServerTransport is now NodeStreamableHTTPServerTransport from @modelcontextprotocol/node, a thin wrapper over WebStandardStreamableHTTPServerTransport from @modelcontextprotocol/server, which exposes the same options (decision rule). The transport-level closeSSEStream(requestId) / closeStandaloneSSEStream() methods keep their v1 names too — only the handler-context accessors moved to ctx.http (remap table).
  • UriTemplate (v1: @modelcontextprotocol/sdk/shared/uriTemplate.js) — expand / match semantics carry over; import it from @modelcontextprotocol/server or @modelcontextprotocol/client (top-level export; the codemod rewrites the path).
  • StreamableHTTPClientTransport, SSEClientTransport constructors and options — including resumability: the per-request resumptionToken / onresumptiontoken request options carry over from v1 unchanged (Resume a dropped stream).
  • StdioClientTransport and StdioServerTransport — import path moved to the ./stdio subpath and gained an optional maxBufferSize (Imports & transports).
  • The Transport interface contract — start / send / close, onmessage / onclose / onerror, optional sessionId and setProtocolVersion, TransportSendOptions, MessageExtraInfo. Hand-rolled v1 transports (recording wrappers, test doubles, decorators) compile and run against v2 with only the import path updated. v2 adds optional members only — hasPerRequestStream and setSupportedProtocolVersions on the interface, requestSignal / headers / onRequestStreamEnd on TransportSendOptions — which matter only for 2026-era per-request-stream cancellation and Mcp-Param-* header attachment (support-2026-07-28.md).
  • All TypeScript type definitions from types.ts (except the aliases listed under Removed type aliases and the experimental capability payload narrowing — see Types & schemas).
  • Tool, prompt, and resource callback return types.

The Server (low-level) constructor and most of its methods are unchanged, but setRequestHandler / setNotificationHandler and request() signatures changed (Low-level protocol). In particular, Server.createElicitationCompletionNotifier() is unchanged — including its construction-time client-capability check — for 2025-era URL-mode elicitation (support-2026-07-28.md). The Zod *Schema constants are not part of the unchanged surface — they moved to @modelcontextprotocol/core (Types & schemas).

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts23d3 checks · Risk SAFE
  • Gen Agent Trust Hub23d

    This skill is a migration guide for the Model Context Protocol (MCP) TypeScript SDK. It provides instructions and an official codemod tool to help users upgrade their projects from v1 to v2. No security issues were detected.

  • Socket26d

    No alerts

  • Snyk26d

    Risk: LOW · No issues

Signed by skilld at 5ee54ee. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month

README badge

README badge for modelcontextprotocol/typescript-sdk/mcp-typescript-sdk-upgrade-to-v2