Elffuss BraidHub

kikocis/continue public

main · 931 BRawPermalink
1import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
3import { SlashCommandWithSource } from "../../index.js";
4
5export function constructMcpSlashCommand(
6 client: Client,
7 name: string,
8 description?: string,
9 args?: string[],
10): SlashCommandWithSource {
11 return {
12 name,
13 description: description ?? "MCP Prompt",
14 source: "mcp-prompt",
15 params: {},
16 };
17}
18
19export function stringifyMcpPrompt(
20 prompt: Awaited<ReturnType<typeof Client.prototype.getPrompt>>,
21): string {
22 const { messages } = prompt;
23 let stringified = "";
24 for (const message of messages) {
25 if (message.content.type === "text") {
26 stringified += `<${message.content.role}/>\n${message.content.text}\n<${message.content.role}/>`;
27 } else {
28 console.warn(
29 `MCP Prompt conversion warning: ${message.content.type} content is not yet supported, message skipped`,
30 );
31 }
32 }
33 return stringified;
34}