@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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-sdk/mcp
2
2
 
3
+ ## 1.0.73
4
+
5
+ ### Patch Changes
6
+
7
+ - b8e4215: fix(mcp): support spawning command shims such as `npx` on Windows
8
+ - Updated dependencies [2d172fb]
9
+ - @ai-sdk/provider-utils@4.0.47
10
+
11
+ ## 1.0.72
12
+
13
+ ### Patch Changes
14
+
15
+ - 0075ed5: fix(mcp): reject SSE requests when POST responses are unsuccessful
16
+
3
17
  ## 1.0.71
4
18
 
5
19
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1527,7 +1527,7 @@ var SseMCPTransport = class {
1527
1527
  const transportSignal = (_b3 = this.abortController) == null ? void 0 : _b3.signal;
1528
1528
  const requestSignal = (options == null ? void 0 : options.signal) == null ? transportSignal : transportSignal == null ? options.signal : AbortSignal.any([transportSignal, options.signal]);
1529
1529
  const attempt = async (triedAuth = false) => {
1530
- var _a4, _b4, _c, _d, _e;
1530
+ var _a4, _b4;
1531
1531
  try {
1532
1532
  const headers = await this.commonHeaders({
1533
1533
  "Content-Type": "application/json"
@@ -1543,38 +1543,33 @@ var SseMCPTransport = class {
1543
1543
  if (response.status === 401 && this.authProvider && !triedAuth) {
1544
1544
  const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
1545
1545
  this.resourceMetadataUrl = resourceMetadataUrl;
1546
- try {
1547
- const result = await auth(this.authProvider, {
1548
- serverUrl: this.url,
1549
- resourceMetadataUrl: this.resourceMetadataUrl,
1550
- scope,
1551
- fetchFn: this.fetchFn
1552
- });
1553
- if (result !== "AUTHORIZED") {
1554
- const error = new UnauthorizedError();
1555
- (_a4 = this.onerror) == null ? void 0 : _a4.call(this, error);
1556
- return;
1557
- }
1558
- } catch (error) {
1559
- (_b4 = this.onerror) == null ? void 0 : _b4.call(this, error);
1560
- return;
1546
+ const result = await auth(this.authProvider, {
1547
+ serverUrl: this.url,
1548
+ resourceMetadataUrl: this.resourceMetadataUrl,
1549
+ scope,
1550
+ fetchFn: this.fetchFn
1551
+ });
1552
+ if (result !== "AUTHORIZED") {
1553
+ throw new UnauthorizedError();
1561
1554
  }
1562
1555
  return attempt(true);
1563
1556
  }
1564
1557
  if (!response.ok) {
1565
1558
  const text = await response.text().catch(() => null);
1566
1559
  const error = new MCPClientError({
1567
- message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${response.status}): ${text}`
1560
+ message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${response.status}): ${text}`,
1561
+ statusCode: response.status,
1562
+ url: endpoint.href,
1563
+ responseBody: text != null ? text : void 0
1568
1564
  });
1569
- (_c = this.onerror) == null ? void 0 : _c.call(this, error);
1570
- return;
1565
+ throw error;
1571
1566
  }
1572
1567
  } catch (error) {
1573
- if ((_d = options == null ? void 0 : options.signal) == null ? void 0 : _d.aborted) {
1568
+ if ((_a4 = options == null ? void 0 : options.signal) == null ? void 0 : _a4.aborted) {
1574
1569
  throw error;
1575
1570
  }
1576
- (_e = this.onerror) == null ? void 0 : _e.call(this, error);
1577
- return;
1571
+ (_b4 = this.onerror) == null ? void 0 : _b4.call(this, error);
1572
+ throw error;
1578
1573
  }
1579
1574
  };
1580
1575
  await attempt();