@ai-sdk/mcp 2.0.50 → 2.0.52

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,31 @@
1
1
  # @ai-sdk/mcp
2
2
 
3
+ ## 2.0.52
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [215b25e]
8
+ - Updated dependencies [d4d96bf]
9
+ - Updated dependencies [a7dd893]
10
+ - Updated dependencies [3456e2c]
11
+ - Updated dependencies [c4e76de]
12
+ - @ai-sdk/provider-utils@5.0.43
13
+ - @ai-sdk/provider@4.0.17
14
+
15
+ ## 2.0.51
16
+
17
+ ### Patch Changes
18
+
19
+ - df91a09: fix(mcp): use the stored authorization server for OAuth callbacks when protected resource metadata rediscovery fails
20
+ - 2cd80b3: Keep default Node.js downloads protected by DNS validation and connection pinning when frameworks or instrumentation wrap global fetch before or after the SDK loads.
21
+ - Updated dependencies [91c2128]
22
+ - Updated dependencies [2cd80b3]
23
+ - Updated dependencies [d06bb2a]
24
+ - Updated dependencies [123d71f]
25
+ - Updated dependencies [2fa5e0e]
26
+ - @ai-sdk/provider-utils@5.0.42
27
+ - @ai-sdk/provider@4.0.16
28
+
3
29
  ## 2.0.50
4
30
 
5
31
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1302,9 +1302,11 @@ async function authInternal(provider, {
1302
1302
  resourceMetadataUrl,
1303
1303
  fetchFn
1304
1304
  }) {
1305
- var _a3, _b3, _c, _d;
1305
+ var _a3, _b3, _c, _d, _e;
1306
1306
  let resourceMetadata;
1307
1307
  let authorizationServerUrl;
1308
+ let clientInformation;
1309
+ let callbackAuthorizationServerInformation;
1308
1310
  assertResourceMetadataUrlSameOrigin(serverUrl, resourceMetadataUrl);
1309
1311
  try {
1310
1312
  resourceMetadata = await discoverOAuthProtectedResourceMetadata(
@@ -1317,8 +1319,17 @@ async function authInternal(provider, {
1317
1319
  }
1318
1320
  } catch (e) {
1319
1321
  }
1322
+ if (authorizationCode !== void 0) {
1323
+ clientInformation = await Promise.resolve(provider.clientInformation());
1324
+ if (clientInformation) {
1325
+ callbackAuthorizationServerInformation = await getStoredAuthorizationServerInformation({
1326
+ provider,
1327
+ clientInformation
1328
+ });
1329
+ }
1330
+ }
1320
1331
  if (!authorizationServerUrl) {
1321
- authorizationServerUrl = serverUrl;
1332
+ authorizationServerUrl = (_a3 = callbackAuthorizationServerInformation == null ? void 0 : callbackAuthorizationServerInformation.authorizationServerUrl) != null ? _a3 : serverUrl;
1322
1333
  }
1323
1334
  const parsedServerUrl = new URL(serverUrl);
1324
1335
  const parsedAuthorizationServerUrl = new URL(authorizationServerUrl);
@@ -1333,7 +1344,7 @@ async function authInternal(provider, {
1333
1344
  provider,
1334
1345
  resourceMetadata
1335
1346
  );
1336
- await ((_a3 = provider.validateAuthorizationServerURL) == null ? void 0 : _a3.call(
1347
+ await ((_b3 = provider.validateAuthorizationServerURL) == null ? void 0 : _b3.call(
1337
1348
  provider,
1338
1349
  serverUrl,
1339
1350
  authorizationServerUrl
@@ -1352,9 +1363,11 @@ async function authInternal(provider, {
1352
1363
  resourceMetadata,
1353
1364
  clientMetadata
1354
1365
  });
1355
- let clientInformation = await Promise.resolve(provider.clientInformation());
1366
+ if (authorizationCode === void 0) {
1367
+ clientInformation = await Promise.resolve(provider.clientInformation());
1368
+ }
1356
1369
  if ((clientInformation == null ? void 0 : clientInformation.issuer) != null) {
1357
- const storedAuthorizationServerInformation = await getStoredAuthorizationServerInformation({
1370
+ const storedAuthorizationServerInformation = callbackAuthorizationServerInformation != null ? callbackAuthorizationServerInformation : await getStoredAuthorizationServerInformation({
1358
1371
  provider,
1359
1372
  clientInformation
1360
1373
  });
@@ -1399,7 +1412,7 @@ async function authInternal(provider, {
1399
1412
  );
1400
1413
  }
1401
1414
  }
1402
- const storedAuthorizationServerInformation = await getStoredAuthorizationServerInformation({
1415
+ const storedAuthorizationServerInformation = callbackAuthorizationServerInformation != null ? callbackAuthorizationServerInformation : await getStoredAuthorizationServerInformation({
1403
1416
  provider,
1404
1417
  clientInformation
1405
1418
  });
@@ -1410,7 +1423,7 @@ async function authInternal(provider, {
1410
1423
  }
1411
1424
  validateAuthorizationResponseIssuer({
1412
1425
  callbackIssuer,
1413
- expectedIssuer: (_c = (_b3 = storedAuthorizationServerInformation.issuer) != null ? _b3 : metadata == null ? void 0 : metadata.issuer) != null ? _c : String(authorizationServerUrl)
1426
+ expectedIssuer: (_d = (_c = storedAuthorizationServerInformation.issuer) != null ? _c : metadata == null ? void 0 : metadata.issuer) != null ? _d : String(authorizationServerUrl)
1414
1427
  });
1415
1428
  assertAuthorizationServerInformationMatches({
1416
1429
  storedAuthorizationServerInformation,
@@ -1448,7 +1461,7 @@ async function authInternal(provider, {
1448
1461
  currentAuthorizationServerInformation
1449
1462
  });
1450
1463
  } else {
1451
- await ((_d = provider.invalidateCredentials) == null ? void 0 : _d.call(provider, "tokens"));
1464
+ await ((_e = provider.invalidateCredentials) == null ? void 0 : _e.call(provider, "tokens"));
1452
1465
  }
1453
1466
  try {
1454
1467
  if (storedAuthorizationServerInformation) {