This commit is contained in:
Ashwin Bhat
2024-10-08 07:33:47 -07:00
parent 51cde09845
commit 38e1c8b2b9
5 changed files with 189 additions and 10 deletions

View File

@@ -30,6 +30,19 @@ wss.on("connection", (ws: WebSocket) => {
} else if (command.type === "getPrompt" && command.name) {
const prompt = await mcpClient.getPrompt(command.name);
ws.send(JSON.stringify({ type: "prompt", data: prompt }));
} else if (command.type === "listTools") {
const tools = await mcpClient.listTools();
ws.send(JSON.stringify({ type: "tools", data: tools }));
} else if (
command.type === "callTool" &&
command.name &&
command.params
) {
const result = await mcpClient.callTool(
command.name + "asdf",
command.params,
);
ws.send(JSON.stringify({ type: "toolResult", data: result }));
}
} catch (error) {
console.error("Error:", error);