The Model Context Protocol (MCP) TypeScript SDK has released version 2.2.0, bringing updates to several core packages including @modelcontextprotocol/client and @modelcontextprotocol/server 1. This release focuses on bolstering security for machine-to-machine OAuth communications and improving data retrieval efficiency for list operations 1.
Developers using the SDK, which implements the 2026-07-28 MCP specification 2 and runs on Node.js, Bun, and Deno environments 2, should review the changes, particularly regarding OAuth provider configuration 1. For a deeper understanding of the protocol itself, refer to /articles/what-is-the-model-context-protocol.
What Changed in v2.2.0
OAuth expectedIssuer Requirement
Version 2.2.0 introduces a significant change for machine-to-machine OAuth providers 1. Developers must now explicitly pass the expectedIssuer parameter when constructing ClientCredentialsProvider, PrivateKeyJwtProvider, StaticPrivateKeyJwtProvider, or CrossAppAccessProvider 1. Failing to provide expectedIssuer is now deprecated and will log a warning 1. The expectedIssuer value should correspond to the issuer of the authorization server where the credentials were registered 1.
Additionally, the fetchToken() function now performs validation to ensure the client information belongs to the correct authorization server 1. If a provider's client information is bound to a different authorization server, fetchToken() will proactively throw an AuthorizationServerMismatchError before initiating any requests 1. This enhances security by preventing tokens from being used with unintended issuers.
Hostnames ending in .localhost are now correctly recognized as loopback addresses for OAuth token endpoints, facilitating multi-tenant local setups based on hostnames 1. The OAuthTokensSchema and OAuthClientInformationSchema have also been updated to support an optional issuer field, allowing providers to retain this information when reading from storage 1.
Enhanced List Call Behavior
List calls within the SDK, such as listTools(), listPrompts(), listResources(), and listResourceTemplates(), now retrieve the entire list by default when called without a cursor 1. The SDK achieves this by automatically following nextCursor until the server no longer provides one 1. The listMaxPages option remains available to cap this full list retrieval process 1.
Bug Fixes and Stability Improvements
Several issues have been addressed in this release:
- CommonJS Type-Checking: CommonJS TypeScript projects can now correctly type-check again 1. The
josetypes used by the DPoP API are inlined into declaration files, resolving a regression introduced in version 2.1.0 1. Client.listen()Stability: TheClient.listen()method has been improved to prevent rejections from escaping as process-level unhandled rejections 1. It also no longer hangs if a send operation fails to settle 1.createMcpHandlerStack Overflow: A stack overflow issue increateMcpHandlerhas been fixed, which previously occurred when the factory returned the same server instance for multiple requests 1. Developers are still required to return a fresh instance per request 1.- Codemod Improvements: The
v1-to-v2codemod now preserves a file's leading comment block and directives when rewriting imports 1.
Why It Matters for Developers
The expectedIssuer requirement for machine-to-machine OAuth providers 1 and the fetchToken() validation 1 ensure that tokens are issued and validated against the correct authorization server 1. This explicit validation helps prevent potential misuse or misconfiguration.
For developers working with lists, the enhanced default behavior of list calls simplifies data retrieval. Instead of manually iterating through paginated results, developers can now often get a complete list with a single call 1, reducing boilerplate code. The fix for CommonJS TypeScript projects is crucial for maintaining type safety and development workflow for users of that module system 1. For more on structured outputs and type safety in TypeScript SDKs, see /articles/structured-outputs-typescript-ai-sdk-zod.
How to Try It
To upgrade to MCP TypeScript SDK v2.2.0, update the relevant @modelcontextprotocol packages to version 2.2.0 1. Packages such as @modelcontextprotocol/node, express, hono, and fastify remain unchanged 1.
Install the client or server packages using your preferred package manager 2:
npm install @modelcontextprotocol/server
# or
bun add @modelcontextprotocol/server
# or
deno add npm:@modelcontextprotocol/servernpm install @modelcontextprotocol/client
# or
bun add @modelcontextprotocol/client
# or
deno add npm:@modelcontextprotocol/clientOptional middleware packages for specific runtimes or frameworks can be installed as needed 2:
# Node.js HTTP (IncomingMessage/ServerResponse) Streamable HTTP transport:
npm install @modelcontextprotocol/node
# Express integration:
npm install @modelcontextprotocol/express express
# Fastify integration:
npm install @modelcontextprotocol/fastify fastify
# Hono integration:
npm install @modelcontextprotocol/hono honoHere is a minimal example of an MCP server exposing a 'greet' tool over stdio 2:
import { McpServer } from '@modelcontextprotocol/server';
import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
import * as z from 'zod/v4';
const server = new McpServer({ name: 'greeting-server', version: '1.0.0' });
server.registerTool(
'greet',
{
description: 'Greet someone by name',
inputSchema: z.object({ name: z.string() })
},
async ({ name }) => ({
content: [{ type: 'text', text: `Hello, ${name}!` }]
})
);
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
}
main();Limitations and Open Questions
While this release introduces several improvements, some aspects remain for further clarification or future development:
- It is currently unknown if there are any breaking changes for existing v2.x users beyond the
expectedIssuerdeprecation. - The specific performance implications of the
fetchToken()authorization server mismatch check have not been detailed. - The exact behavior or error message when
listMaxPagescaps a list call is not specified in the release notes. - Specific migration steps or considerations for developers upgrading from v2.1.0 to v2.2.0, especially regarding the
josetypes fix, are not explicitly provided. - The specific use cases or benefits of the
CrossAppAccessProvidermentioned in theexpectedIssuerdeprecation are not elaborated upon. - The recommended approach for handling the
AuthorizationServerMismatchErrorin client applications is not explicitly outlined. - The full implications for CommonJS projects affected by the
josetypes regression in 2.1.0, and the precise steps they should take to upgrade, are not detailed beyond the fix itself.