systemprompt-mcp-interview
Version:
A specialized Model Context Protocol (MCP) server that enables AI-powered interview roleplay scenarios
27 lines • 927 B
JavaScript
import { TOOLS } from "../constants/tools.js";
import { validateWithErrors } from "./validation.js";
/**
* Validates a tool request and returns the tool configuration if valid
*/
export function validateToolRequest(request) {
if (!request.params?.name) {
throw new Error("Invalid tool request: missing tool name");
}
const tool = TOOLS.find((t) => t.name === request.params.name);
if (!tool) {
throw new Error(`Unknown tool: ${request.params.name}`);
}
// Validate arguments against the tool's schema if present
if (tool.inputSchema && request.params.arguments) {
validateWithErrors(request.params.arguments, tool.inputSchema);
}
return tool;
}
/**
* Gets the schema for a tool by name
*/
export function getToolSchema(toolName) {
const tool = TOOLS.find((t) => t.name === toolName);
return tool?.inputSchema;
}
//# sourceMappingURL=tool-validation.js.map