UNPKG

systemprompt-mcp-interview

Version:

A specialized Model Context Protocol (MCP) server that enables AI-powered interview roleplay scenarios

56 lines 2.03 kB
import { PROMPTS } from "../constants/sampling-prompts.js"; import { injectVariablesIntoText } from "../utils/message-handlers.js"; export async function handleListPrompts(request) { try { if (!PROMPTS || !Array.isArray(PROMPTS)) { throw new Error("Failed to fetch prompts"); } return { prompts: PROMPTS.map(({ messages, ...rest }) => rest), }; } catch (error) { console.error("Failed to fetch prompts:", error); throw error; } } export async function handleGetPrompt(request) { try { if (!PROMPTS || !Array.isArray(PROMPTS)) { throw new Error("Failed to fetch prompts"); } const foundPrompt = PROMPTS.find((p) => p.name === request.params.name); if (!foundPrompt) { throw new Error(`Prompt not found: ${request.params.name}`); } if (!foundPrompt.messages || !Array.isArray(foundPrompt.messages) || foundPrompt.messages.length === 0) { throw new Error(`Messages not found for prompt: ${request.params.name}`); } const injectedMessages = foundPrompt.messages.map((message) => { if (message.role === "user" && message.content.type === "text" && request.params.arguments) { return { role: message.role, content: { type: "text", text: injectVariablesIntoText(message.content.text, request.params.arguments), }, }; } return message; }); return { name: foundPrompt.name, description: foundPrompt.description, arguments: foundPrompt.arguments || [], messages: injectedMessages, _meta: foundPrompt._meta, }; } catch (error) { console.error("Failed to fetch prompt:", error); throw error; } } //# sourceMappingURL=prompt-handlers.js.map