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
JavaScript
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');