"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
const stdio_js_1 = require("@modelcontextprotocol/sdk/client/stdio.js");
async function main() {
const toolName = process.argv[2];
const toolArgs = process.argv[3] ? JSON.parse(process.argv[3]) : {};
if (!toolName) {
console.error("Usage: node client.js <tool_name> <json_args>");
process.exit(1);
}
const transport = new stdio_js_1.StdioClientTransport({
command: "node",
args: ["./build/index.js"],
});
const client = new index_js_1.Client({ name: "cli-client", version: "1.0.0" }, { capabilities: {} });
await client.connect(transport);
try {
const result = await client.callTool({
name: toolName,
arguments: toolArgs,
});
// @ts-ignore
console.log(result.content[0].text);
}
catch (error) {
console.error("Error:", error);
}
finally {
await client.close();
}
}
main();