@ai-sdk/mcp 1.0.43 → 1.0.44

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,20 @@
1
1
  # @ai-sdk/mcp
2
2
 
3
+ ## 1.0.44
4
+
5
+ ### Patch Changes
6
+
7
+ - 77775a4: feat(mcp): expose `statusCode`, `url`, and `responseBody` on `MCPClientError` for HTTP transport failures
8
+
9
+ `MCPClientError` now carries structured HTTP context when it originates from the
10
+ streamable HTTP transport. This lets downstream consumers (e.g. agent frameworks
11
+ that need to decide whether to fall back from streamable HTTP to legacy SSE
12
+ transport per the MCP spec) branch on the actual response status without parsing
13
+ the error message string.
14
+
15
+ Fields are optional — they remain `undefined` for stdio transport errors and for
16
+ non-response failures (network errors, aborts).
17
+
3
18
  ## 1.0.43
4
19
 
5
20
  ### Patch Changes
package/dist/index.js CHANGED
@@ -54,12 +54,18 @@ var MCPClientError = class extends (_b = import_provider.AISDKError, _a = symbol
54
54
  message,
55
55
  cause,
56
56
  data,
57
- code
57
+ code,
58
+ statusCode,
59
+ url,
60
+ responseBody
58
61
  }) {
59
62
  super({ name: name3, message, cause });
60
63
  this[_a] = true;
61
64
  this.data = data;
62
65
  this.code = code;
66
+ this.statusCode = statusCode;
67
+ this.url = url;
68
+ this.responseBody = responseBody;
63
69
  }
64
70
  static isInstance(error) {
65
71
  return import_provider.AISDKError.hasMarker(error, marker);
@@ -1443,7 +1449,10 @@ var HttpMCPTransport = class {
1443
1449
  errorMessage += ". This server does not support HTTP transport. Try using `sse` transport instead";
1444
1450
  }
1445
1451
  const error2 = new MCPClientError({
1446
- message: errorMessage
1452
+ message: errorMessage,
1453
+ statusCode: response.status,
1454
+ url: this.url.href,
1455
+ responseBody: text != null ? text : void 0
1447
1456
  });
1448
1457
  (_c = this.onerror) == null ? void 0 : _c.call(this, error2);
1449
1458
  throw error2;
@@ -1462,7 +1471,9 @@ var HttpMCPTransport = class {
1462
1471
  if (contentType.includes("text/event-stream")) {
1463
1472
  if (!response.body) {
1464
1473
  const error2 = new MCPClientError({
1465
- message: "MCP HTTP Transport Error: text/event-stream response without body"
1474
+ message: "MCP HTTP Transport Error: text/event-stream response without body",
1475
+ statusCode: response.status,
1476
+ url: this.url.href
1466
1477
  });
1467
1478
  (_e = this.onerror) == null ? void 0 : _e.call(this, error2);
1468
1479
  throw error2;
@@ -1500,7 +1511,9 @@ var HttpMCPTransport = class {
1500
1511
  return;
1501
1512
  }
1502
1513
  const error = new MCPClientError({
1503
- message: `MCP HTTP Transport Error: Unexpected content type: ${contentType}`
1514
+ message: `MCP HTTP Transport Error: Unexpected content type: ${contentType}`,
1515
+ statusCode: response.status,
1516
+ url: this.url.href
1504
1517
  });
1505
1518
  (_f = this.onerror) == null ? void 0 : _f.call(this, error);
1506
1519
  throw error;
@@ -1582,7 +1595,9 @@ var HttpMCPTransport = class {
1582
1595
  }
1583
1596
  if (!response.ok || !response.body) {
1584
1597
  const error = new MCPClientError({
1585
- message: `MCP HTTP Transport Error: GET SSE failed: ${response.status} ${response.statusText}`
1598
+ message: `MCP HTTP Transport Error: GET SSE failed: ${response.status} ${response.statusText}`,
1599
+ statusCode: response.status,
1600
+ url: this.url.href
1586
1601
  });
1587
1602
  (_d = this.onerror) == null ? void 0 : _d.call(this, error);
1588
1603
  return;