@ai-sdk/mcp 1.0.79 → 1.0.81

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-sdk/mcp
2
2
 
3
+ ## 1.0.81
4
+
5
+ ### Patch Changes
6
+
7
+ - 5246507: fix(mcp): use the stored authorization server for OAuth callbacks when protected resource metadata rediscovery fails
8
+
9
+ ## 1.0.80
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [1a4dbb1]
14
+ - @ai-sdk/provider@3.0.16
15
+ - @ai-sdk/provider-utils@4.0.51
16
+
3
17
  ## 1.0.79
4
18
 
5
19
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1199,9 +1199,11 @@ async function authInternal(provider, {
1199
1199
  resourceMetadataUrl,
1200
1200
  fetchFn
1201
1201
  }) {
1202
- var _a3, _b3;
1202
+ var _a3, _b3, _c;
1203
1203
  let resourceMetadata;
1204
1204
  let authorizationServerUrl;
1205
+ let clientInformation;
1206
+ let callbackAuthorizationServerInformation;
1205
1207
  assertResourceMetadataUrlSameOrigin(serverUrl, resourceMetadataUrl);
1206
1208
  try {
1207
1209
  resourceMetadata = await discoverOAuthProtectedResourceMetadata(
@@ -1214,15 +1216,24 @@ async function authInternal(provider, {
1214
1216
  }
1215
1217
  } catch (e) {
1216
1218
  }
1219
+ if (authorizationCode !== void 0) {
1220
+ clientInformation = await Promise.resolve(provider.clientInformation());
1221
+ if (clientInformation) {
1222
+ callbackAuthorizationServerInformation = await getStoredAuthorizationServerInformation({
1223
+ provider,
1224
+ clientInformation
1225
+ });
1226
+ }
1227
+ }
1217
1228
  if (!authorizationServerUrl) {
1218
- authorizationServerUrl = serverUrl;
1229
+ authorizationServerUrl = (_a3 = callbackAuthorizationServerInformation == null ? void 0 : callbackAuthorizationServerInformation.authorizationServerUrl) != null ? _a3 : serverUrl;
1219
1230
  }
1220
1231
  const resource = await selectResourceURL(
1221
1232
  serverUrl,
1222
1233
  provider,
1223
1234
  resourceMetadata
1224
1235
  );
1225
- await ((_a3 = provider.validateAuthorizationServerURL) == null ? void 0 : _a3.call(
1236
+ await ((_b3 = provider.validateAuthorizationServerURL) == null ? void 0 : _b3.call(
1226
1237
  provider,
1227
1238
  serverUrl,
1228
1239
  authorizationServerUrl
@@ -1240,7 +1251,9 @@ async function authInternal(provider, {
1240
1251
  resourceMetadata,
1241
1252
  clientMetadata
1242
1253
  });
1243
- let clientInformation = await Promise.resolve(provider.clientInformation());
1254
+ if (authorizationCode === void 0) {
1255
+ clientInformation = await Promise.resolve(provider.clientInformation());
1256
+ }
1244
1257
  if (!clientInformation) {
1245
1258
  if (authorizationCode !== void 0) {
1246
1259
  throw new Error(
@@ -1275,7 +1288,7 @@ async function authInternal(provider, {
1275
1288
  );
1276
1289
  }
1277
1290
  }
1278
- const storedAuthorizationServerInformation = await getStoredAuthorizationServerInformation({
1291
+ const storedAuthorizationServerInformation = callbackAuthorizationServerInformation != null ? callbackAuthorizationServerInformation : await getStoredAuthorizationServerInformation({
1279
1292
  provider,
1280
1293
  clientInformation
1281
1294
  });
@@ -1320,7 +1333,7 @@ async function authInternal(provider, {
1320
1333
  currentAuthorizationServerInformation
1321
1334
  });
1322
1335
  } else {
1323
- await ((_b3 = provider.invalidateCredentials) == null ? void 0 : _b3.call(provider, "tokens"));
1336
+ await ((_c = provider.invalidateCredentials) == null ? void 0 : _c.call(provider, "tokens"));
1324
1337
  }
1325
1338
  try {
1326
1339
  if (storedAuthorizationServerInformation) {