@eko-ai/eko-nodejs 3.0.1 → 3.0.3
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/dist/index.cjs.js +35 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +35 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/mcp/stdio.d.ts +2 -1
- package/dist/mcp/stdio.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -8395,6 +8395,18 @@ class SimpleStdioMcpClient {
|
|
|
8395
8395
|
});
|
|
8396
8396
|
Log.info("MCP Client, connection successful:", this.command, this.args);
|
|
8397
8397
|
}
|
|
8398
|
+
async listTools(param, signal) {
|
|
8399
|
+
const message = await this.sendMessage("tools/list", {
|
|
8400
|
+
...param,
|
|
8401
|
+
}, signal);
|
|
8402
|
+
return message.result.tools || [];
|
|
8403
|
+
}
|
|
8404
|
+
async callTool(param, signal) {
|
|
8405
|
+
const message = await this.sendMessage("tools/call", {
|
|
8406
|
+
...param,
|
|
8407
|
+
}, signal);
|
|
8408
|
+
return message.result;
|
|
8409
|
+
}
|
|
8398
8410
|
async sendMessage(method, params = {}, signal) {
|
|
8399
8411
|
if (!this.process) {
|
|
8400
8412
|
await this.connect();
|
|
@@ -8427,31 +8439,36 @@ class SimpleStdioMcpClient {
|
|
|
8427
8439
|
if (!suc) {
|
|
8428
8440
|
throw new Error("SseClient Response Exception: " + message);
|
|
8429
8441
|
}
|
|
8430
|
-
|
|
8442
|
+
const messageData = await callback;
|
|
8443
|
+
this.handleError(method, messageData);
|
|
8444
|
+
return messageData;
|
|
8431
8445
|
}
|
|
8432
8446
|
finally {
|
|
8433
8447
|
this.requestMap.delete(id);
|
|
8434
8448
|
}
|
|
8435
8449
|
}
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
}, signal);
|
|
8440
|
-
if (message.error) {
|
|
8441
|
-
Log.error("McpClient listTools error: ", param, message);
|
|
8442
|
-
throw new Error("listTools Exception");
|
|
8450
|
+
handleError(method, message) {
|
|
8451
|
+
if (!message) {
|
|
8452
|
+
throw new Error(`MCP ${method} error: no response`);
|
|
8443
8453
|
}
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8454
|
+
if (message?.error) {
|
|
8455
|
+
Log.error(`MCP ${method} error: ` + message.error);
|
|
8456
|
+
throw new Error(`MCP ${method} error: ` +
|
|
8457
|
+
(typeof message.error === "string"
|
|
8458
|
+
? message.error
|
|
8459
|
+
: message.error.message));
|
|
8460
|
+
}
|
|
8461
|
+
if (message.result?.isError == true) {
|
|
8462
|
+
if (message.result.content) {
|
|
8463
|
+
throw new Error(`MCP ${method} error: ` +
|
|
8464
|
+
(typeof message.result.content === "string"
|
|
8465
|
+
? message.result.content
|
|
8466
|
+
: message.result.content[0].text));
|
|
8467
|
+
}
|
|
8468
|
+
else {
|
|
8469
|
+
throw new Error(`MCP ${method} error: ` + JSON.stringify(message.result));
|
|
8470
|
+
}
|
|
8453
8471
|
}
|
|
8454
|
-
return message.result;
|
|
8455
8472
|
}
|
|
8456
8473
|
isConnected() {
|
|
8457
8474
|
return (this.process != null && !this.process.killed && !this.process.exitCode);
|