@ai-sdk/mcp 2.0.65 → 2.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/mcp",
3
- "version": "2.0.65",
3
+ "version": "2.0.66",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -42,6 +42,24 @@ export class UnauthorizedClientError extends MCPClientOAuthError {
42
42
  static errorCode = 'unauthorized_client';
43
43
  }
44
44
 
45
+ const mismatchName = 'AI_AuthorizationServerMismatchError';
46
+ const mismatchMarker = `vercel.ai.error.${mismatchName}`;
47
+ const mismatchSymbol = Symbol.for(mismatchMarker);
48
+
49
+ export class AuthorizationServerMismatchError extends MCPClientOAuthError {
50
+ private readonly [mismatchSymbol] = true;
51
+
52
+ static errorCode = 'authorization_server_mismatch';
53
+
54
+ constructor({ message, cause }: { message: string; cause?: unknown }) {
55
+ super({ name: 'AuthorizationServerMismatchError', message, cause });
56
+ }
57
+
58
+ static isInstance(error: unknown): error is AuthorizationServerMismatchError {
59
+ return AISDKError.hasMarker(error, mismatchMarker);
60
+ }
61
+ }
62
+
45
63
  export const OAUTH_ERRORS = {
46
64
  [ServerError.errorCode]: ServerError,
47
65
  [InvalidClientError.errorCode]: InvalidClientError,
package/src/index.ts CHANGED
@@ -41,6 +41,10 @@ export type {
41
41
  ClientCapabilities as MCPClientCapabilities,
42
42
  } from './tool/types';
43
43
  export { auth, UnauthorizedError } from './tool/oauth';
44
+ export {
45
+ MCPClientOAuthError,
46
+ AuthorizationServerMismatchError,
47
+ } from './error/oauth-error';
44
48
  export type {
45
49
  OAuthAuthorizationServerInformation,
46
50
  OAuthClientProvider,
package/src/tool/oauth.ts CHANGED
@@ -20,6 +20,7 @@ import {
20
20
  InvalidClientError,
21
21
  InvalidGrantError,
22
22
  UnauthorizedClientError,
23
+ AuthorizationServerMismatchError,
23
24
  } from '../error/oauth-error';
24
25
  import {
25
26
  resourceUrlFromServerUrl,
@@ -360,7 +361,7 @@ function assertAuthorizationServerInformationMatches({
360
361
  storedAuthorizationServerInformation.tokenEndpoint !==
361
362
  currentAuthorizationServerInformation.tokenEndpoint
362
363
  ) {
363
- throw new MCPClientOAuthError({
364
+ throw new AuthorizationServerMismatchError({
364
365
  message:
365
366
  'OAuth authorization server metadata does not match the metadata that issued the stored credentials',
366
367
  });