UNPKG

il2cpp-dump-analyzer-mcp

Version:

Agentic RAG system for analyzing IL2CPP dump.cs files from Unity games

113 lines โ€ข 5.29 kB
#!/usr/bin/env node "use strict"; /** * Network MCP Server for IL2CPP Dump Analyzer * Starts the MCP server with HTTP/WebSocket transport for remote access */ Object.defineProperty(exports, "__esModule", { value: true }); const mcp_sdk_server_1 = require("./mcp/mcp-sdk-server"); const cli_config_1 = require("./config/cli-config"); const transport_1 = require("./transport"); async function main() { try { console.log('๐Ÿš€ Starting IL2CPP MCP Server with Network Transport...\n'); // Parse command-line arguments const cliConfig = (0, cli_config_1.parseStdioArgs)(); // Load transport configuration from environment const transportConfig = (0, transport_1.loadTransportConfig)(); // Override with HTTP transport if not specified if (transportConfig.type === transport_1.TransportType.STDIO) { transportConfig.type = transport_1.TransportType.SSE; // Use SSE for better compatibility transportConfig.host = transportConfig.host || '0.0.0.0'; // Listen on all interfaces transportConfig.port = transportConfig.port || 3000; transportConfig.enableCors = transportConfig.enableCors ?? true; transportConfig.enableLogging = transportConfig.enableLogging ?? true; // Enable logging for debugging } // Validate transport configuration const validation = (0, transport_1.validateTransportConfig)(transportConfig); if (!validation.valid) { console.error('โŒ Invalid transport configuration:'); validation.errors.forEach(error => console.error(` - ${error}`)); process.exit(1); } // Print configuration summary (0, transport_1.printTransportConfigSummary)(transportConfig); // Start the MCP server with network transport await (0, mcp_sdk_server_1.startMcpServer)({ dumpFilePath: cliConfig.dumpFile, model: cliConfig.model, environment: 'production', logLevel: cliConfig.logLevel, hashFilePath: cliConfig.hashFile, forceReprocess: cliConfig.forceReprocess, transportConfig, progressCallback: (progress, message) => { console.log(`[${progress}%] ${message}`); } }); // Log success message const protocol = transportConfig.enableSsl ? 'https' : 'http'; const url = `${protocol}://${transportConfig.host}:${transportConfig.port}`; console.log('\nโœ… IL2CPP MCP Server started successfully!'); console.log(`๐ŸŒ Server URL: ${url}`); console.log(`๐Ÿ”ง Transport: ${transportConfig.type}`); if (transportConfig.apiKey) { console.log('๐Ÿ” Authentication: API key required'); console.log(' Add header: X-API-Key: your_api_key'); } else { console.log('โš ๏ธ Authentication: Open access (no API key)'); } console.log('\n๐Ÿ“ก MCP Endpoints:'); console.log(` GET ${url}/ - SSE stream for MCP communication`); console.log(` POST ${url}/ - Send MCP messages`); console.log(` DELETE ${url}/ - Terminate session`); console.log('\n๐Ÿงช Test with curl:'); const authHeader = transportConfig.apiKey ? ` -H "X-API-Key: ${transportConfig.apiKey}"` : ''; console.log(` curl -X POST ${url}${authHeader} \\`); console.log(` -H "Content-Type: application/json" \\`); console.log(` -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'`); console.log('\n๐Ÿ”— MCP Client Configuration (Claude Desktop):'); console.log(' {'); console.log(' "mcpServers": {'); console.log(' "il2cpp-analyzer-remote": {'); console.log(` "url": "${url}",`); console.log(' "description": "Remote IL2CPP Dump Analyzer"'); if (transportConfig.apiKey) { console.log(' "headers": {'); console.log(` "X-API-Key": "${transportConfig.apiKey}"`); console.log(' }'); } console.log(' }'); console.log(' }'); console.log(' }'); console.log('\nโน๏ธ Press Ctrl+C to stop the server'); // Handle graceful shutdown process.on('SIGINT', async () => { console.log('\n๐Ÿ›‘ Shutting down server...'); process.exit(0); }); process.on('SIGTERM', async () => { console.log('\n๐Ÿ›‘ Shutting down server...'); process.exit(0); }); // Keep the process alive with a simple interval const keepAliveInterval = setInterval(() => { // This keeps the Node.js event loop active }, 30000); // Every 30 seconds // Clean up on shutdown const cleanup = () => { clearInterval(keepAliveInterval); process.exit(0); }; process.on('SIGINT', cleanup); process.on('SIGTERM', cleanup); } catch (error) { console.error('โŒ Failed to start network MCP server:', error); process.exit(1); } } // Start the server main(); //# sourceMappingURL=network-server.js.map