@ai-sdk/mcp 2.0.34 → 2.0.36
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/mcp-stdio/index.js +9 -4
- package/dist/mcp-stdio/index.js.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/mcp
|
|
2
2
|
|
|
3
|
+
## 2.0.36
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b352a6a: fix(mcp): support spawning command shims such as `npx` on Windows
|
|
8
|
+
- Updated dependencies [b74971f]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.29
|
|
10
|
+
|
|
11
|
+
## 2.0.35
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 76fb75d: fix(mcp): reject SSE requests when POST responses are unsuccessful
|
|
16
|
+
|
|
3
17
|
## 2.0.34
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1560,7 +1560,7 @@ var SseMCPTransport = class {
|
|
|
1560
1560
|
const transportSignal = (_b3 = this.abortController) == null ? void 0 : _b3.signal;
|
|
1561
1561
|
const requestSignal = (options == null ? void 0 : options.signal) == null ? transportSignal : transportSignal == null ? options.signal : AbortSignal.any([transportSignal, options.signal]);
|
|
1562
1562
|
const attempt = async (triedAuth = false) => {
|
|
1563
|
-
var _a4, _b4
|
|
1563
|
+
var _a4, _b4;
|
|
1564
1564
|
try {
|
|
1565
1565
|
const headers = await this.commonHeaders({
|
|
1566
1566
|
"Content-Type": "application/json"
|
|
@@ -1576,38 +1576,33 @@ var SseMCPTransport = class {
|
|
|
1576
1576
|
if (response.status === 401 && this.authProvider && !triedAuth) {
|
|
1577
1577
|
const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
|
|
1578
1578
|
this.resourceMetadataUrl = resourceMetadataUrl;
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
const error = new UnauthorizedError();
|
|
1588
|
-
(_a4 = this.onerror) == null ? void 0 : _a4.call(this, error);
|
|
1589
|
-
return;
|
|
1590
|
-
}
|
|
1591
|
-
} catch (error) {
|
|
1592
|
-
(_b4 = this.onerror) == null ? void 0 : _b4.call(this, error);
|
|
1593
|
-
return;
|
|
1579
|
+
const result = await auth(this.authProvider, {
|
|
1580
|
+
serverUrl: this.url,
|
|
1581
|
+
resourceMetadataUrl: this.resourceMetadataUrl,
|
|
1582
|
+
scope,
|
|
1583
|
+
fetchFn: this.fetchFn
|
|
1584
|
+
});
|
|
1585
|
+
if (result !== "AUTHORIZED") {
|
|
1586
|
+
throw new UnauthorizedError();
|
|
1594
1587
|
}
|
|
1595
1588
|
return attempt(true);
|
|
1596
1589
|
}
|
|
1597
1590
|
if (!response.ok) {
|
|
1598
1591
|
const text = await response.text().catch(() => null);
|
|
1599
1592
|
const error = new MCPClientError({
|
|
1600
|
-
message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${response.status}): ${text}
|
|
1593
|
+
message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${response.status}): ${text}`,
|
|
1594
|
+
statusCode: response.status,
|
|
1595
|
+
url: endpoint.href,
|
|
1596
|
+
responseBody: text != null ? text : void 0
|
|
1601
1597
|
});
|
|
1602
|
-
|
|
1603
|
-
return;
|
|
1598
|
+
throw error;
|
|
1604
1599
|
}
|
|
1605
1600
|
} catch (error) {
|
|
1606
|
-
if ((
|
|
1601
|
+
if ((_a4 = options == null ? void 0 : options.signal) == null ? void 0 : _a4.aborted) {
|
|
1607
1602
|
throw error;
|
|
1608
1603
|
}
|
|
1609
|
-
(
|
|
1610
|
-
|
|
1604
|
+
(_b4 = this.onerror) == null ? void 0 : _b4.call(this, error);
|
|
1605
|
+
throw error;
|
|
1611
1606
|
}
|
|
1612
1607
|
};
|
|
1613
1608
|
await attempt();
|