Labsco
brysgo logo

WebRTC MCP Chat Server

from brysgo

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

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeNeeds API keys

WebRTC MCP Chat Server v2.0

A remote-first WebRTC chat server with secure temporary rooms and full MCP (Model Context Protocol) support, designed for background agents and real-time communication.

✨ New in v2.0: Remote & Secure

πŸ” Secure Temporary Rooms - Cryptographically secure, auto-expiring chat rooms
πŸš€ Remote Deployment Ready - Deploy to Railway, Vercel, Render, Heroku in minutes
πŸ€– Background Agent Support - Perfect for CI/CD, service coordination, and automation
πŸ›‘οΈ No Local Config Required - Zero-configuration MCP integration
⚑ CLI Tool Included - Command-line interface for agents and scripts

🎯 Perfect For

  • πŸ€– Background agent coordination
  • πŸ”„ CI/CD pipeline notifications
  • πŸ”— Service-to-service communication
  • ⚑ Temporary collaboration channels
  • πŸ” Secure inter-process messaging
  • πŸ“‘ Remote system monitoring

πŸ” Security Features

  • 256-bit cryptographic tokens for room access
  • 128-bit secure room IDs
  • Automatic expiration and cleanup (1 hour to 24 hours)
  • Server-side validation for all operations
  • No persistent storage - stateless design
  • Zero-configuration security
  • Tunnel-ready - Automatic ngrok header support (bypasses browser warnings)
  • URL normalization - Handles trailing slashes automatically
  • Comprehensive testing - Built-in tests for header functionality

πŸ› οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Web Users     β”‚    β”‚ MCP/Cursor Usersβ”‚    β”‚ Background      β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚ Agents/CLI      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ Video/Audio   β”‚    β”‚ β€’ Text Chat     β”‚    β”‚ β€’ API Calls     β”‚
β”‚ β€’ Screen Share  β”‚    β”‚ β€’ MCP Tools     β”‚    β”‚ β€’ CLI Commands  β”‚
β”‚ β€’ WebRTC P2P    β”‚    β”‚ β€’ Resources     β”‚    β”‚ β€’ HTTP/REST     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                      β”‚                      β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Chat Server    β”‚
                    β”‚  (Remote)       β”‚
                    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
                    β”‚ β€’ Socket.IO     β”‚
                    β”‚ β€’ HTTP/REST API β”‚
                    β”‚ β€’ WebRTC Signal β”‚
                    β”‚ β€’ Temp Rooms    β”‚
                    β”‚ β€’ Auto Cleanup  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‹ CLI Commands

The included CLI tool provides everything background agents need:

# Create secure temporary room
chat-room create --expires 120 --created-by agent-1

# Join room with credentials  
chat-room join <roomId> <token> <username>

# Send secure messages
chat-room send <roomId> <token> <username> "Hello world"

# Get room information
chat-room info <roomId> <token>

# Check server health
chat-room health

# Interactive mode for agents
chat-room interactive

πŸ”§ MCP Tools Available

ToolDescriptionUse Case
create_temp_chatCreate secure temporary roomAgent coordination
join_temp_chatJoin temporary room with tokenSecure communication
send_temp_messageSend message to secure roomReal-time messaging
get_temp_room_infoGet room status and usersMonitoring
check_server_statusVerify server healthHealth checking
join_public_chatJoin permanent public roomLong-term collaboration
send_public_messageSend to public roomGeneral communication

πŸš€ Background Agent Examples

Simple Agent Communication

# Agent 1: Create room
ROOM_INFO=$(chat-room create --expires 60 --output json)
ROOM_ID=$(echo $ROOM_INFO | jq -r '.roomId')
ROOM_TOKEN=$(echo $ROOM_INFO | jq -r '.roomToken')

# Agent 2: Join and communicate  
chat-room join $ROOM_ID $ROOM_TOKEN agent-2
chat-room send $ROOM_ID $ROOM_TOKEN agent-2 "Task complete"

CI/CD Integration

#!/bin/bash
# In your pipeline
ROOM_INFO=$(chat-room create --expires 30 --created-by ci-pipeline --output json)
echo "Deployment room: $(echo $ROOM_INFO | jq -r '.joinUrl')"

chat-room send $(echo $ROOM_INFO | jq -r '.roomId') \
              $(echo $ROOM_INFO | jq -r '.roomToken') \
              ci-bot "Deployment started for ${COMMIT_SHA}"

Service-to-Service

// Node.js service
const response = await fetch(`${CHAT_SERVER}/api/create-temp-room`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ expiresInMinutes: 30, createdBy: 'service-a' })
});
const { roomId, roomToken } = await response.json();
// Share credentials with other services

πŸ“Š Performance

  • Room Creation: ~10ms
  • Message Delivery: ~5ms
  • Health Checks: ~2ms
  • Memory per Room: ~1KB
  • Concurrent Users: 1000+ per instance

πŸ”„ Auto-Scaling

  • Stateless Design - No database required
  • Memory-Only Storage - Fast and efficient
  • Auto-Cleanup - Expired rooms automatically removed
  • Load Balancer Ready - Health check endpoint included
  • Multi-Instance - Use sticky sessions for WebSockets

🚨 Monitoring

Health Check Endpoint

curl https://your-app.com/health

Response

{
  "status": "healthy",
  "serverUrl": "https://your-app.com", 
  "remoteMode": true,
  "activeRooms": 5,
  "temporaryRooms": 3,
  "connectedUsers": 12
}

πŸ“š Documentation

  • REMOTE_DEPLOYMENT.md - Complete deployment guide
  • LOCAL_REVERSE_PROXY.md - Local server with reverse proxy tunnels
  • CURSOR_SETUP.md - Cursor IDE integration
  • Web Interface - Built-in at server root URL
  • Health Endpoint - /health for monitoring
  • API Documentation - Available via MCP resources

πŸ›‘οΈ Security Best Practices

  1. Use HTTPS in production deployments
  2. Rotate tokens for long-running agents
  3. Monitor health endpoints regularly
  4. Set appropriate expiration times for rooms
  5. Use environment variables for server URLs
  6. Implement rate limiting if needed

🀝 Contributing

We welcome contributions! Areas of interest:

  • Additional deployment platforms
  • Enhanced security features
  • Performance optimizations
  • More CLI commands
  • Integration examples

πŸ“„ License

MIT License - see LICENSE file for details.


Ready to deploy secure, temporary chat rooms for your background agents?

Start with: railway up or vercel --prod

Then: chat-room create --expires 60 --created-by my-agent

πŸš€ Your agents can now communicate securely!