UNPKG

@runreal/unreal-mcp

Version:

MCP server for Unreal Engine using Unreal Python Remote Execution

56 lines (53 loc) 2.47 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const node_fs_1 = __importDefault(require("node:fs")); const node_path_1 = __importDefault(require("node:path")); function extractToolsFromIndexFile() { const indexPath = node_path_1.default.join(__dirname, "../index.js"); const content = node_fs_1.default.readFileSync(indexPath, "utf-8"); const toolRegex = /server\.tool\(\s*["']([^"']+)["'],\s*["']([^"']+)["']/g; const matches = Array.from(content.matchAll(toolRegex)); return matches.reduce((tools, match) => { const fullDescription = match[2]; const shortDescription = fullDescription.split(". ")[0].split("\\n")[0].split("\n")[0]; tools.push({ name: match[1], description: shortDescription, }); return tools; }, []); } function generateToolsTable(tools) { const header = "| Tool | Description |\n|------|-------------|\n"; const rows = tools.map((tool) => `| \`${tool.name}\` | ${tool.description} |`).join("\n"); return header + rows; } function updateReadmeWithTools() { const readmePath = node_path_1.default.join(__dirname, "../../README.md"); const readmeContent = node_fs_1.default.readFileSync(readmePath, "utf-8"); const tools = extractToolsFromIndexFile(); const toolsTable = generateToolsTable(tools); const toolsSection = `## Available Tools ${toolsTable} `; const toolsSectionRegex = /## Available Tools[\s\S]*?(?=##|$)/; const updatedContent = toolsSectionRegex.test(readmeContent) ? readmeContent.replace(toolsSectionRegex, toolsSection) : insertToolsSection(readmeContent, toolsSection); node_fs_1.default.writeFileSync(readmePath, updatedContent); console.log(`Updated README.md with ${tools.length} tools`); } function insertToolsSection(content, toolsSection) { const insertPoints = [ { marker: "## Contributing", found: content.indexOf("## Contributing") }, { marker: "### License MIT", found: content.indexOf("### License MIT") }, ]; const insertPoint = insertPoints.find((point) => point.found !== -1); return insertPoint ? content.slice(0, insertPoint.found) + toolsSection + content.slice(insertPoint.found) : content + "\n" + toolsSection; } updateReadmeWithTools();