@ai-sdk/mcp 2.0.54 → 2.0.55

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.54",
3
+ "version": "2.0.55",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
package/src/tool/oauth.ts CHANGED
@@ -91,6 +91,16 @@ export interface OAuthClientProvider {
91
91
  | OAuthClientInformation
92
92
  | undefined
93
93
  | Promise<OAuthClientInformation | undefined>;
94
+ /**
95
+ * Returns whether the current client information was obtained through
96
+ * dynamic client registration.
97
+ *
98
+ * Return `true` only when the current client information was saved after a
99
+ * dynamic registration response. When this method is omitted or returns
100
+ * `false`, the client information is treated as pre-registered and is not
101
+ * automatically invalidated after client authentication errors.
102
+ */
103
+ isClientInformationDynamicallyRegistered?(): boolean | Promise<boolean>;
94
104
  saveClientInformation?(
95
105
  clientInformation: OAuthClientInformation,
96
106
  ): void | Promise<void>;
@@ -1259,6 +1269,13 @@ export async function auth(
1259
1269
  error instanceof InvalidClientError ||
1260
1270
  error instanceof UnauthorizedClientError
1261
1271
  ) {
1272
+ if (
1273
+ options.authorizationCode !== undefined ||
1274
+ !(await provider.isClientInformationDynamicallyRegistered?.())
1275
+ ) {
1276
+ throw error;
1277
+ }
1278
+
1262
1279
  await provider.invalidateCredentials?.('all');
1263
1280
  return await authInternal(provider, options);
1264
1281
  } else if (error instanceof InvalidGrantError) {