@ai-sdk/mcp 1.0.84 → 1.0.85

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/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.invalidateCredentials) == null ? void 0 : _a3.call(provider, "all"));
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 ((_b3 = provider.invalidateCredentials) == null ? void 0 : _b3.call(provider, "tokens"));
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
- try {
2467
- return this.callToolWithRetry({
2468
- options,
2469
- execute: () => this.request({
2470
- request: {
2471
- method: "tools/call",
2472
- params: { name: name3, arguments: args }
2473
- },
2474
- resultSchema: CallToolResultSchema,
2475
- options: {
2476
- signal: options == null ? void 0 : options.abortSignal
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
- try {
2489
- return this.request({
2490
- request: { method: "resources/list", params },
2491
- resultSchema: ListResourcesResultSchema,
2492
- options
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
- try {
2503
- return this.request({
2504
- request: { method: "resources/read", params: { uri } },
2505
- resultSchema: ReadResourceResultSchema,
2506
- options
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
- try {
2516
- return this.request({
2517
- request: { method: "resources/templates/list" },
2518
- resultSchema: ListResourceTemplatesResultSchema,
2519
- options
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
- try {
2530
- return this.request({
2531
- request: { method: "prompts/list", params },
2532
- resultSchema: ListPromptsResultSchema,
2533
- options
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
- try {
2545
- return this.request({
2546
- request: { method: "prompts/get", params: { name: name3, arguments: args } },
2547
- resultSchema: GetPromptResultSchema,
2548
- options
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,