Skip to main content
Glama
server-test.jsโ€ข2.14 kB
#!/usr/bin/env node import { spawn } from 'child_process'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); console.log('๐Ÿงช Testing swagger-mcp server initialization...'); const serverProcess = spawn('node', [join(__dirname, '../src/server.js')], { stdio: ['pipe', 'pipe', 'pipe'] }); let testCompleted = false; // Force kill after 5 seconds regardless const forceTimeout = setTimeout(() => { if (!testCompleted) { console.log('โŒ Server initialization test timed out'); serverProcess.kill('SIGKILL'); process.exit(1); } }, 5000); // Simple test: if server starts and doesn't crash within 2 seconds, it's working const successTimeout = setTimeout(() => { if (!testCompleted) { console.log('โœ… Server started and remained stable for 2 seconds'); testCompleted = true; clearTimeout(forceTimeout); serverProcess.kill('SIGTERM'); setTimeout(() => { console.log('โœ… All tests passed - Server can be initialized properly'); process.exit(0); }, 100); } }, 2000); serverProcess.on('error', (error) => { console.error('โŒ Failed to start server:', error.message); clearTimeout(forceTimeout); clearTimeout(successTimeout); process.exit(1); }); serverProcess.on('exit', (code, signal) => { clearTimeout(forceTimeout); clearTimeout(successTimeout); if (testCompleted) { console.log('โœ… Server terminated gracefully after successful test'); process.exit(0); } else if (code !== 0 && signal !== 'SIGTERM') { console.error(`โŒ Server exited unexpectedly with code ${code}`); process.exit(1); } }); // Check for any error output serverProcess.stderr.on('data', (data) => { const output = data.toString(); // Only fail on actual errors, not warnings if (output.toLowerCase().includes('error:') || output.includes('throw ')) { console.error('โŒ Server error detected:', output); clearTimeout(forceTimeout); clearTimeout(successTimeout); serverProcess.kill('SIGTERM'); process.exit(1); } });

Latest Blog Posts

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/amrsa1/swagger-mcp'

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