UNPKG

vibe-coder-mcp

Version:

Production-ready MCP server with complete agent integration, multi-transport support, and comprehensive development automation tools for AI-assisted workflows.

59 lines (58 loc) 2.77 kB
import { z } from 'zod'; import { hybridMatch, getMatchExplanation } from "../hybrid-matcher/index.js"; import logger from '../../logger.js'; import { registerTool, executeTool } from '../routing/toolRegistry.js'; const processRequestInputSchemaShape = { request: z.string().min(3, { message: "Request must be at least 3 characters." }).describe("Natural language request to process and route to the appropriate tool") }; export const processUserRequest = async (params, config, context) => { const request = params.request; let matchResult; try { logger.info(`Processing request: "${request.substring(0, 50)}..."`); matchResult = await hybridMatch(request, config); if (matchResult.requiresConfirmation) { logger.info(`Tool execution requires confirmation: ${matchResult.toolName}`); const explanation = getMatchExplanation(matchResult); return { content: [{ type: "text", text: `I plan to use the '${matchResult.toolName}' tool for your request.\nExplanation: ${explanation}\nConfidence: ${Math.round(matchResult.confidence * 100)}%\n\nDo you want to proceed?` }], isError: false }; } logger.info(`Executing tool '${matchResult.toolName}' directly based on processed request (Confidence: ${matchResult.confidence.toFixed(3)}).`); const toolResult = await executeTool(matchResult.toolName, matchResult.parameters, config, context); const explanation = getMatchExplanation(matchResult); return { content: [ { type: "text", text: `Using ${matchResult.toolName}:\n${explanation}\n\n---\n\n` }, ...(toolResult.content || [{ type: 'text', text: '(Tool executed successfully but returned no content)' }]) ], isError: toolResult.isError ?? false }; } catch (error) { logger.error({ err: error, request }, "Error processing user request"); return { content: [ { type: "text", text: `Error processing request: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }; const processRequestToolDefinition = { name: "process-request", description: "Processes natural language requests, determines the best tool using semantic matching and fallbacks, and either asks for confirmation or executes the tool directly.", inputSchema: processRequestInputSchemaShape, executor: processUserRequest }; registerTool(processRequestToolDefinition);