Skip to main content
Glama

SystemPrompt Coding Agent

Official
tunnel-status.tsโ€ข3.71 kB
#!/usr/bin/env node /** * @file Check tunnel status * @module scripts/tunnel-status */ import * as fs from 'fs'; import * as path from 'path'; import { fileURLToPath } from 'url'; import { execSync } from 'child_process'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const projectRoot = path.join(__dirname, '..'); const colors = { reset: '\x1b[0m', red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m', cyan: '\x1b[36m' }; function log(message: string, color: string = colors.reset): void { console.log(`${color}${message}${colors.reset}`); } function checkTunnelStatus(): void { console.log('๐Ÿ” Tunnel Status Check\n'); // Check for tunnel URL in environment or daemon logs let url: string | null = null; const daemonTunnelFile = path.join(projectRoot, 'daemon', 'logs', 'tunnel-url.txt'); // Check environment first if (process.env.TUNNEL_URL) { url = process.env.TUNNEL_URL; } else if (fs.existsSync(daemonTunnelFile)) { url = fs.readFileSync(daemonTunnelFile, 'utf8').trim(); } if (url) { // Check if cloudflared process is running let processRunning = false; try { execSync('pgrep cloudflared', { stdio: 'ignore' }); processRunning = true; } catch { processRunning = false; } if (processRunning) { log('โœ… Tunnel is ACTIVE', colors.green); log(`๐ŸŒ Public URL: ${colors.cyan}${url}${colors.reset}`); log(`๐Ÿ“ก MCP Endpoint: ${colors.cyan}${url}/mcp${colors.reset}`); console.log('\nTo use this tunnel:'); console.log(` 1. In tests: ${colors.yellow}MCP_BASE_URL="${url}" npm test${colors.reset}`); console.log(` 2. Auto-detect: ${colors.yellow}cd e2e-test && npm run test:tunnel${colors.reset}`); console.log(` 3. From root: ${colors.yellow}npm run test:tunnel${colors.reset}`); // Test connectivity console.log('\n๐Ÿ”— Testing connectivity...'); fetch(`${url}/health`) .then(res => { if (res.ok) { log('โœ… Tunnel is accessible and working!', colors.green); } else { log(`โš ๏ธ Tunnel returned status ${res.status}`, colors.yellow); } }) .catch(err => { log('โŒ Cannot connect to tunnel', colors.red); console.log(` Error: ${err.message}`); }); } else { log('โš ๏ธ Tunnel URL found but cloudflared is not running', colors.yellow); log(` Stale URL: ${url}`, colors.yellow); console.log('\nCleaning up stale tunnel file...'); if (fs.existsSync(daemonTunnelFile)) { fs.unlinkSync(daemonTunnelFile); } log('โœ… Cleaned up', colors.green); } } else { log('โŒ No tunnel is currently running', colors.red); console.log('\nTo start a tunnel:'); console.log(` 1. Manual: ${colors.yellow}npm run tunnel${colors.reset}`); console.log(` 2. With test: ${colors.yellow}npm run test:tunnel${colors.reset}`); console.log(` 3. Just tunnel: ${colors.yellow}cloudflared tunnel --url http://localhost:3000${colors.reset}`); } // Check if server is running console.log('\n๐Ÿ” Server Status:'); fetch('http://localhost:3000/health') .then(res => { if (res.ok) { log('โœ… MCP server is running on port 3000', colors.green); } else { log(`โš ๏ธ Server returned status ${res.status}`, colors.yellow); } }) .catch(() => { log('โŒ MCP server is not running', colors.red); console.log(` Start it with: ${colors.yellow}npm start${colors.reset}`); }); } // Run the check checkTunnelStatus();

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/systempromptio/systemprompt-code-orchestrator'

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