@ai-sdk/mcp 1.0.84 → 1.0.86
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 +17 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +44 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -65
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +8 -1
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +8 -1
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/tool/mcp-client.ts +39 -63
- package/src/tool/mcp-stdio/get-environment.ts +23 -16
- package/src/tool/oauth.ts +17 -0
package/dist/index.mjs
CHANGED
|
@@ -1129,15 +1129,18 @@ async function registerClient(authorizationServerUrl, {
|
|
|
1129
1129
|
return OAuthClientInformationFullSchema.parse(await response.json());
|
|
1130
1130
|
}
|
|
1131
1131
|
async function auth(provider, options) {
|
|
1132
|
-
var _a3, _b3;
|
|
1132
|
+
var _a3, _b3, _c;
|
|
1133
1133
|
try {
|
|
1134
1134
|
return await authInternal(provider, options);
|
|
1135
1135
|
} catch (error) {
|
|
1136
1136
|
if (error instanceof InvalidClientError || error instanceof UnauthorizedClientError) {
|
|
1137
|
-
await ((_a3 = provider.
|
|
1137
|
+
if (options.authorizationCode !== void 0 || !await ((_a3 = provider.isClientInformationDynamicallyRegistered) == null ? void 0 : _a3.call(provider))) {
|
|
1138
|
+
throw error;
|
|
1139
|
+
}
|
|
1140
|
+
await ((_b3 = provider.invalidateCredentials) == null ? void 0 : _b3.call(provider, "all"));
|
|
1138
1141
|
return await authInternal(provider, options);
|
|
1139
1142
|
} else if (error instanceof InvalidGrantError) {
|
|
1140
|
-
await ((
|
|
1143
|
+
await ((_c = provider.invalidateCredentials) == null ? void 0 : _c.call(provider, "tokens"));
|
|
1141
1144
|
return await authInternal(provider, options);
|
|
1142
1145
|
}
|
|
1143
1146
|
throw error;
|
|
@@ -2463,93 +2466,69 @@ var DefaultMCPClient = class {
|
|
|
2463
2466
|
args,
|
|
2464
2467
|
options
|
|
2465
2468
|
}) {
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
options:
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
});
|
|
2480
|
-
} catch (error) {
|
|
2481
|
-
throw error;
|
|
2482
|
-
}
|
|
2469
|
+
return this.callToolWithRetry({
|
|
2470
|
+
options,
|
|
2471
|
+
execute: () => this.request({
|
|
2472
|
+
request: {
|
|
2473
|
+
method: "tools/call",
|
|
2474
|
+
params: { name: name3, arguments: args }
|
|
2475
|
+
},
|
|
2476
|
+
resultSchema: CallToolResultSchema,
|
|
2477
|
+
options: {
|
|
2478
|
+
signal: options == null ? void 0 : options.abortSignal
|
|
2479
|
+
}
|
|
2480
|
+
})
|
|
2481
|
+
});
|
|
2483
2482
|
}
|
|
2484
2483
|
async listResourcesInternal({
|
|
2485
2484
|
params,
|
|
2486
2485
|
options
|
|
2487
2486
|
} = {}) {
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
});
|
|
2494
|
-
} catch (error) {
|
|
2495
|
-
throw error;
|
|
2496
|
-
}
|
|
2487
|
+
return this.request({
|
|
2488
|
+
request: { method: "resources/list", params },
|
|
2489
|
+
resultSchema: ListResourcesResultSchema,
|
|
2490
|
+
options
|
|
2491
|
+
});
|
|
2497
2492
|
}
|
|
2498
2493
|
async readResourceInternal({
|
|
2499
2494
|
uri,
|
|
2500
2495
|
options
|
|
2501
2496
|
}) {
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
});
|
|
2508
|
-
} catch (error) {
|
|
2509
|
-
throw error;
|
|
2510
|
-
}
|
|
2497
|
+
return this.request({
|
|
2498
|
+
request: { method: "resources/read", params: { uri } },
|
|
2499
|
+
resultSchema: ReadResourceResultSchema,
|
|
2500
|
+
options
|
|
2501
|
+
});
|
|
2511
2502
|
}
|
|
2512
2503
|
async listResourceTemplatesInternal({
|
|
2513
2504
|
options
|
|
2514
2505
|
} = {}) {
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
});
|
|
2521
|
-
} catch (error) {
|
|
2522
|
-
throw error;
|
|
2523
|
-
}
|
|
2506
|
+
return this.request({
|
|
2507
|
+
request: { method: "resources/templates/list" },
|
|
2508
|
+
resultSchema: ListResourceTemplatesResultSchema,
|
|
2509
|
+
options
|
|
2510
|
+
});
|
|
2524
2511
|
}
|
|
2525
2512
|
async listPromptsInternal({
|
|
2526
2513
|
params,
|
|
2527
2514
|
options
|
|
2528
2515
|
} = {}) {
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
});
|
|
2535
|
-
} catch (error) {
|
|
2536
|
-
throw error;
|
|
2537
|
-
}
|
|
2516
|
+
return this.request({
|
|
2517
|
+
request: { method: "prompts/list", params },
|
|
2518
|
+
resultSchema: ListPromptsResultSchema,
|
|
2519
|
+
options
|
|
2520
|
+
});
|
|
2538
2521
|
}
|
|
2539
2522
|
async getPromptInternal({
|
|
2540
2523
|
name: name3,
|
|
2541
2524
|
args,
|
|
2542
2525
|
options
|
|
2543
2526
|
}) {
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
});
|
|
2550
|
-
} catch (error) {
|
|
2551
|
-
throw error;
|
|
2552
|
-
}
|
|
2527
|
+
return this.request({
|
|
2528
|
+
request: { method: "prompts/get", params: { name: name3, arguments: args } },
|
|
2529
|
+
resultSchema: GetPromptResultSchema,
|
|
2530
|
+
options
|
|
2531
|
+
});
|
|
2553
2532
|
}
|
|
2554
2533
|
async completeInternal({
|
|
2555
2534
|
options,
|