@ai-sdk/mcp 0.0.21 → 0.0.23
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 +13 -0
- package/dist/index.js +39 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/mcp
|
|
2
2
|
|
|
3
|
+
## 0.0.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 01a2b53: Prevent streamable HTTP MCP background SSE disconnects from surfacing as unhandled promise rejections.
|
|
8
|
+
|
|
9
|
+
## 0.0.22
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [b85c4fb]
|
|
14
|
+
- @ai-sdk/provider-utils@3.0.28
|
|
15
|
+
|
|
3
16
|
## 0.0.21
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1301,7 +1301,7 @@ var HttpMCPTransport = class {
|
|
|
1301
1301
|
});
|
|
1302
1302
|
}
|
|
1303
1303
|
this.abortController = new AbortController();
|
|
1304
|
-
|
|
1304
|
+
this.startInboundSse();
|
|
1305
1305
|
}
|
|
1306
1306
|
async close() {
|
|
1307
1307
|
var _a3, _b3, _c;
|
|
@@ -1358,7 +1358,7 @@ var HttpMCPTransport = class {
|
|
|
1358
1358
|
}
|
|
1359
1359
|
if (response.status === 202) {
|
|
1360
1360
|
if (!this.inboundSseConnection) {
|
|
1361
|
-
|
|
1361
|
+
this.startInboundSse();
|
|
1362
1362
|
}
|
|
1363
1363
|
return;
|
|
1364
1364
|
}
|
|
@@ -1418,7 +1418,13 @@ var HttpMCPTransport = class {
|
|
|
1418
1418
|
(_c2 = this.onerror) == null ? void 0 : _c2.call(this, error2);
|
|
1419
1419
|
}
|
|
1420
1420
|
};
|
|
1421
|
-
processEvents()
|
|
1421
|
+
void processEvents().catch((error2) => {
|
|
1422
|
+
var _a4;
|
|
1423
|
+
if (error2 instanceof Error && error2.name === "AbortError") {
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
(_a4 = this.onerror) == null ? void 0 : _a4.call(this, error2);
|
|
1427
|
+
});
|
|
1422
1428
|
return;
|
|
1423
1429
|
}
|
|
1424
1430
|
const error = new MCPClientError({
|
|
@@ -1458,12 +1464,21 @@ var HttpMCPTransport = class {
|
|
|
1458
1464
|
}
|
|
1459
1465
|
const delay = this.getNextReconnectionDelay(this.inboundReconnectAttempts);
|
|
1460
1466
|
this.inboundReconnectAttempts += 1;
|
|
1461
|
-
setTimeout(
|
|
1467
|
+
setTimeout(() => {
|
|
1462
1468
|
var _a4;
|
|
1463
1469
|
if ((_a4 = this.abortController) == null ? void 0 : _a4.signal.aborted) return;
|
|
1464
|
-
|
|
1470
|
+
this.startInboundSse(false, this.lastInboundEventId);
|
|
1465
1471
|
}, delay);
|
|
1466
1472
|
}
|
|
1473
|
+
startInboundSse(triedAuth = false, resumeToken) {
|
|
1474
|
+
void this.openInboundSse(triedAuth, resumeToken).catch((error) => {
|
|
1475
|
+
var _a3;
|
|
1476
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1479
|
+
(_a3 = this.onerror) == null ? void 0 : _a3.call(this, error);
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1467
1482
|
// Open optional inbound SSE stream; best-effort and resumable
|
|
1468
1483
|
async openInboundSse(triedAuth = false, resumeToken) {
|
|
1469
1484
|
var _a3, _b3, _c, _d, _e, _f;
|
|
@@ -1547,10 +1562,27 @@ var HttpMCPTransport = class {
|
|
|
1547
1562
|
}
|
|
1548
1563
|
};
|
|
1549
1564
|
this.inboundSseConnection = {
|
|
1550
|
-
close: () =>
|
|
1565
|
+
close: () => {
|
|
1566
|
+
void reader.cancel().catch((error) => {
|
|
1567
|
+
var _a4;
|
|
1568
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
(_a4 = this.onerror) == null ? void 0 : _a4.call(this, error);
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1551
1574
|
};
|
|
1552
1575
|
this.inboundReconnectAttempts = 0;
|
|
1553
|
-
processEvents()
|
|
1576
|
+
void processEvents().catch((error) => {
|
|
1577
|
+
var _a4, _b4;
|
|
1578
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
(_a4 = this.onerror) == null ? void 0 : _a4.call(this, error);
|
|
1582
|
+
if (!((_b4 = this.abortController) == null ? void 0 : _b4.signal.aborted)) {
|
|
1583
|
+
this.scheduleInboundSseReconnection();
|
|
1584
|
+
}
|
|
1585
|
+
});
|
|
1554
1586
|
} catch (error) {
|
|
1555
1587
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1556
1588
|
return;
|