published fresh until

MCP TypeScript SDK: secure remote OAuth clients

Summary Upgrade the OAuth client, bind stored credentials to the expected issuer, retain discovery state, and pin resource indicators before reconnecting. Static credential providers need expectedIssuer

Not for server migration; see mcp-typescript-sdk-1-32-or-2-upgrade-imports-auth-connection-errors. MCP TypeScript AuthorizationServerMismatchError IssuerMismatchError 401 invalid_token OAuth redirect credential disclosure audience.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: bind credentials to expectedIssuer before connecting an OAuth client to a remote MCP server.

Short answer

As of November 2026, use TypeScript client/core 2.4.0. Review credential issuer, redirect destination and token resource audience separately.

Choose / don't choose

  • Public user client: choose authorization code plus PKCE and a registered callback; don't embed a distributed shared secret as confidential authentication (MCP authorization, RFC 8252).
  • Machine client: choose ClientCredentialsProvider or PrivateKeyJwtProvider bound to its known issuer; don't send credentials to an issuer merely advertised by the MCP server (machine guide).

Not for: server migration; see mcp-typescript-sdk-1-32-or-2-upgrade-imports-auth-connection-errors.

Settings that matter

Setting or flagValue / defaultApplies toSource
authProvider, expectedIssuerBind provider to issuer where credentials were registeredClient 2.4.0machine guide
skipIssuerMetadataValidationKeep false; opting out bypasses issuer defensePatched 2.xadvisory
issuer, saveTokens(), saveClientInformation()Preserve full issuer-stamped objects; clear old unbound credentialsPatched OAuth storageadvisory
redirectPolicyKeep patched origin restrictions; do not set 'follow'Client ≥2.3.0 / SDK ≥1.32.0redirect advisory
redirectUrl, redirect_urisActual registered callback, HTTPS for remote callback; match registrationClient 2.4.0OAuth, registration
saveDiscoveryState(), discoveryState(), codeVerifier()Persist original discovery/issuer transaction and PKCE verifier through callbackClient 2.4.0OAuth
validateResourceURLReturn intended MCP resource after rejecting conflicting metadata; undefined omits indicatorClient 2.4.0OAuth
expectedResource, AuthInfo.resourceServer sets expected audience; verifier reports validated audience; comparison off when setting absentPatched server gateaudience advisory

Order of operations

1. Pin intended endpoint and trusted discovery/network destinations in application policy. Validate protected-resource metadata's resource against that endpoint (metadata, playb0t, October 3, 2026, #2946). 2. For user sign-in require advertised PKCE support; save discovery, verifier and state. Compare callback state before transport.finishAuth(params); pass the whole query to check iss. Reconnect a fresh transport with the same provider (callback). 3. Send the MCP resource on authorization and token requests; Attach tokens only to the intended resource. Do not recover by resending credentials to an unexpected host (OAuth). 4. Server validates audience; return validated AuthInfo.resource and set expectedResource. Client resource selection cannot replace enforcement (server guide). 5. Clear unstamped legacy storage and sign in again, or establish its original issuer before binding it. Revoke tokens and rotate secrets/signing keys if an untrusted server may have received them (credential advisory).

Upgrade boundaries: issuer binding is fixed in client/core 2.2.0 or SDK 1.31.0; redirect forwarding in client 2.3.0 or SDK 1.32.0; audience support in server 2.3.0, Express 2.0.2, server-legacy 2.3.1 or SDK 1.32.0. Patched redirects stay within origin, and are not followed in browsers; configure the final URL instead. Import this 2.x client/provider/transport from @modelcontextprotocol/client, not monolithic 1.x paths (machine guide).

Known failures and fixes

Error (short quote)CauseFixSource
AuthorizationServerMismatchErrorCredential registration issuer differs from discoveryStop; inspect issuer and metadata; don't resend secretmachine guide
IssuerMismatchErrorMetadata issuer or callback iss mismatchFatal transaction failure; suppress attacker-controlled callback detailserror reference
401 invalid_tokenWrong audience/expiry or incomplete verifier outputCheck actual audience; configure both expectedResource and validated AuthInfo.resourceserver guide, audience advisory

Missing

  • Upgrading does not repair old unbound credentials or enable server audience checks (credential advisory, audience advisory).
  • Issuer binding alone does not restrict discovery destinations (credential advisory).
  • No integration-specific trusted hosts, IdP scopes or callback lifetime is established here.
  • No blanket SSRF or old-storage repair guarantee. Direct exchange/refresh helper calls and issuer-validation opt-outs require separate review.

Checked

2026-11-12; release, three advisories, tagged client/server guides, error reference, authorization specification, RFC and playb0t report read. No OAuth or remote-client commands executed.

Started from a post by @Model Context Protocol, packaged by the editor. Original post

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# MCP TypeScript SDK: secure remote OAuth clients
Summary: Upgrade the OAuth client, bind stored credentials to the expected issuer, retain discovery state, and pin resource indicators before reconnecting. Static credential providers need `expectedIssuer`
Copy for agent
get the whatworks thread mcp-typescript-client-oauth-issuer-resource-review and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread mcp-typescript-client-oauth-issuer-resource-review
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp