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.

66 lines (65 loc) 2.5 kB
import { readFileSync } from "fs"; import path from "path"; import { fileURLToPath } from "url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const toolConfig = JSON.parse(readFileSync(path.join(__dirname, "..", "..", "..", "mcp-config.json"), "utf-8")); export function matchRequest(request) { const lowercaseRequest = request.toLowerCase(); let bestMatch = null; for (const [toolName, toolData] of Object.entries(toolConfig.tools)) { for (const pattern of toolData.input_patterns) { const regexPattern = pattern .replace(/\{([^}]+)\}/g, "([\\w\\s-]+)") .toLowerCase(); const regex = new RegExp(`^${regexPattern}$`, "i"); const match = lowercaseRequest.match(regex); if (match) { return { toolName, confidence: 0.9, matchedPattern: pattern }; } } for (const useCase of toolData.use_cases) { if (lowercaseRequest.includes(useCase.toLowerCase())) { const confidence = 0.7; if (!bestMatch || confidence > bestMatch.confidence) { bestMatch = { toolName, confidence, matchedPattern: useCase }; } } } if (toolData.description && lowercaseRequest.split(" ").some(word => toolData.description.toLowerCase().includes(word) && word.length > 3)) { const confidence = 0.5; if (!bestMatch || confidence > bestMatch.confidence) { bestMatch = { toolName, confidence, matchedPattern: "description_match" }; } } } return bestMatch; } export function extractParameters(request, matchedPattern) { const params = {}; const placeholders = matchedPattern.match(/\{([^}]+)\}/g); if (!placeholders) return params; const regexStr = matchedPattern.replace(/\{([^}]+)\}/g, "([\\w\\s-]+)"); const regex = new RegExp(regexStr, "i"); const match = request.match(regex); if (!match) return params; for (let i = 0; i < placeholders.length; i++) { const paramName = placeholders[i].slice(1, -1); params[paramName] = match[i + 1]; } return params; }