@eko-ai/eko-nodejs 3.0.0-alpha.9 → 3.0.1-alpha.1
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.cjs.js
CHANGED
|
@@ -8419,6 +8419,18 @@ class SimpleStdioMcpClient {
|
|
|
8419
8419
|
});
|
|
8420
8420
|
eko.Log.info("MCP Client, connection successful:", this.command, this.args);
|
|
8421
8421
|
}
|
|
8422
|
+
async listTools(param, signal) {
|
|
8423
|
+
const message = await this.sendMessage("tools/list", {
|
|
8424
|
+
...param,
|
|
8425
|
+
}, signal);
|
|
8426
|
+
return message.result.tools || [];
|
|
8427
|
+
}
|
|
8428
|
+
async callTool(param, signal) {
|
|
8429
|
+
const message = await this.sendMessage("tools/call", {
|
|
8430
|
+
...param,
|
|
8431
|
+
}, signal);
|
|
8432
|
+
return message.result;
|
|
8433
|
+
}
|
|
8422
8434
|
async sendMessage(method, params = {}, signal) {
|
|
8423
8435
|
if (!this.process) {
|
|
8424
8436
|
await this.connect();
|
|
@@ -8451,31 +8463,36 @@ class SimpleStdioMcpClient {
|
|
|
8451
8463
|
if (!suc) {
|
|
8452
8464
|
throw new Error("SseClient Response Exception: " + message);
|
|
8453
8465
|
}
|
|
8454
|
-
|
|
8466
|
+
const messageData = await callback;
|
|
8467
|
+
this.handleError(method, messageData);
|
|
8468
|
+
return messageData;
|
|
8455
8469
|
}
|
|
8456
8470
|
finally {
|
|
8457
8471
|
this.requestMap.delete(id);
|
|
8458
8472
|
}
|
|
8459
8473
|
}
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
}, signal);
|
|
8464
|
-
if (message.error) {
|
|
8465
|
-
eko.Log.error("McpClient listTools error: ", param, message);
|
|
8466
|
-
throw new Error("listTools Exception");
|
|
8474
|
+
handleError(method, message) {
|
|
8475
|
+
if (!message) {
|
|
8476
|
+
throw new Error(`MCP ${method} error: no response`);
|
|
8467
8477
|
}
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8478
|
+
if (message?.error) {
|
|
8479
|
+
eko.Log.error(`MCP ${method} error: ` + message.error);
|
|
8480
|
+
throw new Error(`MCP ${method} error: ` +
|
|
8481
|
+
(typeof message.error === "string"
|
|
8482
|
+
? message.error
|
|
8483
|
+
: message.error.message));
|
|
8484
|
+
}
|
|
8485
|
+
if (message.result?.isError == true) {
|
|
8486
|
+
if (message.result.content) {
|
|
8487
|
+
throw new Error(`MCP ${method} error: ` +
|
|
8488
|
+
(typeof message.result.content === "string"
|
|
8489
|
+
? message.result.content
|
|
8490
|
+
: message.result.content[0].text));
|
|
8491
|
+
}
|
|
8492
|
+
else {
|
|
8493
|
+
throw new Error(`MCP ${method} error: ` + JSON.stringify(message.result));
|
|
8494
|
+
}
|
|
8477
8495
|
}
|
|
8478
|
-
return message.result;
|
|
8479
8496
|
}
|
|
8480
8497
|
isConnected() {
|
|
8481
8498
|
return (this.process != null && !this.process.killed && !this.process.exitCode);
|