This is the documentation for the v2 beta — looking for the v1 documentation?
Skip to content

MCP TypeScript SDK (V2) / @modelcontextprotocol/client / client/authErrors

client/authErrors

Classes

AuthorizationServerMismatchError

Defined in: packages/client/src/client/authErrors.ts:187

Thrown by auth() on the authorization-code callback leg when the authorization server resolved by discovery differs from the one recorded in discoveryState() at redirect time. The authorization_code and PKCE code_verifier are bound to the AS that minted the code (RFC 7636); sending them to a different AS's token endpoint is a credential-exfiltration vector.

This is the only runtime check left in the SEP-2352 model — stored tokens and client credentials are protected structurally by the issuer stamp instead.

Extends

Constructors

Constructor

new AuthorizationServerMismatchError(recordedIssuer, currentIssuer): AuthorizationServerMismatchError

Defined in: packages/client/src/client/authErrors.ts:192

Parameters
recordedIssuer

string

The issuer recorded in discoveryState() when the authorization redirect was issued.

currentIssuer

string

The issuer resolved by discovery on this call.

Returns

AuthorizationServerMismatchError

Overrides

OAuthClientFlowError.constructor

Properties

cause?

optional cause?: unknown

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26

Inherited from

OAuthClientFlowError.cause

currentIssuer

readonly currentIssuer: string

Defined in: packages/client/src/client/authErrors.ts:196

The issuer resolved by discovery on this call.

message

message: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from

OAuthClientFlowError.message

name

name: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from

OAuthClientFlowError.name

recordedIssuer

readonly recordedIssuer: string

Defined in: packages/client/src/client/authErrors.ts:194

The issuer recorded in discoveryState() when the authorization redirect was issued.

stack?

optional stack?: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from

OAuthClientFlowError.stack

stackTraceLimit

static stackTraceLimit: number

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from

OAuthClientFlowError.stackTraceLimit

Methods

[hasInstance]()

static [hasInstance](value): boolean

Defined in: packages/client/src/client/authErrors.ts:27

Parameters
value

unknown

Returns

boolean

Inherited from

OAuthClientFlowError.[hasInstance]

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters
targetObject

object

constructorOpt?

Function

Returns

void

Inherited from

OAuthClientFlowError.captureStackTrace

isError()

static isError(error): error is Error

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.esnext.error.d.ts:23

Indicates whether the argument provided is a built-in Error instance or not.

Parameters
error

unknown

Returns

error is Error

Inherited from

OAuthClientFlowError.isError

isInstance()

static isInstance<T>(this, value): value is InstanceType<T>

Defined in: packages/client/src/client/authErrors.ts:40

Brand-based type guard: equivalent to value instanceof this, as an explicit static predicate (the axios/AWS-SDK isInstance style). Reads the caller's own brand via this, so every branded subclass gets a correctly-scoped guard by inheritance. Must be invoked on the class — in callback position write v => SdkError.isInstance(v), not .filter(SdkError.isInstance) (detached calls throw rather than silently matching nothing).

Type Parameters
T

T extends (...args) => unknown

Parameters
this

T

value

unknown

Returns

value is InstanceType<T>

Inherited from

OAuthClientFlowError.isInstance

prepareStackTrace()

static prepareStackTrace(err, stackTraces): any

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:56

Parameters
err

Error

stackTraces

CallSite[]

Returns

any

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from

OAuthClientFlowError.prepareStackTrace


InsecureTokenEndpointError

Defined in: packages/client/src/client/authErrors.ts:140

Thrown by the token-exchange and refresh paths when the resolved token endpoint is not https: and is not a loopback host (SEP-2207). This is a configuration error — re-authorizing cannot fix it — so it intentionally does not extend OAuthError and auth()'s refresh branch rethrows it instead of falling through to a fresh /authorize redirect.

Extends

Constructors

Constructor

new InsecureTokenEndpointError(tokenEndpoint): InsecureTokenEndpointError

Defined in: packages/client/src/client/authErrors.ts:148

Parameters
tokenEndpoint

string

Returns

InsecureTokenEndpointError

Overrides

OAuthClientFlowError.constructor

Properties

cause?

optional cause?: unknown

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26

Inherited from

OAuthClientFlowError.cause

message

message: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from

OAuthClientFlowError.message

name

name: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from

OAuthClientFlowError.name

stack?

optional stack?: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from

OAuthClientFlowError.stack

tokenEndpoint

readonly tokenEndpoint: string

Defined in: packages/client/src/client/authErrors.ts:146

The token endpoint URL that was rejected.

stackTraceLimit

static stackTraceLimit: number

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from

OAuthClientFlowError.stackTraceLimit

Methods

[hasInstance]()

static [hasInstance](value): boolean

Defined in: packages/client/src/client/authErrors.ts:27

Parameters
value

unknown

Returns

boolean

Inherited from

OAuthClientFlowError.[hasInstance]

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters
targetObject

object

constructorOpt?

Function

Returns

void

Inherited from

OAuthClientFlowError.captureStackTrace

isError()

static isError(error): error is Error

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.esnext.error.d.ts:23

Indicates whether the argument provided is a built-in Error instance or not.

Parameters
error

unknown

Returns

error is Error

Inherited from

OAuthClientFlowError.isError

isInstance()

static isInstance<T>(this, value): value is InstanceType<T>

Defined in: packages/client/src/client/authErrors.ts:40

Brand-based type guard: equivalent to value instanceof this, as an explicit static predicate (the axios/AWS-SDK isInstance style). Reads the caller's own brand via this, so every branded subclass gets a correctly-scoped guard by inheritance. Must be invoked on the class — in callback position write v => SdkError.isInstance(v), not .filter(SdkError.isInstance) (detached calls throw rather than silently matching nothing).

Type Parameters
T

T extends (...args) => unknown

Parameters
this

T

value

unknown

Returns

value is InstanceType<T>

Inherited from

OAuthClientFlowError.isInstance

prepareStackTrace()

static prepareStackTrace(err, stackTraces): any

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:56

Parameters
err

Error

stackTraces

CallSite[]

Returns

any

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from

OAuthClientFlowError.prepareStackTrace


InsufficientScopeError

Defined in: packages/client/src/client/authErrors.ts:206

Base class for the OAuth-client-flow error family. Concrete subclasses are added to this module alongside the SEP-2468/837/2207/2350/2352 behavior changes that throw them, so callers can catch the whole family with a single instanceof OAuthClientFlowError guard once those land.

Remarks

Nothing in the SDK throws this base class directly. In the release that introduces it no subclass exists yet — the guard is a forward-compat hook and will not match anything until the first behavior change ships.

Extends

Constructors

Constructor

new InsufficientScopeError(init): InsufficientScopeError

Defined in: packages/client/src/client/authErrors.ts:218

Parameters
init
errorDescription?

string

requiredScope?

string

resourceMetadataUrl?

URL

Returns

InsufficientScopeError

Overrides

OAuthClientFlowError.constructor

Properties

cause?

optional cause?: unknown

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26

Inherited from

OAuthClientFlowError.cause

errorDescription?

readonly optional errorDescription?: string

Defined in: packages/client/src/client/authErrors.ts:216

The error_description from the WWW-Authenticate challenge, if present.

message

message: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from

OAuthClientFlowError.message

name

name: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from

OAuthClientFlowError.name

requiredScope?

readonly optional requiredScope?: string

Defined in: packages/client/src/client/authErrors.ts:212

The scope value from the WWW-Authenticate challenge — the scopes the resource server says are required.

resourceMetadataUrl?

readonly optional resourceMetadataUrl?: URL

Defined in: packages/client/src/client/authErrors.ts:214

The resource_metadata URL from the WWW-Authenticate challenge, if present.

stack?

optional stack?: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from

OAuthClientFlowError.stack

stackTraceLimit

static stackTraceLimit: number

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from

OAuthClientFlowError.stackTraceLimit

Methods

[hasInstance]()

static [hasInstance](value): boolean

Defined in: packages/client/src/client/authErrors.ts:27

Parameters
value

unknown

Returns

boolean

Inherited from

OAuthClientFlowError.[hasInstance]

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters
targetObject

object

constructorOpt?

Function

Returns

void

Inherited from

OAuthClientFlowError.captureStackTrace

isError()

static isError(error): error is Error

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.esnext.error.d.ts:23

Indicates whether the argument provided is a built-in Error instance or not.

Parameters
error

unknown

Returns

error is Error

Inherited from

OAuthClientFlowError.isError

isInstance()

static isInstance<T>(this, value): value is InstanceType<T>

Defined in: packages/client/src/client/authErrors.ts:40

Brand-based type guard: equivalent to value instanceof this, as an explicit static predicate (the axios/AWS-SDK isInstance style). Reads the caller's own brand via this, so every branded subclass gets a correctly-scoped guard by inheritance. Must be invoked on the class — in callback position write v => SdkError.isInstance(v), not .filter(SdkError.isInstance) (detached calls throw rather than silently matching nothing).

Type Parameters
T

T extends (...args) => unknown

Parameters
this

T

value

unknown

Returns

value is InstanceType<T>

Inherited from

OAuthClientFlowError.isInstance

prepareStackTrace()

static prepareStackTrace(err, stackTraces): any

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:56

Parameters
err

Error

stackTraces

CallSite[]

Returns

any

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from

OAuthClientFlowError.prepareStackTrace


IssuerMismatchError

Defined in: packages/client/src/client/authErrors.ts:75

Thrown when an authorization-server issuer identifier fails validation.

Two checks raise this error, distinguished by kind:

  • 'metadata' — the issuer in fetched authorization-server metadata does not match the issuer identifier the well-known URL was constructed from (RFC 8414 §3.3 / OpenID Connect Discovery §4.3).
  • 'authorization_response' — the iss parameter on the authorization callback failed RFC 9207 §2.4 validation against the recorded issuer.

Intentionally does not extend OAuthError: the auth() orchestrator's OAuthError retry block must not swallow this — a mix-up indication is fatal for the flow, not a retryable credential problem.

On the 'authorization_response' path the received value is attacker-controllable in a mix-up attack; callers MUST NOT display it (or any error/error_description/error_uri from the same callback) to end users. The values are JSON-encoded in the message to neutralize log-injection.

Extends

Constructors

Constructor

new IssuerMismatchError(kind, expected, received): IssuerMismatchError

Defined in: packages/client/src/client/authErrors.ts:87

Parameters
kind

"metadata" | "authorization_response"

expected

string | undefined

received

string | undefined

Returns

IssuerMismatchError

Overrides

OAuthClientFlowError.constructor

Properties

cause?

optional cause?: unknown

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26

Inherited from

OAuthClientFlowError.cause

expected

readonly expected: string | undefined

Defined in: packages/client/src/client/authErrors.ts:83

The issuer the client expected (from validated metadata / discovery input).

kind

readonly kind: "metadata" | "authorization_response"

Defined in: packages/client/src/client/authErrors.ts:81

Which check failed — metadata echo (RFC 8414 §3.3) or authorization-response iss (RFC 9207).

message

message: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from

OAuthClientFlowError.message

name

name: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from

OAuthClientFlowError.name

received

readonly received: string | undefined

Defined in: packages/client/src/client/authErrors.ts:85

The issuer value that was received. Attacker-controllable on the 'authorization_response' path.

stack?

optional stack?: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from

OAuthClientFlowError.stack

stackTraceLimit

static stackTraceLimit: number

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from

OAuthClientFlowError.stackTraceLimit

Methods

[hasInstance]()

static [hasInstance](value): boolean

Defined in: packages/client/src/client/authErrors.ts:27

Parameters
value

unknown

Returns

boolean

Inherited from

OAuthClientFlowError.[hasInstance]

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters
targetObject

object

constructorOpt?

Function

Returns

void

Inherited from

OAuthClientFlowError.captureStackTrace

isError()

static isError(error): error is Error

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.esnext.error.d.ts:23

Indicates whether the argument provided is a built-in Error instance or not.

Parameters
error

unknown

Returns

error is Error

Inherited from

OAuthClientFlowError.isError

isInstance()

static isInstance<T>(this, value): value is InstanceType<T>

Defined in: packages/client/src/client/authErrors.ts:40

Brand-based type guard: equivalent to value instanceof this, as an explicit static predicate (the axios/AWS-SDK isInstance style). Reads the caller's own brand via this, so every branded subclass gets a correctly-scoped guard by inheritance. Must be invoked on the class — in callback position write v => SdkError.isInstance(v), not .filter(SdkError.isInstance) (detached calls throw rather than silently matching nothing).

Type Parameters
T

T extends (...args) => unknown

Parameters
this

T

value

unknown

Returns

value is InstanceType<T>

Inherited from

OAuthClientFlowError.isInstance

prepareStackTrace()

static prepareStackTrace(err, stackTraces): any

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:56

Parameters
err

Error

stackTraces

CallSite[]

Returns

any

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from

OAuthClientFlowError.prepareStackTrace


OAuthClientFlowError

Defined in: packages/client/src/client/authErrors.ts:22

Base class for the OAuth-client-flow error family. Concrete subclasses are added to this module alongside the SEP-2468/837/2207/2350/2352 behavior changes that throw them, so callers can catch the whole family with a single instanceof OAuthClientFlowError guard once those land.

Remarks

Nothing in the SDK throws this base class directly. In the release that introduces it no subclass exists yet — the guard is a forward-compat hook and will not match anything until the first behavior change ships.

Extends

  • Error

Extended by

Constructors

Constructor

new OAuthClientFlowError(message): OAuthClientFlowError

Defined in: packages/client/src/client/authErrors.ts:49

Parameters
message

string

Returns

OAuthClientFlowError

Overrides

Error.constructor

Properties

cause?

optional cause?: unknown

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26

Inherited from

Error.cause

message

message: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from

Error.message

name

name: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from

Error.name

stack?

optional stack?: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from

Error.stack

stackTraceLimit

static stackTraceLimit: number

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from

Error.stackTraceLimit

Methods

[hasInstance]()

static [hasInstance](value): boolean

Defined in: packages/client/src/client/authErrors.ts:27

Parameters
value

unknown

Returns

boolean

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters
targetObject

object

constructorOpt?

Function

Returns

void

Inherited from

Error.captureStackTrace

isError()

static isError(error): error is Error

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.esnext.error.d.ts:23

Indicates whether the argument provided is a built-in Error instance or not.

Parameters
error

unknown

Returns

error is Error

Inherited from

Error.isError

isInstance()

static isInstance<T>(this, value): value is InstanceType<T>

Defined in: packages/client/src/client/authErrors.ts:40

Brand-based type guard: equivalent to value instanceof this, as an explicit static predicate (the axios/AWS-SDK isInstance style). Reads the caller's own brand via this, so every branded subclass gets a correctly-scoped guard by inheritance. Must be invoked on the class — in callback position write v => SdkError.isInstance(v), not .filter(SdkError.isInstance) (detached calls throw rather than silently matching nothing).

Type Parameters
T

T extends (...args) => unknown

Parameters
this

T

value

unknown

Returns

value is InstanceType<T>

prepareStackTrace()

static prepareStackTrace(err, stackTraces): any

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:56

Parameters
err

Error

stackTraces

CallSite[]

Returns

any

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from

Error.prepareStackTrace


RegistrationRejectedError

Defined in: packages/client/src/client/authErrors.ts:113

Thrown by registerClient() when the authorization server rejects a Dynamic Client Registration request. Carries the HTTP status, the raw response body, and the metadata that was submitted, so callers can inspect the AS's error / error_description and retry with adjusted metadata (for example a different application_type) per SEP-837.

The body is the raw RFC 7591 error JSON; compare JSON.parse(body).error against OAuthErrorCode (e.g. OAuthErrorCode.InvalidRedirectUri, OAuthErrorCode.InvalidClientMetadata).

Intentionally does not extend OAuthError: registration rejection is not a recoverable-by-credential-invalidation condition, and staying outside that hierarchy keeps it from being caught by auth()'s OAuthError retry path.

Extends

Constructors

Constructor

new RegistrationRejectedError(args): RegistrationRejectedError

Defined in: packages/client/src/client/authErrors.ts:125

Parameters
args
body

string

status

number

submittedMetadata

{ application_type?: string; client_name?: string; client_uri?: string; contacts?: string[]; grant_types?: string[]; jwks?: any; jwks_uri?: string; logo_uri?: string; policy_uri?: string; redirect_uris: string[]; response_types?: string[]; scope?: string; software_id?: string; software_statement?: string; software_version?: string; token_endpoint_auth_method?: string; tos_uri?: string; }

submittedMetadata.application_type?

string = ...

OIDC Dynamic Client Registration application_type. MCP clients MUST set this to 'native' or 'web' when registering (SEP-837); the SDK defaults it from redirect_uris when omitted. Typed as string (not an enum) so that parsing an authorization server's registration response — which under RFC 7591 may echo extension values — never rejects the document on this field alone.

submittedMetadata.client_name?

string = ...

submittedMetadata.client_uri?

string = ...

submittedMetadata.contacts?

string[] = ...

submittedMetadata.grant_types?

string[] = ...

submittedMetadata.jwks?

any = ...

submittedMetadata.jwks_uri?

string = ...

submittedMetadata.logo_uri?

string = OptionalSafeUrlSchema

submittedMetadata.policy_uri?

string = ...

submittedMetadata.redirect_uris

string[] = ...

submittedMetadata.response_types?

string[] = ...

submittedMetadata.scope?

string = ...

submittedMetadata.software_id?

string = ...

submittedMetadata.software_statement?

string = ...

submittedMetadata.software_version?

string = ...

submittedMetadata.token_endpoint_auth_method?

string = ...

submittedMetadata.tos_uri?

string = OptionalSafeUrlSchema

Returns

RegistrationRejectedError

Overrides

OAuthClientFlowError.constructor

Properties

body

readonly body: string

Defined in: packages/client/src/client/authErrors.ts:121

Raw response body text (typically an RFC 7591 error JSON document).

cause?

optional cause?: unknown

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26

Inherited from

OAuthClientFlowError.cause

message

message: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from

OAuthClientFlowError.message

name

name: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from

OAuthClientFlowError.name

stack?

optional stack?: string

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from

OAuthClientFlowError.stack

status

readonly status: number

Defined in: packages/client/src/client/authErrors.ts:119

HTTP status code returned by the registration endpoint.

submittedMetadata

readonly submittedMetadata: object

Defined in: packages/client/src/client/authErrors.ts:123

The exact client metadata that was POSTed (after SDK defaults were applied).

application_type?

optional application_type?: string

OIDC Dynamic Client Registration application_type. MCP clients MUST set this to 'native' or 'web' when registering (SEP-837); the SDK defaults it from redirect_uris when omitted. Typed as string (not an enum) so that parsing an authorization server's registration response — which under RFC 7591 may echo extension values — never rejects the document on this field alone.

client_name?

optional client_name?: string

client_uri?

optional client_uri?: string

contacts?

optional contacts?: string[]

grant_types?

optional grant_types?: string[]

jwks?

optional jwks?: any

jwks_uri?

optional jwks_uri?: string

logo_uri?

optional logo_uri?: string = OptionalSafeUrlSchema

policy_uri?

optional policy_uri?: string

redirect_uris

redirect_uris: string[]

response_types?

optional response_types?: string[]

scope?

optional scope?: string

software_id?

optional software_id?: string

software_statement?

optional software_statement?: string

software_version?

optional software_version?: string

token_endpoint_auth_method?

optional token_endpoint_auth_method?: string

tos_uri?

optional tos_uri?: string = OptionalSafeUrlSchema

stackTraceLimit

static stackTraceLimit: number

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from

OAuthClientFlowError.stackTraceLimit

Methods

[hasInstance]()

static [hasInstance](value): boolean

Defined in: packages/client/src/client/authErrors.ts:27

Parameters
value

unknown

Returns

boolean

Inherited from

OAuthClientFlowError.[hasInstance]

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters
targetObject

object

constructorOpt?

Function

Returns

void

Inherited from

OAuthClientFlowError.captureStackTrace

isError()

static isError(error): error is Error

Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.esnext.error.d.ts:23

Indicates whether the argument provided is a built-in Error instance or not.

Parameters
error

unknown

Returns

error is Error

Inherited from

OAuthClientFlowError.isError

isInstance()

static isInstance<T>(this, value): value is InstanceType<T>

Defined in: packages/client/src/client/authErrors.ts:40

Brand-based type guard: equivalent to value instanceof this, as an explicit static predicate (the axios/AWS-SDK isInstance style). Reads the caller's own brand via this, so every branded subclass gets a correctly-scoped guard by inheritance. Must be invoked on the class — in callback position write v => SdkError.isInstance(v), not .filter(SdkError.isInstance) (detached calls throw rather than silently matching nothing).

Type Parameters
T

T extends (...args) => unknown

Parameters
this

T

value

unknown

Returns

value is InstanceType<T>

Inherited from

OAuthClientFlowError.isInstance

prepareStackTrace()

static prepareStackTrace(err, stackTraces): any

Defined in: node_modules/.pnpm/@types+node@24.12.0/node_modules/@types/node/globals.d.ts:56

Parameters
err

Error

stackTraces

CallSite[]

Returns

any

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from

OAuthClientFlowError.prepareStackTrace