UNPKG

azureai-optimizer

Version:

AI-Powered Azure Infrastructure Optimization via Model Context Protocol

64 lines 2.37 kB
/** * AzureAI Optimizer MCP Server * Main entry point for the Model Context Protocol server */ import { MCPServer } from './server/mcp-server.js'; import { AzureAuthProvider } from './auth/azure-auth.js'; import { ToolRegistry } from './tools/registry.js'; import { Logger } from './utils/logger.js'; import { Config } from './config/config.js'; const logger = new Logger('AzureAI-Optimizer'); async function main() { try { logger.info('🚀 Starting AzureAI Optimizer MCP Server...'); // Load configuration const config = Config.load(); logger.info(`📋 Configuration loaded for environment: ${config.environment}`); // Initialize Azure authentication logger.info('🔐 Initializing Azure authentication...'); const auth = new AzureAuthProvider(config.azure); await auth.initialize(); // Initialize tool registry logger.info('🛠️ Loading optimization tools...'); const tools = new ToolRegistry(config.tools); await tools.initialize(); // Create and start MCP server logger.info('🌐 Starting MCP server...'); const server = new MCPServer({ auth, tools, config: config.server }); await server.start(); logger.info('✅ AzureAI Optimizer is ready!'); logger.info('📊 Available tools:'); const availableTools = await tools.getToolNames(); availableTools.forEach(tool => { logger.info(` • ${tool}`); }); // Handle graceful shutdown process.on('SIGINT', async () => { logger.info('🛑 Received SIGINT, shutting down gracefully...'); await server.stop(); process.exit(0); }); process.on('SIGTERM', async () => { logger.info('🛑 Received SIGTERM, shutting down gracefully...'); await server.stop(); process.exit(0); }); } catch (error) { logger.error('❌ Failed to start AzureAI Optimizer:', error); process.exit(1); } } // Start the server if this file is run directly if (import.meta.url === `file://${process.argv[1]}`) { main().catch((error) => { console.error('Fatal error:', error); process.exit(1); }); } export { main }; //# sourceMappingURL=index.js.map