make prompts pass args

This commit is contained in:
Ashwin Bhat
2024-10-08 14:54:56 -07:00
parent 0c66e16dda
commit 88df0cd453
4 changed files with 65 additions and 23 deletions

View File

@@ -80,16 +80,18 @@ export class McpClient {
);
}
async getPrompt(name: string): Promise<GetPromptResult> {
async getPrompt(
name: string,
args?: Record<string, string>,
): Promise<GetPromptResult> {
return await this.client.request(
{
method: "prompts/get",
params: { name },
params: { name, arguments: args },
},
GetPromptResultSchema,
);
}
// Tool Operations
async listTools(): Promise<ListToolsResult> {
return await this.client.request(

View File

@@ -35,7 +35,7 @@ wss.on("connection", (ws: WebSocket) => {
const prompts = await mcpClient.listPrompts();
ws.send(JSON.stringify({ type: "prompts", data: prompts }));
} else if (command.type === "getPrompt" && command.name) {
const prompt = await mcpClient.getPrompt(command.name);
const prompt = await mcpClient.getPrompt(command.name, command.args);
ws.send(JSON.stringify({ type: "prompt", data: prompt }));
} else if (command.type === "listTools") {
const tools = await mcpClient.listTools();