@ai-sdk/mcp 1.0.71 → 1.0.73

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
@@ -1497,7 +1497,7 @@ var SseMCPTransport = class {
1497
1497
  const transportSignal = (_b3 = this.abortController) == null ? void 0 : _b3.signal;
1498
1498
  const requestSignal = (options == null ? void 0 : options.signal) == null ? transportSignal : transportSignal == null ? options.signal : AbortSignal.any([transportSignal, options.signal]);
1499
1499
  const attempt = async (triedAuth = false) => {
1500
- var _a4, _b4, _c, _d, _e;
1500
+ var _a4, _b4;
1501
1501
  try {
1502
1502
  const headers = await this.commonHeaders({
1503
1503
  "Content-Type": "application/json"
@@ -1513,38 +1513,33 @@ var SseMCPTransport = class {
1513
1513
  if (response.status === 401 && this.authProvider && !triedAuth) {
1514
1514
  const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
1515
1515
  this.resourceMetadataUrl = resourceMetadataUrl;
1516
- try {
1517
- const result = await auth(this.authProvider, {
1518
- serverUrl: this.url,
1519
- resourceMetadataUrl: this.resourceMetadataUrl,
1520
- scope,
1521
- fetchFn: this.fetchFn
1522
- });
1523
- if (result !== "AUTHORIZED") {
1524
- const error = new UnauthorizedError();
1525
- (_a4 = this.onerror) == null ? void 0 : _a4.call(this, error);
1526
- return;
1527
- }
1528
- } catch (error) {
1529
- (_b4 = this.onerror) == null ? void 0 : _b4.call(this, error);
1530
- return;
1516
+ const result = await auth(this.authProvider, {
1517
+ serverUrl: this.url,
1518
+ resourceMetadataUrl: this.resourceMetadataUrl,
1519
+ scope,
1520
+ fetchFn: this.fetchFn
1521
+ });
1522
+ if (result !== "AUTHORIZED") {
1523
+ throw new UnauthorizedError();
1531
1524
  }
1532
1525
  return attempt(true);
1533
1526
  }
1534
1527
  if (!response.ok) {
1535
1528
  const text = await response.text().catch(() => null);
1536
1529
  const error = new MCPClientError({
1537
- message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${response.status}): ${text}`
1530
+ message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${response.status}): ${text}`,
1531
+ statusCode: response.status,
1532
+ url: endpoint.href,
1533
+ responseBody: text != null ? text : void 0
1538
1534
  });
1539
- (_c = this.onerror) == null ? void 0 : _c.call(this, error);
1540
- return;
1535
+ throw error;
1541
1536
  }
1542
1537
  } catch (error) {
1543
- if ((_d = options == null ? void 0 : options.signal) == null ? void 0 : _d.aborted) {
1538
+ if ((_a4 = options == null ? void 0 : options.signal) == null ? void 0 : _a4.aborted) {
1544
1539
  throw error;
1545
1540
  }
1546
- (_e = this.onerror) == null ? void 0 : _e.call(this, error);
1547
- return;
1541
+ (_b4 = this.onerror) == null ? void 0 : _b4.call(this, error);
1542
+ throw error;
1548
1543
  }
1549
1544
  };
1550
1545
  await attempt();