mcp-casual-interview
Version:
MCP server for casual interview preparation workflow management
38 lines • 1.45 kB
JavaScript
import { PROMPT_TEMPLATES, substituteVariables, formatPromptResult, errorMessages } from './prompts.js';
import { toStructuredCallToolResult } from '../util.js';
/**
* Handler for prompts tool
* Retrieves prompts by name and supports variable substitution
*/
export const promptsHandler = async (params) => {
try {
// Get the prompt template
const template = PROMPT_TEMPLATES[params.name];
if (!template) {
return toStructuredCallToolResult([errorMessages.promptNotFound(params.name)], {
name: params.name,
content: '',
variables_used: []
}, true);
}
// Substitute variables
const { content, variablesUsed } = substituteVariables(template, params.variables);
// Format human-readable response
const message = formatPromptResult(params.name, content, variablesUsed);
// Return structured result
return toStructuredCallToolResult([message], {
name: params.name,
content,
variables_used: variablesUsed
}, false);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
return toStructuredCallToolResult([errorMessages.unexpectedError(message)], {
name: params.name,
content: '',
variables_used: []
}, true);
}
};
//# sourceMappingURL=handler.js.map