UNPKG

webrtc-mcp-chat

Version:

A remote WebRTC chat server with secure temporary rooms and MCP support for background agents

61 lines (51 loc) • 1.53 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('šŸš€ Starting WebRTC MCP Chat Server...\n'); // Start the main chat server console.log('šŸ“” Starting main chat server...'); const chatServer = spawn('node', ['server.js'], { cwd: __dirname, stdio: 'inherit' }); // Start the MCP server console.log('šŸ”§ Starting MCP server...'); const mcpServer = spawn('node', ['mcp-server.js'], { cwd: __dirname, stdio: 'inherit' }); // Handle graceful shutdown process.on('SIGINT', () => { console.log('\nšŸ›‘ Shutting down servers...'); chatServer.kill('SIGINT'); mcpServer.kill('SIGINT'); process.exit(0); }); process.on('SIGTERM', () => { console.log('\nšŸ›‘ Shutting down servers...'); chatServer.kill('SIGTERM'); mcpServer.kill('SIGTERM'); process.exit(0); }); // Handle server exits chatServer.on('exit', (code) => { console.log(`Chat server exited with code ${code}`); if (code !== 0) { mcpServer.kill(); process.exit(1); } }); mcpServer.on('exit', (code) => { console.log(`MCP server exited with code ${code}`); if (code !== 0) { chatServer.kill(); process.exit(1); } }); console.log('\nāœ… Both servers started successfully!'); console.log('🌐 Web interface: http://localhost:3000'); console.log('šŸ”§ MCP server: Running on stdio'); console.log('\nPress Ctrl+C to stop both servers');