@ai-sdk/mcp 1.0.43 → 1.0.45
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 +21 -0
- package/dist/index.js +28 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -5
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +7 -1
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +7 -1
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/error/mcp-client-error.ts +40 -0
- package/src/tool/mcp-client.ts +9 -0
- package/src/tool/mcp-http-transport.ts +9 -0
package/dist/index.mjs
CHANGED
|
@@ -20,12 +20,18 @@ var MCPClientError = class extends (_b = AISDKError, _a = symbol, _b) {
|
|
|
20
20
|
message,
|
|
21
21
|
cause,
|
|
22
22
|
data,
|
|
23
|
-
code
|
|
23
|
+
code,
|
|
24
|
+
statusCode,
|
|
25
|
+
url,
|
|
26
|
+
responseBody
|
|
24
27
|
}) {
|
|
25
28
|
super({ name: name3, message, cause });
|
|
26
29
|
this[_a] = true;
|
|
27
30
|
this.data = data;
|
|
28
31
|
this.code = code;
|
|
32
|
+
this.statusCode = statusCode;
|
|
33
|
+
this.url = url;
|
|
34
|
+
this.responseBody = responseBody;
|
|
29
35
|
}
|
|
30
36
|
static isInstance(error) {
|
|
31
37
|
return AISDKError.hasMarker(error, marker);
|
|
@@ -1417,7 +1423,10 @@ var HttpMCPTransport = class {
|
|
|
1417
1423
|
errorMessage += ". This server does not support HTTP transport. Try using `sse` transport instead";
|
|
1418
1424
|
}
|
|
1419
1425
|
const error2 = new MCPClientError({
|
|
1420
|
-
message: errorMessage
|
|
1426
|
+
message: errorMessage,
|
|
1427
|
+
statusCode: response.status,
|
|
1428
|
+
url: this.url.href,
|
|
1429
|
+
responseBody: text != null ? text : void 0
|
|
1421
1430
|
});
|
|
1422
1431
|
(_c = this.onerror) == null ? void 0 : _c.call(this, error2);
|
|
1423
1432
|
throw error2;
|
|
@@ -1436,7 +1445,9 @@ var HttpMCPTransport = class {
|
|
|
1436
1445
|
if (contentType.includes("text/event-stream")) {
|
|
1437
1446
|
if (!response.body) {
|
|
1438
1447
|
const error2 = new MCPClientError({
|
|
1439
|
-
message: "MCP HTTP Transport Error: text/event-stream response without body"
|
|
1448
|
+
message: "MCP HTTP Transport Error: text/event-stream response without body",
|
|
1449
|
+
statusCode: response.status,
|
|
1450
|
+
url: this.url.href
|
|
1440
1451
|
});
|
|
1441
1452
|
(_e = this.onerror) == null ? void 0 : _e.call(this, error2);
|
|
1442
1453
|
throw error2;
|
|
@@ -1474,7 +1485,9 @@ var HttpMCPTransport = class {
|
|
|
1474
1485
|
return;
|
|
1475
1486
|
}
|
|
1476
1487
|
const error = new MCPClientError({
|
|
1477
|
-
message: `MCP HTTP Transport Error: Unexpected content type: ${contentType}
|
|
1488
|
+
message: `MCP HTTP Transport Error: Unexpected content type: ${contentType}`,
|
|
1489
|
+
statusCode: response.status,
|
|
1490
|
+
url: this.url.href
|
|
1478
1491
|
});
|
|
1479
1492
|
(_f = this.onerror) == null ? void 0 : _f.call(this, error);
|
|
1480
1493
|
throw error;
|
|
@@ -1556,7 +1569,9 @@ var HttpMCPTransport = class {
|
|
|
1556
1569
|
}
|
|
1557
1570
|
if (!response.ok || !response.body) {
|
|
1558
1571
|
const error = new MCPClientError({
|
|
1559
|
-
message: `MCP HTTP Transport Error: GET SSE failed: ${response.status} ${response.statusText}
|
|
1572
|
+
message: `MCP HTTP Transport Error: GET SSE failed: ${response.status} ${response.statusText}`,
|
|
1573
|
+
statusCode: response.status,
|
|
1574
|
+
url: this.url.href
|
|
1560
1575
|
});
|
|
1561
1576
|
(_d = this.onerror) == null ? void 0 : _d.call(this, error);
|
|
1562
1577
|
return;
|
|
@@ -2097,6 +2112,14 @@ var DefaultMCPClient = class {
|
|
|
2097
2112
|
}
|
|
2098
2113
|
async onRequestMessage(request) {
|
|
2099
2114
|
try {
|
|
2115
|
+
if (request.method === "ping") {
|
|
2116
|
+
await this.transport.send({
|
|
2117
|
+
jsonrpc: "2.0",
|
|
2118
|
+
id: request.id,
|
|
2119
|
+
result: {}
|
|
2120
|
+
});
|
|
2121
|
+
return;
|
|
2122
|
+
}
|
|
2100
2123
|
if (request.method !== "elicitation/create") {
|
|
2101
2124
|
await this.transport.send({
|
|
2102
2125
|
jsonrpc: "2.0",
|