Minor Changes
-
#2393
e4e8b22Thanks @felixweinberger! - Three migration-sweep fixes.completable()calls whose first argument is an optional-wrapped schema are rewritten to apply.optional()to thecompletable(...)result — v2 resolves completion metadata after unwrapping an outer optional wrapper, so the v1 nesting produced empty completion lists without an error; wrapper shapes the codemod cannot invert get an action-required marker instead. Imports ofProtocolandmergeCapabilitiesfrom v1'sshared/protocol.jsare no longer rewritten to a member the v2 packages do not export: the symbols are dropped from the rewritten import and an action-required marker explains the replacement (fallbackRequestHandlerfor unrouted inbound requests; a plain object spread for capability merging). The manifest zod-range warning now describes the symptom by vintage — zod 4.0–4.1 ranges fail type-checking (TS2769), while zod-3 ranges fail type-checking or at the firsttools/listdepending on the imported zod entry point. -
#2393
e4e8b22Thanks @felixweinberger! - Migration-sweep batch. The ErrorCode split now coordinates with the surrounding check: an all-SDK condition'sinstanceof ProtocolError/McpErrorguard is rewritten toSdkError, a guard covering both enums gets a marker asking for a split, and anErrorCodeimport with no rewritable member access on a v2 specifier is dropped with a marker instead of failing at module link time. Wrapping a raw shape withz.object()addsimport { z } from 'zod'when the file has nozvalue binding (a non-importzbinding gets a marker instead). The context-parameter rewrite finds the trailingextraparameter, covering the three-argumentregisterResourcetemplate callback without flagging itsvariablesargument. Resource-server auth helpers routed to the frozen server-legacy copy get a marker on value imports and barrel re-exports (an info note for type-only imports), every rewrittenSdkHttpErrorconstructor site gets a marker, and single-argumentfinishAuth(...)calls in files the run changes get a run-log note (the one-argumentURLSearchParamsform is valid v2, so the note never re-fires on already-migrated trees). The codemod accepts a single source file as target — source rewrites scope to that file and manifest changes are reported, not applied — and the no-changes summary distinguishes "already on the v2 packages", "still on the v1 SDK under a transform subset", and "no MCP SDK imports found". -
#2393
e4e8b22Thanks @felixweinberger! - Overhaul manifest handling. The codemod now discovers workspace-member manifests (npm/yarn/bunworkspacesandpnpm-workspace.yaml), writes only the nearestpackage.json, and reports the exact dependency changes every other affected manifest needs, so you can apply them deliberately. The v2 additions are computed from the post-transform import state of the files each manifest owns, so already-migrated packages still receive the packages their imports need when the v1 dependency is removed; in hoisted monorepos, member usage counts toward the manifest that declares the SDK dependency, with a note naming the contributing members. File collection no longer follows symbolic links (pnpmnode_moduleslayouts contain cycles that previously aborted the run) and honors--ignorepatterns during directory descent. Manifests whosezodrange cannot satisfy the v2 floor get a warning describing the runtime failure mode.RunnerResult.packageJsonChangesis now an array of per-manifest changes with optionalwarningsandnotes.
Patch Changes
-
#2393
e4e8b22Thanks @felixweinberger! - Backlog fixes. When the zod import injection fires in a package that declares no zod, the manifest pass adds it (devDependencies when only tests import it) so strict node_modules layouts install cleanly. The ErrorCode-split pairing re-points staleas ProtocolError/as McpErrorcasts bound to subjects whose assertions it moves toSdkError. Handler registration resolves one same-file variable hop (const S = ListToolsRequestSchema) before declaring a schema custom. Shorthand and aliased destructures of SDK dynamic imports rename with the static-import pass. Call-shape assertions pinning a registration schema (expect.objectContaining({ inputSchema: … })) get an advisory. The guide covers dist-text pins (no CJS-resolvable subpaths, content-hashed chunks, changed quote style, ESM-only output). -
#2393
e4e8b22Thanks @felixweinberger! - Fixes from migrating two large consumers. Registrations nested inside another handler's body no longer crash the transform with a whole-file rollback (calls process inner-first). Legacy.tool()/.prompt()/.resource()calls migrate without a directMcpServerimport when their shape matches the v1 signature AND the receiver is named like an MCP server (server,harness.mcp,this.mockServer); other receivers are left alone, without hard markers, since their type is unknown to the codemod.setRequestHandler/setNotificationHandlerwith a schema expression first argument get a marker pointing at the typed two-argument or custom three-argument form instead of being skipped silently, andremoveRequestHandler/removeNotificationHandlerwithSchema.shape.method.valuearguments rewrite to the method string. Destructured trailing callback parameters only count as the context when their keys look like context members, so template-variable destructures stop collecting false markers. The manifest zod note only appears for manifests that actually take part in the migration. -
#2393
e4e8b22Thanks @felixweinberger! - Two long-standing intervention classes now migrate mechanically..codereads on values aninstanceof SdkHttpErrorcheck proves — in the same condition or the guarded block — rewrite to.status(v2 carries the HTTP status there;.codeis anSdkErrorCodestring); unprovable reads keep the existing warning. The context-property remap reaches three shapes the call-site scan missed: functions assigned tofallbackRequestHandler, parameters annotated with a context type directly or via a same-file alias (accesses remap in place, the parameter keeps its name), and contexts forwarded wholesale to helpers, which get an advisory naming the callee. -
#2286
1823aaeThanks @felixweinberger! - The v1→v2 codemod no longer rewritestaskStore/taskMessageQueueMcpServer constructor options intocapabilities.tasks— that target does not exist in v2 (the experimental tasks runtime was removed, SEP-2663). The codemod now leaves the code untouched and emits an action-required diagnostic telling migrators to remove the option, matching the removal guidance already given forexperimental/tasksimports and the migration guide. -
#2386
36055d5Thanks @KKonstantinov! - Preserve a leading#!shebang (and the blank lines after it) when migrating a file. Some transforms drop the shebang because it is leading trivia of the first import they rewrite; the codemod now captures it before transforms and restores it before saving, so CLI packages whosebinpoints at the migrated entry keep working. -
#2393
e4e8b22Thanks @felixweinberger! - The explicit-undefinedresult-schema removal now requires the same proof as the schema-identifier path:request()calls must carry a provably literal spec method, andcallTool()calls whose first argument is a primitive are left alone. Previously, any file importing an MCP package could have the middle argument deleted from an unrelated.request()/.callTool()member call on a non-SDK receiver (e.g. a bespokeend.request('ping', undefined, id)helper), corrupting the call. -
#2286
1823aaeThanks @felixweinberger! - v1-to-v2: now wrapsoutputSchemaraw shapes withz.object(); importMap coverssdk/server/express.js,sdk/server/middleware/hostHeaderValidation.js, andsdk/client/auth-extensions.js. The unreachableexpressMiddlewaretransform is removed. -
#2383
9f8ba61Thanks @felixweinberger! - Keep the result-schema argument onrequest()calls unless the method is a literal spec method, and keep the generic passthroughResultSchemaeven then. Schema-less v2request()enforces the spec result schema for spec methods and throws aTypeErrorfor non-spec methods, so dropping the schema from a dynamic-method call site (the proxy/forwarder shape,request({ method, params }, ResultSchema)) or from a custom-method call broke the call.callTool()is unaffected — v2callTool()has no schema parameter.