unstale

npm / @modelcontextprotocol/sdk

@modelcontextprotocol/sdk

What changed in @modelcontextprotocol/sdk 1 to 2, from its official release notes, upgrade guides and advisories. Also covers @modelcontextprotocol/node. Sources checked 2026-11-30.

153 breaking12 security14 deprecations69 new APIs and options2 performance34 behavior and defaults4 tooling56 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

@modelcontextprotocol/sdk 2246 changes

Breaking changes 147

  • The bundled Ajv validator now rejects $id or $ref values with invalid URI schemes.

    2.4.0release notes

  • On a 2025-11-25 connection, results from outputSchema built with z.object(...).meta({ id }) are no longer wrapped in { result }; read structuredContent directly.

    2.4.0release notes

  • The annotation is rejected on number parameters; the client omits the tool and the server responds to calls with -32020. Use z.int() or remove the annotation.

    2.4.0release notes

  • The client requires version 3.0.8 or later, which reduces time and memory for large messages received as a single SSE event.

    2.3.0release notes

  • When arguments is omitted, validates it as {} instead of undefined, so top-level optional or default schemas no longer receive undefined.

    2.3.0release notes

  • HTTP client transports follow redirects only on the same origin by default; set redirectPolicy: 'follow' to permit cross-origin redirects.

    1.32.0, 2.3.0release notesrelease notessecurity advisory

  • Rejects connections while the server instance is already connected; create a server per request instead of sharing one across requests.

    2.3.0release notes

  • Checks whether the provider's client information is bound to the expected authorization server and throws AuthorizationServerMismatchError before sending anything if it is not.

    2.2.0release notes

  • The upgrade alone does not serve the 2026-07-28 revision; move the entry point to serveStdio or createMcpHandler to serve clients using it.

    2.0.0upgrade guide

  • The Zod-specific type alias is removed; replace it with StandardSchemaV1.

    2.0.0upgrade guide

  • Typed verbs perform async pre-work before sending; a same-tick abort can reject before the frame is sent and emits no notifications/cancelled, unlike v1.

    2.0.0upgrade guide

  • Output-schema validators compile lazily on the first callTool against the cached tools/list entry; compilation errors surface before the request is sent.

    2.0.0upgrade guide

  • The field type is widened from an object to unknown, allowing non-object JSON values; presence checks must compare against undefined rather than use truthiness.

    2.0.0upgrade guide

  • A transport that already exposes sessionId skips the initialize handshake, leaving capabilities undefined and list verbs empty; expose sessionId only after the first request.

    2.0.0upgrade guide

  • The result-schema argument is removed for spec methods.

    2.0.0upgrade guide

  • Caps automatic list pagination at 64 pages by default; exceeding the limit throws SdkError(ListPaginationExceeded).

    2.0.0upgrade guide

  • Role-aggregate unions and typed-method maps no longer include task vocabulary; deprecated Task* types remain individually importable.

    2.0.0upgrade guide

  • Optional completable schemas invert their nesting: apply optional() to the result of completable rather than to its schema argument.

    2.0.0upgrade guide

  • Localhost-class hosts now validate Origin by default. Browser clients from non-localhost origins need allowedOrigins; invalid or opaque Origin values are rejected.

    2.0.0upgrade guide

  • Use createMcpHandler(() => createServer()) as an entry point to serve both 2025-era and 2026-07-28 clients.

    2.0.0upgrade guide

  • The handler context replaces the extra parameter; context properties are remapped to ctx.mcpReq or ctx.http.

    2.0.0upgrade guide

  • HTTP-specific context is optional; authInfo, req, and SSE close helpers are accessed through ctx.http?. and may be undefined, including on stdio.

    2.0.0upgrade guide

  • The request ID is now accessed as ctx.mcpReq.id instead of extra.requestId.

    2.0.0upgrade guide

  • The request abort signal is now accessed as ctx.mcpReq.signal instead of extra.signal.

    2.0.0upgrade guide

  • HTTP request headers are now a standard Web Headers object, so read values with .get() instead of bracket access.

    2.0.0upgrade guide

  • New handler-context helper replacing server.elicitInput.

    2.0.0upgrade guide

  • Log notifications are request-related on every era and travel on the in-flight exchange; on 2025-era sessionful HTTP they move from standalone GET to per-request POST streams.

    2.0.0upgrade guide

  • The schema argument must be dropped from nested low-level send calls; the codemod does not rewrite these calls.

    2.0.0upgrade guide

  • In-flight request handlers are now aborted when the transport closes.

    2.0.0upgrade guide

  • Every request handler now receives a structured context object as its second parameter instead of the flat RequestHandlerExtra object; context types no longer take type parameters.

    2.0.0upgrade guide

  • Treats 502 Bad Gateway like 4xx and falls through to the next candidate URL; other 5xx responses still throw.

    2.0.0upgrade guide

  • Rejects metadata whose issuer does not exactly match the URL it was fetched for, unless the validation opt-out is used.

    2.0.0upgrade guide

  • The build layout changes to flat .mjs and .cjs siblings instead of /dist/cjs/ and /dist/esm/ flavor directories.

    2.0.0upgrade guide

  • Elicitation content values are restricted to string, number, boolean, or string arrays; arbitrary objects no longer compile or pass schema validation.

    2.0.0upgrade guide

  • ErrorCode is renamed to ProtocolErrorCode; RequestTimeout and ConnectionClosed move to SdkErrorCode.

    2.0.0upgrade guide

  • Exported from @modelcontextprotocol/server only.

    2.0.0upgrade guide

  • Client and server capability experimental payloads are now typed as JSON-compatible nested values rather than arbitrary objects.

    2.0.0upgrade guide

  • getSchemaDescription is removed and has no replacement.

    2.0.0upgrade guide

  • getSchemaShape is removed and has no replacement.

    2.0.0upgrade guide

  • For interactive DCR, defaults to authorization_code and refresh_token in the registration body unless explicitly set.

    2.0.0upgrade guide

  • Sampling's with-tools CreateMessageResult variant is now selected when either tools or toolChoice is present.

    2.0.0upgrade guide

  • IsomorphicHeaders is replaced with the Web Standard Headers type, which uses .get() and .set() rather than bracket access.

    2.0.0upgrade guide

  • hostHeaderValidation() moved to @modelcontextprotocol/express; its signature is unchanged.

    2.0.0upgrade guide

  • Frames failing typed message-shape validation are dropped and reported through onerror; no response is sent.

    2.0.0upgrade guide

  • Now exported from the client and server packages. Linked-pair halves must come from the same package import because the packages bundle separate copies with private state.

    2.0.0upgrade guide

  • Schema objects must implement Standard Schema; raw shapes remain accepted only through deprecated registerTool/registerPrompt overloads.

    2.0.0upgrade guide

  • Thrown when token operations use a non-HTTPS endpoint, except for the specified loopback hosts.

    2.0.0upgrade guide

  • A transport error reports insufficient scope when configured to throw or when a non-OAuth AuthProvider cannot reauthorize.

    2.0.0upgrade guide

  • This guard was removed; use isJSONRPCErrorResponse.

    2.0.0upgrade guide

  • The name now matches both result and error responses; use isJSONRPCResultResponse to preserve the v1 result-only behavior.

    2.0.0upgrade guide

  • IsomorphicHeaders is removed in favor of the Web Standard Headers object.

    2.0.0upgrade guide

  • isOptionalSchema is removed and has no replacement.

    2.0.0upgrade guide

  • The default validator dispatches by declared $schema: absent or 2020-12 uses 2020-12, 2019-09 uses 2019-09, and draft-07/06 uses draft-07; other dialects are rejected.

    2.0.0upgrade guide

  • This alias was removed; use JSONRPCErrorResponse.

    2.0.0upgrade guide

  • The JSONRPCError symbol is renamed to JSONRPCErrorResponse.

    2.0.0upgrade guide

  • This alias was removed; use JSONRPCErrorResponseSchema.

    2.0.0upgrade guide

  • The name now covers result and error responses; use JSONRPCResultResponse to preserve the v1 result-only behavior.

    2.0.0upgrade guide

  • The schema now accepts both result and error responses; use JSONRPCResultResponseSchema to preserve the v1 result-only behavior.

    2.0.0upgrade guide

  • Declared tools, resources, or prompts capabilities with empty objects are now advertised with listChanged: true; set false explicitly to opt out.

    2.0.0upgrade guide

  • Client list methods return empty results without sending a request when the server did not advertise the corresponding capability.

    2.0.0upgrade guide

  • Called without a cursor, client list methods fetch all pages and return an aggregate without nextCursor; passing a cursor still fetches one page.

    2.0.0upgrade guide

  • localhostHostValidation() moved to @modelcontextprotocol/express; its signature is unchanged.

    2.0.0upgrade guide

  • McpError is renamed to ProtocolError for protocol errors that cross the wire as JSON-RPC error responses.

    2.0.0upgrade guide

  • This API moved from shared/protocol.js to the client or server package root.

    2.0.0upgrade guide

  • The v1 SDK is split into packages; use this package for the client implementation.

    2.0.0upgrade guide

  • Stdio client transport and utilities moved to this subpath; the package root does not export them.

    2.0.0upgrade guide

  • Client middleware, FetchLike, InMemoryTransport, and AuthInfo are exported from the package root.

    2.0.0upgrade guide

  • A codemod package is available to mechanically migrate fixed v1-to-v2 renames and update package dependencies.

    2.0.0upgrade guide

  • Public Zod schema constants moved to this package; import raw *Schema constants from here.

    2.0.0upgrade guide

  • Built-in HTTP framework support is split into adapter packages; this adapter declares Express as a peer dependency.

    2.0.0upgrade guide

  • Built-in HTTP framework support is split into adapter packages; this adapter declares Fastify as a peer dependency.

    2.0.0upgrade guide

  • Built-in HTTP framework support is split into adapter packages; this adapter declares Hono as a peer dependency.

    2.0.0upgrade guide

  • Built-in HTTP framework support is split into adapter packages, including this Node adapter.

    2.0.0upgrade guide

  • Node HTTP deployments import NodeStreamableHTTPServerTransport from this package; web-standard runtimes use WebStandardStreamableHTTPServerTransport from @modelcontextprotocol/server.

    2.0.0upgrade guide

  • The v1 SDK is split into packages; use this package for the server implementation.

    2.0.0upgrade guide

  • Authorization Server helpers are available as a deprecated, frozen v1 copy; migrate Authorization Server functionality to a dedicated IdP/OAuth library.

    2.0.0upgrade guide

  • StdioServerTransport moved to this subpath; the package root does not export it.

    2.0.0upgrade guide

  • Web-standard deployments import WebStandardStreamableHTTPServerTransport here; the package also exports InMemoryTransport, server event-store types, and runtime-neutral auth helpers.

    2.0.0upgrade guide

  • Node.js 20 or newer is required to use v2.

    2.0.0upgrade guide

  • Run the codemod at the package root to rewrite v1-to-v2 imports, symbols, registrations, and package dependencies.

    2.0.0upgrade guide

  • In Node and Cloudflare Workers, fetch TypeError during OAuth discovery now throws instead of being swallowed as a CORS miss and returning undefined; browser behavior retains the CORS swallow.

    2.0.0upgrade guide

  • The OAuth error constant is removed.

    2.0.0upgrade guide

  • New base class for dedicated OAuth client-flow errors, distinct from OAuthError.

    2.0.0upgrade guide

  • Implementers must persist and round-trip issuer and discovery state, pass expectedIssuer and callback iss, protect refresh tokens, set application_type correctly, track cross-request step-up failures, and choose insufficient-scope handling.

    2.0.0upgrade guide

  • Replaces individual OAuth error classes; check error.code with OAuthErrorCode instead of using the removed classes.

    2.0.0upgrade guide

  • Token exchange and refresh now throw OAuthError when the authorization server returns HTTP 200 with a JSON error body.

    2.0.0upgrade guide

  • Stored tokens carry an optional issuer, and credentials stamped for another authorization server are treated as undefined on read.

    2.0.0upgrade guide

  • parseSchemaAsync is removed; validate directly with the schema library.

    2.0.0upgrade guide

  • Server entries validate the parsed media type and return 415 for POST requests whose type is not application/json; hand-rolled clients must set Content-Type.

    2.0.0upgrade guide

  • The Protocol base class moved from shared/protocol.js to the client or server package root; each package exports a distinct compiled class.

    2.0.0upgrade guide

  • With an already-aborted signal, request rejects with SdkError(RequestTimeout, reason) instead of throwing the raw signal.reason.

    2.0.0upgrade guide

  • The McpError symbol is renamed to ProtocolError.

    2.0.0upgrade guide

  • Reconstruct a typed protocol error from code, message, and data before throwing it from a relay handler; plain error-shaped objects are unspecified behavior.

    2.0.0upgrade guide

  • Relayed JSON-RPC error messages no longer include the MCP error code prefix; match error.code rather than rendered message text.

    2.0.0upgrade guide

  • ProtocolError replaces McpError for protocol errors sent as JSON-RPC error responses.

    2.0.0upgrade guide

  • ErrorCode is renamed to ProtocolErrorCode; local-only RequestTimeout and ConnectionClosed members move to SdkErrorCode.

    2.0.0upgrade guide

  • ProtocolErrorCode replaces ErrorCode for protocol error codes.

    2.0.0upgrade guide

  • Pins legacy initialize negotiation and supplies modern probe candidates when present; list order defines preference, and a list without a pre-2026 version makes the handshake throw.

    2.0.0upgrade guide

  • The experimental 2025-11 task side-channel through Protocol has been removed; remove task-related options and usages.

    2.0.0upgrade guide

  • Non-JSON stdout lines are silently skipped instead of causing a SyntaxError and onerror; JSON that fails JSON-RPC validation still throws.

    2.0.0upgrade guide

  • update() takes schema objects and does not auto-wrap raw shapes; wrap raw shapes with z.object() yourself.

    2.0.0upgrade guide

  • Replace the v1 .prompt() registration API with registerPrompt.

    2.0.0upgrade guide

  • Replace the v1 .resource() registration API with registerResource.

    2.0.0upgrade guide

  • cacheHint is now a reserved, validated configuration key and is stripped from resource list metadata; invalid values throw RangeError.

    2.0.0upgrade guide

  • Use this registration API with an explicit config object; a metadata argument is required, and pass {} when there is none.

    2.0.0upgrade guide

  • Replace the v1 .tool() registration API with registerTool.

    2.0.0upgrade guide

  • Use this registration API with an explicit config object; schema fields use Standard Schema.

    2.0.0upgrade guide

  • Task-specific tool registration and handler APIs have been removed.

    2.0.0upgrade guide

  • This type was removed; use ServerContext, ClientContext, or BaseContext.

    2.0.0upgrade guide

  • Transport-managed Authorization, mcp-protocol-version, and Streamable HTTP mcp-session-id headers take precedence over same-named configured headers.

    2.0.0upgrade guide

  • Exported method-union type used to select the spec-method handler overload when a method string is computed at runtime.

    2.0.0upgrade guide

  • Experimental task streaming methods, including requestStream and callToolStream, have been removed; remove usages.

    2.0.0upgrade guide

  • This type was renamed to ResourceTemplateReference.

    2.0.0upgrade guide

  • Reading an unknown URI answers -32602 on every protocol revision; peers may still send the tolerated legacy -32002 code.

    2.0.0upgrade guide

  • The spec wire type was renamed to ResourceTemplateType to resolve a name collision; the URI-template helper class is unchanged.

    2.0.0upgrade guide

  • The spec wire type imported from types.js is renamed from ResourceTemplate to ResourceTemplateType; the URI-template helper class keeps its name.

    2.0.0upgrade guide

  • SSE resumability behavior is enabled only for supported protocol versions at or above 2025-11-25; unknown future version strings no longer enable it.

    2.0.0upgrade guide

  • SchemaInput<T> is removed; the codemod rewrites it to StandardSchemaWithJSON.InferInput<T>.

    2.0.0upgrade guide

  • The Zod-specific type alias is removed; replace it with StandardSchemaV1.InferOutput.

    2.0.0upgrade guide

  • The Zod-specific schemaToJson helper is removed; use fromJsonSchema() for raw JSON Schema or the schema library's native conversion.

    2.0.0upgrade guide

  • Local-only error codes such as RequestTimeout and ConnectionClosed are routed to SdkErrorCode.

    2.0.0upgrade guide

  • StreamableHTTPError is renamed to SdkHttpError; constructor argument shape changed and calls need review.

    2.0.0upgrade guide

  • SdkHttpError now assigns its class name to .name; name-based classifiers must account for SdkHttpError.

    2.0.0upgrade guide

  • HTTP status is read from .status rather than .code on SdkHttpError.

    2.0.0upgrade guide

  • Construct SdkHttpError with an SdkErrorCode string as the first argument and HTTP status details in the third-argument data object.

    2.0.0upgrade guide

  • The v1 Zod JSON Schema compatibility module and toJsonSchemaCompat are removed.

    2.0.0upgrade guide

  • The deprecated variadic registration method was removed; use registerPrompt with an explicit config object.

    2.0.0upgrade guide

  • The deprecated variadic registration method was removed; use registerResource with an explicit config object.

    2.0.0upgrade guide

  • The deprecated variadic registration method was removed; use registerTool with an explicit config object.

    2.0.0upgrade guide

  • Use serveStdio(() => createServer()) as an entry point to serve both 2025-era and 2026-07-28 clients.

    2.0.0upgrade guide

  • Low-level notification-handler registration now uses method strings; spec handlers receive the full parsed notification envelope, while custom handlers use a schema-based three-argument form.

    2.0.0upgrade guide

  • Handler registration now takes a method string instead of a schema; the old schema-first form throws a TypeError at registration.

    2.0.0upgrade guide

  • Validators now validate the neutral model: result entries reject resultType, and 2025-only task message types and RequestMetaEnvelope are removed from the public set.

    2.0.0upgrade guide

  • Removed; migrate to Streamable HTTP. A frozen v1 copy is available as a temporary bridge.

    2.0.0upgrade guide

  • SchemaInput<T> is rewritten to StandardSchemaWithJSON.InferInput<T>.

    2.0.0upgrade guide

  • Outbound write failures reject the pending send and close the transport through onerror/onclose instead of surfacing an unhandled stream error.

    2.0.0upgrade guide

  • Custom requestInit.headers.Accept values are appended to the required application/json and text/event-stream media types instead of replacing them.

    2.0.0upgrade guide

  • StreamableHTTPError is removed; use SdkHttpError for HTTP transport errors.

    2.0.0upgrade guide

  • Task store and in-memory task store APIs have been removed.

    2.0.0upgrade guide

  • Non-existent tools, disabled tools, and inputSchema validation failures now return MCP protocol-level errors instead of CallToolResult values with isError: true.

    1.21.0, 2.0.0release notesupgrade guide

  • Advertised tool input schemas change shape to JSON Schema 2020-12 idioms, different additionalProperties handling, and no execution.taskSupport member.

    2.0.0upgrade guide

  • Validates the callback issuer against validated authorization-server metadata before exchanging the code; pass URLSearchParams to provide code and iss.

    2.0.0upgrade guide

  • unwrapOptionalSchema is removed and has no replacement.

    2.0.0upgrade guide

  • Removed because WebSocket is not a spec transport; use StreamableHTTPClientTransport for remote servers or StdioClientTransport for local servers.

    2.0.0upgrade guide

  • Raw Zod shapes supplied as inputSchema, outputSchema, argsSchema, or uriSchema are wrapped with z.object().

    2.0.0upgrade guide

  • The v2 packages depend on zod ^4.2.0; upgrading a zod@3-pinned workspace can deduplicate nested copies.

    2.0.0upgrade guide

  • Zod v3 is no longer supported; SDK-bound schemas must use Zod v4 or another Standard Schema implementation.

    2.0.0upgrade guide

Security 6

  • MCP TypeScript SDK: One HTTP request within the default size limit could exhaust server memory during validation

    1.32.0, 2.3.0security advisory

  • Adds expectedResource to accept only tokens issued for this server, based on the token's audience.

    1.32.0, 2.3.0release notesrelease notessecurity advisory

  • Handles one request, so create the server and transport inside the request handler or createMcpHandler factory.

    2.3.0release notessecurity advisory

  • MCP TypeScript SDK: OAuth client could send credentials to an authorization server chosen by the MCP server

    1.31.0, 2.2.0security advisory

  • createMcpHandler does not check Host or Origin headers; mount host and origin validation in front of it when using enableDnsRebindingProtection.

    2.0.0upgrade guide

  • Optional provider methods persist and retrieve discovery state so the callback leg can verify the authorization server targeted by the redirect.

    2.0.0upgrade guide

Deprecations 13

  • Machine-to-machine OAuth providers should be constructed with expectedIssuer set to the issuer of the authorization server the credentials were registered with; omitting it is deprecated and logs a warning.

    1.31.0, 2.2.0release notesrelease notes

  • New handler-context helper replacing server.sendLoggingMessage; it is deprecated, and its notification becomes request-related on every protocol era.

    2.0.0upgrade guide

  • New handler-context helper replacing server.createMessage; it is deprecated.

    2.0.0upgrade guide

  • Use fromJsonSchema() to register raw JSON Schema or to register host-converted consumer-authored schemas.

    2.0.0upgrade guide

  • Deprecated as of protocol version 2026-07-28; the deprecation is annotation-only and the API remains functional.

    2.0.0upgrade guide

  • The logging capability schema field is deprecated as of protocol version 2026-07-28.

    2.0.0upgrade guide

  • The method remains written for back-compat but is deprecated and is no longer read by the SDK.

    2.0.0upgrade guide

  • Dynamic Client Registration is deprecated; prefer Client ID Metadata Documents.

    2.0.0upgrade guide

  • The roots capability schema field is deprecated as of protocol version 2026-07-28.

    2.0.0upgrade guide

  • The sampling capability schema field is deprecated as of protocol version 2026-07-28.

    2.0.0upgrade guide

  • Deprecated as of protocol version 2026-07-28; remains functional with its v1 signature and wire behavior during the deprecation window.

    2.0.0upgrade guide

  • This accessor remains functional but is deprecated; on 2026-07-28 requests, prefer ctx.mcpReq.envelope.

    2.0.0upgrade guide

  • Deprecated as of protocol version 2026-07-28; remains functional with its v1 call signature and wire behavior.

    2.0.0upgrade guide

New APIs and options 43

  • Loads a folder of skills for a server to publish over MCP; supported on 2025-11-25 and 2026-07-28.

    2.4.0release notes

  • OAuthClientProvider can implement this method to include scope in token refresh requests when an authorization server requires it; the default request is unchanged.

    2.4.0release notes

  • ServerEvent accepts optional params, allowing gateways to forward change notifications with their _meta.

    2.4.0release notes

  • Attaches skills to a server for publication over MCP. This API is experimental and may change in a minor release.

    2.4.0release notes

  • Lets a client list, read, and verify skills published over MCP.

    2.4.0release notes

  • In @modelcontextprotocol/server-legacy, requireBearerAuth accepts the optional expectedResource to accept only tokens issued for this server. It is off unless set.

    2.3.1release notes

  • Adds an McpServer option that limits the number of array elements and object members in a tool call's arguments; it is off unless set.

    1.32.0, 2.3.0release notesrelease notes

  • Can be served and called on a 2026-07-28 connection as part of the Tasks extension.

    2.3.0release notes

  • Accepts the optional issuer field so a provider that reads its storage back through the schema keeps it.

    2.2.0release notes

  • Adapts an OAuthClientProvider for use with the widened transport authProvider option.

    2.0.0upgrade guide

  • The auth() inline options object becomes a named type with iss, skipIssuerMetadataValidation, and forceReauthorization fields.

    2.0.0upgrade guide

  • Reports a mismatch between a recorded authorization server and the current one.

    2.0.0upgrade guide

  • A minimal interface supports static-token and other non-OAuth bearer authentication; transports call token before requests and onUnauthorized after 401.

    2.0.0upgrade guide

  • Cacheable client verbs may return fresh server-stamped cached entries; per-call cacheMode can refresh or bypass the cache.

    2.0.0upgrade guide

  • connect accepts a cached era verdict through prior, allowing modern connections to skip discovery round trips or known legacy servers to skip the probe.

    2.0.0upgrade guide

  • Adds a client option for partitioning response-cache entries.

    2.0.0upgrade guide

  • Adds a client option for the default response-cache TTL.

    2.0.0upgrade guide

  • Set this option to true to restore the v1 throw when a list method is called for an unadvertised capability.

    2.0.0upgrade guide

  • Although v2 is ESM-first, it ships a CommonJS build so CommonJS projects can use require directly without a dynamic import shim.

    2.0.0upgrade guide

  • New exported type extending RequestOptions with prior?: PriorDiscovery.

    2.0.0upgrade guide

  • The legacy option can be set to 'reject' when creating a handler alongside routing for 2025-era clients.

    2.0.0upgrade guide

  • Use exported guards rather than the in operator to discriminate passthrough result unions, whose index signatures prevent property-based narrowing.

    2.0.0upgrade guide

  • Custom entries composing classifyInboundRequest or PerRequestHTTPServerTransport can use the exported helper to apply JSON Content-Type validation.

    2.0.0upgrade guide

  • Use isLegacyRequest to route HTTP-session requests to the transport serving 2025-era clients.

    2.0.0upgrade guide

  • Client and server export keyed type guards as a Zod-free alternative for checking MCP spec values.

    2.0.0upgrade guide

  • A dedicated error reports authorization-server issuer mismatches.

    2.0.0upgrade guide

  • Custom three-argument handlers now receive _meta, except reserved io.modelcontextprotocol/* envelope keys; strict parameter schemas should allow an optional _meta member.

    2.0.0upgrade guide

  • A typed ProtocolError subclass carries data.requiredCapabilities.

    2.0.0upgrade guide

  • Explicit validator subpaths expose named backend classes for customization; importing a backend subpath requires its corresponding peer dependency.

    2.0.0upgrade guide

  • Exported method-union type used to select the spec notification-handler overload for computed method strings.

    2.0.0upgrade guide

  • New exported type representing a cached modern discovery result or a legacy verdict.

    2.0.0upgrade guide

  • Reconstructs the typed subclass from code, message, and data, including plain wire shapes and SDK copies predating brand-matched instanceof.

    2.0.0upgrade guide

  • Gains an optional scope parameter that overrides clientMetadata.scope in the registration body.

    2.0.0upgrade guide

  • Registration rejection errors carry status, body, and submittedMetadata.

    2.0.0upgrade guide

  • A typed ProtocolError subclass for unknown resources carries .uri.

    2.0.0upgrade guide

  • ResponseCacheStore adds delete(key) for removing a cached entry.

    2.0.0upgrade guide

  • Result types are inferred from the method name through this map.

    2.0.0upgrade guide

  • SdkError represents local SDK errors that do not cross the wire and uses SdkErrorCode.

    2.0.0upgrade guide

  • Static isInstance guards brand-match errors across separately bundled SDK copies and narrow the type in TypeScript.

    2.0.0upgrade guide

  • SdkErrorCode identifies local SDK errors, including request timeouts and connection-closed errors.

    2.0.0upgrade guide

  • SdkHttpError extends SdkError for HTTP transport errors and exposes typed .status and .statusText fields.

    2.0.0upgrade guide

  • Client and server export synchronous StandardSchemaV1 validators as a Zod-free alternative to raw Zod schemas.

    2.0.0upgrade guide

  • The framework-agnostic validateHostHeader helper is available from @modelcontextprotocol/server.

    2.0.0upgrade guide

Performance 1

  • No longer converts tool schemas up front, avoiding repeated conversion on each request when a server is built per request.

    2.3.0release notes

Behavior and default changes 19

  • @modelcontextprotocol/node accepts version 1.x or 2.x; a new install resolves version 2.x.

    2.4.0release notes

  • Express, Fastify, and Hono app helpers accept <scheme>://* entries, allowing servers to admit MCP clients running as browser extensions.

    2.3.0release notes

  • Refreshes once after a 401 on connect instead of retrying without limit.

    2.3.0release notes

  • Accepts <scheme>://* origin entries, allowing servers to admit MCP clients running as browser extensions.

    2.3.0release notes

  • When called without a cursor, follows nextCursor until the server stops sending one, returning the whole list.

    2.2.0release notes

  • Hostnames ending in .localhost count as loopback for OAuth token endpoints, supporting host-based multi-tenant local setups.

    2.2.0release notes

  • The DCR default is derived from redirect_uris: loopback or custom URI schemes use native; otherwise web.

    2.0.0upgrade guide

  • The transport option now accepts AuthProvider or OAuthClientProvider; OAuthClientProvider implementations continue to work through an internal adapter.

    2.0.0upgrade guide

  • Spec-method calls no longer require a result-schema argument; the SDK resolves it from the method name.

    2.0.0upgrade guide

  • Use the raw request method for page-level observation; unlike typed list verbs, it never aggregates pagination.

    2.0.0upgrade guide

  • Spec-method sends no longer require a result-schema argument; custom methods still do.

    2.0.0upgrade guide

  • The in-memory response cache is now bounded, with a default capacity of 512 entries.

    2.0.0upgrade guide

  • The SDK selects a JSON Schema validator by runtime: AJV on Node.js and @cfworker/json-schema on Cloudflare Workers; Workers users can remove explicit configuration.

    2.0.0upgrade guide

  • McpServer installs handlers for declared primitive capabilities even with no registrations, so empty list requests return empty results rather than Method not found.

    2.0.0upgrade guide

  • Tool output schemas may now have non-object roots; for non-object structuredContent without its own text block, the SDK auto-appends a JSON.stringify text block.

    2.0.0upgrade guide

  • Spec-method calls no longer require a result schema; the SDK resolves and validates the spec result by method name. Custom methods still require a schema, and arbitrary-method relays must keep passing one.

    2.0.0upgrade guide

  • A buffer limit is added for v1 stdio.

    1.30.0, 2.0.0release notesupgrade guide

  • Objects and nominal types from v1-imported and v2-imported code do not interoperate; keep them separated across process or transport boundaries.

    2.0.0upgrade guide

  • Request-related events emitted after closeSSE(), and final responses without a connected per-request stream, are persisted to eventStore for replay.

    2.0.0upgrade guide

Tooling 2

  • The codemod keeps a file's leading comment block and directives above the rewritten imports.

    2.2.0release notes

  • CommonJS test runners such as Jest no longer need a moduleNameMapper workaround to import the v2 packages; remove v1 mappings to dist/*.mjs.

    2.0.0upgrade guide

Fixes and other changes 15

  • The handler now sends Allow: POST on every 405 response.

    2.4.0release notes

  • A Server connected to a per-request transport at a modern revision now binds that revision instead of answering -32022.

    2.4.0release notes

  • Updating the title of a resource or resource template now appears in list responses.

    2.4.0release notes

  • Becomes a regular dependency of @modelcontextprotocol/node, so installs with strict peer-dependency checking no longer fail.

    2.3.0release notes

  • Types the callback correctly when no argsSchema is given.

    2.3.0release notes

  • Reports when a probe receives an unusable 2xx reply instead of presenting it as a network failure.

    2.3.0release notes

  • No longer lets a rejection escape as a process-level unhandled rejection, and no longer hangs when a send never settles.

    2.2.0release notes

  • No longer overflows the stack when the factory returns the same server instance for more than one request; a fresh instance per request is still required.

    2.2.0release notes

  • Inlining the jose types used by the DPoP API in declaration files restores type-checking for CommonJS TypeScript projects.

    2.2.0release notes

  • Preserves _meta on input_required results.

    2.2.0release notes

  • Sending a notification on a closed connection no longer produces a briefly unhandled promise rejection.

    2.2.0release notes

  • createMcpHandler ends a subscriptions/listen stream right after the acknowledgement when it honored none of the requested notification types.

    2.2.0release notes

  • CacheEntry.value and the set() entry value are JSON-serialized result documents (string), not unknown; persist and return the value verbatim.

    2.0.0upgrade guide

  • On the legacy era, inbound results missing content default to []; 2026-07-28 connections remain strict, and content-less handler results are normalized before reaching the wire.

    2.0.0upgrade guide

  • The stdio implementation always sets windowsHide on Windows, rather than doing so only in Electron.

    1.29.0, 2.0.0release notesupgrade guide

@modelcontextprotocol/sdk 198 changes

Breaking changes 6

  • Stored OAuth tokens and client information now include an issuer field; storage that rejects unknown fields needs to allow it.

    1.31.0release notes

  • Null requested TTLs are disallowed, preventing an infinite TTL.

    1.29.0release notes

  • Plain JSON Schema objects passed as inputSchema are now rejected.

    1.28.0release notes

  • Removes loose or passthrough types not allowed or defined by the MCP spec, along with Task types.

    1.25.0release notes

  • Updates the signature to provide a properly typed ToolCallback.

    1.24.0release notes

  • Request payloads are decoupled and passthrough iteration is removed.

    1.22.0release notes

Security 6

  • Keep tasks in the in-memory task store within the session that created them.

    1.32.0release notessecurity advisory

  • HTTP request bodies are read with a size limit, preventing unbounded body reads.

    1.30.1release notes

  • MCP TypeScript SDK: HTTP server transports and handlers did not limit request body size or JSON-RPC batch length

    1.30.1security advisory

  • @modelcontextprotocol/sdk has cross-client data leak via shared server/transport instance reuse

    1.26.0security advisoryrelease notes

  • Anthropic's MCP TypeScript SDK has a ReDoS vulnerability

    1.25.2security advisoryrelease notes

  • Model Context Protocol (MCP) TypeScript SDK does not enable DNS rebinding protection by default

    1.24.0security advisory

Deprecations 1

  • Marks the old elicitInput overload as deprecated.

    1.23.0release notes

New APIs and options 26

  • Servers and clients can advertise extensions in the capability object.

    1.29.0release notes

  • Adds discoverOAuthServerInfo() to v1.x for discovering OAuth server information.

    1.27.0release notes

  • Adds a url property to the RequestInfo interface.

    1.27.0release notes

  • Adds streaming methods for elicitation and sampling.

    1.27.0release notes

  • Client Credentials providers now support scopes.

    1.26.0release notes

  • Changed handlers can be listed on the client constructor.

    1.25.0release notes

  • Adds a fetch transport.

    1.25.0release notes

  • The Icon schema gains a theme property.

    1.25.0release notes

  • The Implementation schema gains an optional description field.

    1.25.0release notes

  • Role is now a reusable type instead of an inline type.

    1.25.0release notes

  • Resource annotations are now optional, allowing developers to include them when defining resources.

    1.24.2release notes

  • Adds a client credentials flow for machine-to-machine use without user interaction.

    1.24.0release notes

  • Adds a closeSSEStream callback to RequestHandlerExtra.

    1.24.0release notes

  • Adds closeStandaloneSSEStream for GET stream polling.

    1.24.0release notes

  • Adds backwards-compatible overloads for SEP-1577.

    1.24.0release notes

  • Adds the invalid_target OAuth error from RFC 8707.

    1.24.0release notes

  • Adds task support in line with SEP-1686.

    1.24.0release notes

  • Adds URL-based client metadata registration.

    1.23.0release notes

  • Implements sampling with tools.

    1.23.0release notes

  • Implements SSE polling via server-side disconnect.

    1.23.0release notes

  • Adds URL-based elicitation support.

    1.23.0release notes

  • Supports Zod v4 while retaining backwards compatibility with v3.25+.

    1.23.0release notes

  • Elicitation schemas support default values.

    1.22.0release notes

  • registerTool accepts ZodType<object> for input and output schemas, allowing object schemas to be used for both.

    1.22.0release notes

  • Tool names have a specified format.

    1.22.0release notes

  • JSON schema validator providers are now pluggable, allowing developers to use different validators.

    1.21.0release notes

Performance 1

Behavior and default changes 15

  • Registration is allowed after connect() when the capability was declared.

    1.32.2release notes

  • Accept tools/call and prompts/get requests that omit arguments.

    1.32.0release notes

  • JSON-RPC batch length is bounded.

    1.30.1release notes

  • The Streamable HTTP server transport sends SSE keep-alive comment frames.

    1.30.0release notes

  • Loopback port handling was relaxed to align with RFC 8252.

    1.28.0release notes

  • Resource metadata is now used by default to determine supported scopes.

    1.28.0release notes

  • When the server omits this field, the SDK now defaults to client_secret_basic.

    1.28.0release notes

  • Adds validation for protocol dates.

    1.25.0release notes

  • Allows HTTP issuer URLs when development mode is enabled.

    1.24.0release notes

  • Request header validation now allows requests without an Origin header because they are not relevant to server DNS rebinding protection.

    1.24.0release notes

  • Uses catchall on inputSchema and outputSchema to support JSON Schema 2020-12.

    1.23.0release notes

  • Adjusts authentication scope management to align with SEP-835.

    1.23.0release notes

  • Supports upscoping after an insufficient_scope 403 response.

    1.23.0release notes

  • Metadata discovery uses only path-based discovery URLs from the authorization server.

    1.21.1release notes

  • An empty string is now accepted as a valid URL in the DCR workflow.

    1.20.1release notes

Tooling 2

  • Typing exports are added to the package, enabling consumers to resolve the package's TypeScript types.

    1.29.0release notes

  • Adds an ESLint rule to prefer node protocols.

    1.24.0release notes

Fixes and other changes 41

  • Optional Transport properties now explicitly include undefined in their types.

    1.32.2release notes

  • Authentication preserves resource URIs without a trailing slash.

    1.30.1release notes

  • Content-Type is validated using its parsed media type rather than a substring match.

    1.30.0release notes

  • Fixes the lifecycle of the Streamable HTTP server transport's SSE keep-alive timer.

    1.30.0release notes

  • Supports Zod 3.25 method literals.

    1.30.0release notes

  • Server errors prioritize Zod issues and format them, making validation failures clearer.

    1.30.0release notes

  • The v1.x branch is treated as the primary branch for the npm latest tag, affecting which release users receive when installing the package without specifying a version.

    1.29.0release notes

  • ResourceSchema gains the missing size field, making that field available in the schema's types.

    1.29.0release notes

  • onerror is now called for transport errors that were previously silently swallowed, allowing developers to handle those errors.

    1.27.1release notes

  • Uses the correct schema for client sampling validation when tools are present.

    1.25.3release notes

  • Prevents Hono from overriding the global Response object.

    1.25.3release notes

  • Spec types received backwards compatibility changes.

    1.25.1release notes

  • Automatic completion support is not provided unless needed.

    1.25.0release notes

  • Fixes support for updating the output schema.

    1.25.0release notes

  • Fixes schema description extraction for Zod v4.

    1.25.0release notes

  • closeSSEStream is skipped for old protocol versions.

    1.24.3release notes

  • HTTP connections are released after POST responses.

    1.24.3release notes

  • Priming events are skipped for old protocol versions.

    1.24.3release notes

  • Fixes infinite retries when maxRetries is set to 0.

    1.24.1release notes

  • Updates the protocol version to 2025-11-25.

    1.24.1release notes

  • Normalizes null to undefined in the content field.

    1.24.0release notes

  • Coerces expires_in to a number.

    1.24.0release notes

  • HTTP error response bodies are now consumed.

    1.24.0release notes

  • Fixes JSON parse errors for SSE events with empty data.

    1.24.0release notes

  • Improves SSE reconnection behavior.

    1.24.0release notes

  • Normalizes headers in the SSE transport.

    1.24.0release notes

  • Fixes stdio servers hanging.

    1.24.0release notes

  • Fixes transport instantiation.

    1.24.0release notes

  • Client send() now uses StreamableHTTPError instead of a plain Error.

    1.24.0release notes

  • Calls tasks/result to deliver side-channel messages.

    1.24.0release notes

  • Allows Zod 4 transformations.

    1.24.0release notes

  • Fixes optional argument handling in prompts for Zod V4.

    1.24.0release notes

  • Disabled SSE priming events to preserve backwards compatibility with clients that crash on empty SSE data.

    1.23.1release notes

  • Updates handling to match upstream RC schema changes for form mode elicitation requests.

    1.23.0release notes

  • Auth requests now receive the RequestInit options.

    1.23.0release notes

  • Validates constraints for tools, tool_use, and tool_result in sampling.

    1.23.0release notes

  • Fixes the March spec fallback for metadata discovery.

    1.22.0release notes

  • Support the scope parameter in WWW-Authenticate for SEP-835.

    1.21.1release notes

  • The SDK now prefers the token_endpoint_auth_method returned by DCR registration.

    1.21.0release notes

  • Fixes handling of Zod-to-JSONSchema pipe strategies.

    1.20.2release notes

  • Auth metadata requests now include an Accept header.

    1.20.1release notes