Skip to main content
Glama
startup.js•1.92 kB
#!/usr/bin/env node /** * Startup Script * Downloads database and starts MCP server */ import { downloadDatabase, checkDatabaseHealth } from './download-database.js'; import { spawn } from 'child_process'; import path from 'path'; import { fileURLToPath } from 'url'; import { dirname } from 'path'; // Get __dirname equivalent in ES modules const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); async function startup() { console.log('šŸš€ Starting EGW Research Server...'); // Download database if needed const downloadSuccess = await downloadDatabase(); if (!downloadSuccess) { console.error('āŒ Failed to download database, server cannot start'); process.exit(1); } // Verify database health const dbHealthy = checkDatabaseHealth(); if (!dbHealthy) { console.error('āŒ Database health check failed, server cannot start'); process.exit(1); } console.log('āœ… Database ready, starting MCP server...'); // Start MCP server const serverPath = path.join(__dirname, 'server-universal.js'); const serverProcess = spawn('node', [serverPath], { stdio: 'inherit', env: { ...process.env, NODE_ENV: 'production' } }); serverProcess.on('error', (error) => { console.error('āŒ Failed to start server:', error); process.exit(1); }); serverProcess.on('exit', (code) => { console.log(`šŸ“ Server exited with code ${code}`); process.exit(code); }); // Handle graceful shutdown process.on('SIGTERM', () => { console.log('šŸ“ Received SIGTERM, shutting down gracefully...'); serverProcess.kill('SIGTERM'); }); process.on('SIGINT', () => { console.log('šŸ“ Received SIGINT, shutting down gracefully...'); serverProcess.kill('SIGINT'); }); } // Start application startup().catch(error => { console.error('āŒ Startup failed:', error); process.exit(1); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pythondev-pro/egw_writings_mcp_server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server