auto-publishing-mcp-server
Version:
Enterprise-grade MCP Server for Auto-Publishing with pre-publish validation, multi-cloud deployment, and monitoring
86 lines (70 loc) • 2.5 kB
JavaScript
/**
* Auto-Publishing MCP Server Entry Point
* Main executable for the MCP server with monitoring integration
*/
import { AutoPublishingMcpServer } from './server.js';
// Configuration from environment variables
const config = {
// Port configuration
httpPort: parseInt(process.env.MCP_HTTP_PORT || '13000'),
wsPort: parseInt(process.env.MCP_WS_PORT || '13001'),
host: process.env.MCP_HOST || '192.168.101.1',
// Server behavior
enableMetrics: process.env.MCP_ENABLE_METRICS !== 'false',
logLevel: process.env.MCP_LOG_LEVEL || 'info',
// Auto-publishing specific
autoRegisterTools: process.env.MCP_AUTO_REGISTER_TOOLS !== 'false',
// Environment detection
environment: process.env.NODE_ENV || 'production'
};
// Create and start server
const server = new AutoPublishingMcpServer(config);
async function startServer() {
try {
console.log('🚀 Starting Auto-Publishing MCP Server...');
console.log(`📊 Metrics enabled: ${config.enableMetrics}`);
console.log(`🌐 Environment: ${config.environment}`);
console.log(`📡 HTTP Port: ${config.httpPort}`);
console.log(`🔌 WebSocket Port: ${config.wsPort}`);
await server.start();
console.log('✅ Server started successfully!');
console.log(`📊 Metrics endpoint: http://${config.host}:${config.httpPort}/metrics`);
console.log(`🏥 Health endpoint: http://${config.host}:${config.httpPort}/health`);
} catch (error) {
console.error('❌ Failed to start server:', error);
process.exit(1);
}
}
// Handle process signals for graceful shutdown
process.on('SIGTERM', async () => {
console.log('🛑 Received SIGTERM, shutting down gracefully...');
try {
await server.stop();
process.exit(0);
} catch (error) {
console.error('Error during graceful shutdown:', error);
process.exit(1);
}
});
process.on('SIGINT', async () => {
console.log('🛑 Received SIGINT, shutting down gracefully...');
try {
await server.stop();
process.exit(0);
} catch (error) {
console.error('Error during graceful shutdown:', error);
process.exit(1);
}
});
// Handle uncaught exceptions
process.on('uncaughtException', (error) => {
console.error('❌ Uncaught Exception:', error);
process.exit(1);
});
process.on('unhandledRejection', (reason, promise) => {
console.error('❌ Unhandled Rejection at:', promise, 'reason:', reason);
process.exit(1);
});
// Start the server
startServer();