@ai-sdk/mcp 2.0.50 → 2.0.51
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 +14 -0
- package/dist/index.js +21 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/tool/oauth.ts +33 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/mcp",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.51",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ai-sdk/provider": "4.0.
|
|
35
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
34
|
+
"@ai-sdk/provider": "4.0.16",
|
|
35
|
+
"@ai-sdk/provider-utils": "5.0.42",
|
|
36
36
|
"cross-spawn": "^7.0.6",
|
|
37
37
|
"pkce-challenge": "^5.0.1"
|
|
38
38
|
},
|
package/src/tool/oauth.ts
CHANGED
|
@@ -1323,6 +1323,10 @@ async function authInternal(
|
|
|
1323
1323
|
): Promise<AuthResult> {
|
|
1324
1324
|
let resourceMetadata: OAuthProtectedResourceMetadata | undefined;
|
|
1325
1325
|
let authorizationServerUrl: string | URL | undefined;
|
|
1326
|
+
let clientInformation: OAuthClientInformation | undefined;
|
|
1327
|
+
let callbackAuthorizationServerInformation:
|
|
1328
|
+
| OAuthAuthorizationServerInformation
|
|
1329
|
+
| undefined;
|
|
1326
1330
|
|
|
1327
1331
|
/** Reject Protected Resource Metadata URLs outside the configured MCP server origin. */
|
|
1328
1332
|
assertResourceMetadataUrlSameOrigin(serverUrl, resourceMetadataUrl);
|
|
@@ -1342,9 +1346,27 @@ async function authInternal(
|
|
|
1342
1346
|
}
|
|
1343
1347
|
} catch {}
|
|
1344
1348
|
|
|
1345
|
-
/**
|
|
1349
|
+
/**
|
|
1350
|
+
* A callback may not have the original PRM URL from the authentication
|
|
1351
|
+
* challenge. Use the authorization server pinned before redirecting when
|
|
1352
|
+
* rediscovery does not select one.
|
|
1353
|
+
*/
|
|
1354
|
+
if (authorizationCode !== undefined) {
|
|
1355
|
+
clientInformation = await Promise.resolve(provider.clientInformation());
|
|
1356
|
+
if (clientInformation) {
|
|
1357
|
+
callbackAuthorizationServerInformation =
|
|
1358
|
+
await getStoredAuthorizationServerInformation({
|
|
1359
|
+
provider,
|
|
1360
|
+
clientInformation,
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
/** Reuse the callback pin, then fall back to the legacy MCP-as-AS behavior. */
|
|
1346
1366
|
if (!authorizationServerUrl) {
|
|
1347
|
-
authorizationServerUrl =
|
|
1367
|
+
authorizationServerUrl =
|
|
1368
|
+
callbackAuthorizationServerInformation?.authorizationServerUrl ??
|
|
1369
|
+
serverUrl;
|
|
1348
1370
|
}
|
|
1349
1371
|
|
|
1350
1372
|
const parsedServerUrl = new URL(serverUrl);
|
|
@@ -1396,13 +1418,16 @@ async function authInternal(
|
|
|
1396
1418
|
});
|
|
1397
1419
|
|
|
1398
1420
|
/** Load or register client credentials with the AS pin attached. */
|
|
1399
|
-
|
|
1421
|
+
if (authorizationCode === undefined) {
|
|
1422
|
+
clientInformation = await Promise.resolve(provider.clientInformation());
|
|
1423
|
+
}
|
|
1400
1424
|
if (clientInformation?.issuer != null) {
|
|
1401
1425
|
const storedAuthorizationServerInformation =
|
|
1402
|
-
|
|
1426
|
+
callbackAuthorizationServerInformation ??
|
|
1427
|
+
(await getStoredAuthorizationServerInformation({
|
|
1403
1428
|
provider,
|
|
1404
1429
|
clientInformation,
|
|
1405
|
-
});
|
|
1430
|
+
}));
|
|
1406
1431
|
if (storedAuthorizationServerInformation) {
|
|
1407
1432
|
assertAuthorizationServerInformationMatches({
|
|
1408
1433
|
storedAuthorizationServerInformation,
|
|
@@ -1452,10 +1477,11 @@ async function authInternal(
|
|
|
1452
1477
|
}
|
|
1453
1478
|
|
|
1454
1479
|
const storedAuthorizationServerInformation =
|
|
1455
|
-
|
|
1480
|
+
callbackAuthorizationServerInformation ??
|
|
1481
|
+
(await getStoredAuthorizationServerInformation({
|
|
1456
1482
|
provider,
|
|
1457
1483
|
clientInformation,
|
|
1458
|
-
});
|
|
1484
|
+
}));
|
|
1459
1485
|
if (!storedAuthorizationServerInformation) {
|
|
1460
1486
|
throw new MCPClientOAuthError({
|
|
1461
1487
|
message:
|