Cleaner rl handling
This commit is contained in:
parent
f5637a04a2
commit
e065b112f2
1 changed files with 14 additions and 10 deletions
|
|
@ -159,16 +159,20 @@ class MCPClient {
|
||||||
output: process.stdout,
|
output: process.stdout,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("\nMCP Client Started!");
|
try {
|
||||||
console.log("Type your queries or 'quit' to exit.");
|
console.log("\nMCP Client Started!");
|
||||||
|
console.log("Type your queries or 'quit' to exit.");
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const message = await rl.question("\nQuery: ");
|
const message = await rl.question("\nQuery: ");
|
||||||
if (message === "quit") {
|
if (message.toLowerCase() === "quit") {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
const response = await this.processQuery(message);
|
||||||
|
console.log("\n" + response);
|
||||||
}
|
}
|
||||||
const response = await this.processQuery(message);
|
} finally {
|
||||||
console.log("\n" + response);
|
rl.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,7 +186,7 @@ class MCPClient {
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
if (process.argv.length < 3) {
|
if (process.argv.length < 3) {
|
||||||
console.log("Usage: node index.ts <path_to_server_script>");
|
console.log("Usage: node build/index.js <path_to_server_script>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const mcpClient = new MCPClient();
|
const mcpClient = new MCPClient();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue