@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 +14 -0
- package/dist/index.js +17 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -22
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +19 -4
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +9 -4
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +4 -2
- package/src/error/mcp-client-error.ts +1 -1
- package/src/tool/mcp-sse-transport.ts +13 -18
- package/src/tool/mcp-stdio/create-child-process.ts +11 -1
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
|
|
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
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
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
|
-
|
|
1540
|
-
return;
|
|
1535
|
+
throw error;
|
|
1541
1536
|
}
|
|
1542
1537
|
} catch (error) {
|
|
1543
|
-
if ((
|
|
1538
|
+
if ((_a4 = options == null ? void 0 : options.signal) == null ? void 0 : _a4.aborted) {
|
|
1544
1539
|
throw error;
|
|
1545
1540
|
}
|
|
1546
|
-
(
|
|
1547
|
-
|
|
1541
|
+
(_b4 = this.onerror) == null ? void 0 : _b4.call(this, error);
|
|
1542
|
+
throw error;
|
|
1548
1543
|
}
|
|
1549
1544
|
};
|
|
1550
1545
|
await attempt();
|