πŸ“‘ MCP Signaling Server (Django + Channels + ASGI)

by yer-retb

191 downloads
Not rated
GitHub

Description

# πŸ“‘ MCP Signaling Server (Django + Channels + ASGI) This is an asynchronous backend WebSocket signaling server built with Django and Channels, implementing a custom protocol called MCP (Message Context Protocol). It allows React frontend clients to exchange WebRTC signaling…

About

# πŸ“‘ MCP Signaling Server (Django + Channels + ASGI) This is an asynchronous backend WebSocket signaling server built with Django and Channels, implementing a custom protocol called MCP (Message Context Protocol). It allows React frontend clients to exchange WebRTC signaling messages in real-time without using REST…

Details

Author
yer-retb
Downloads
191
Categories
Developer Tools

- ASGI-compliant Django server with real-time WebSocket support
- Custom signaling protocol: MCP (Message Context Protocol)
- Room-based signaling (multi-user capable)
- Supports offer, answer, candidate, and leave messages
- Works with any frontend WebRTC client (React, etc.)
- Includes test script for two-client simulation

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name πŸ“‘ MCP Signaling Server (Django + Channels + ASGI)
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Clone the repository, create a Python virtual environment, install dependencies from requirements.txt, then run the server using daphne mcp_server.asgi:application. Connect via WebSocket at ws://127.0.0.1:8000/ws/signal/?room=ROOM_NAME. A test script (test_mcp.py) is provided to simulate two clients.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "\ud83d\udce1 mcp signaling server (django + channels + asgi)": {
            "Asynchronous-MCP-Server-with-WebRTC-Signaling": {
                "command": "python3",
                "args": [
                    "-m",
                    "venv",
                    "venv"
                ]
            }
        }
    }
}

McpServers

{
    "Asynchronous-MCP-Server-with-WebRTC-Signaling": {
        "command": "python3",
        "args": [
            "-m",
            "venv",
            "venv"
        ]
    }
}

πŸ“‘ MCP Signaling Server (Django + Channels + ASGI)

This is an asynchronous backend WebSocket signaling server built with Django and Channels, implementing a custom protocol called MCP (Message Context Protocol). It allows React frontend clients to exchange WebRTC signaling messages in real-time without using REST APIs.

---

πŸš€ Features

ASGI-compliant Django server with real-time WebSocket support
Custom signaling protocol: MCP (Message Context Protocol)
Room-based signaling (multi-user capable)
Supports offer, answer, candidate, and leave messages
Works with any frontend WebRTC client (React, etc.)
Includes test script for two-clients simulation

---

🧱 Project Structure

backend/
β”œβ”€β”€ mcp_server/             # Django project
β”‚   β”œβ”€β”€ settings.py         # ASGI + Channels config
β”‚   └── asgi.py             # ASGI application
β”œβ”€β”€ signaling/              # Signaling app
β”‚   β”œβ”€β”€ consumers.py        # SignalConsumer logic
β”‚   └── routing.py          # WebSocket routing rules
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ manage.py               # Django CLI tool
β”œβ”€β”€ test_mcp.py             # Python script to test with 2 clients
└── venv/                   # Virtual environment (not included in repo)

---

βš™οΈ Installation & Setup

1. Clone the repo and enter backend folder:

   git clone https://github.com/yer-retb/Asynchronous-MCP-Server-with-WebRTC-Signaling.git mcp-signaling-server
   cd mcp-signaling-server/backend
   

2. Create and activate virtual environment:

   python3 -m venv venv
   source venv/bin/activate
   

3. Install dependencies:

   pip install -r requirements.txt
   

4. Apply migrations (optional if using Django admin):

   python manage.py migrate
   

5. Run the server using Daphne:

   daphne mcp_server.asgi:application
   

Server will be available at:

http://127.0.0.1:8000
WebSocket endpoint: ws://127.0.0.1:8000/ws/signal/?room=ROOM_NAME

---

πŸ” MCP Protocol (Message Context Protocol)

Supported Message Types

| Type | Purpose |
| ----------- | ---------------------------- |
| offer | Initial connection offer |
| answer | Response to the offer |
| candidate | ICE candidate for connection |
| leave | User leaves the session |

Example Message Formats

// Offer
{ "type": "offer", "sdp": "..." }

// Answer
{ "type": "answer", "sdp": "..." }

// ICE Candidate
{ "type": "candidate", "candidate": "..." }

// Leave
{ "type": "leave" }

Clients send these messages through the WebSocket. The server forwards each message to all other peers in the same room.

---

πŸ§ͺ Testing the Backend

Use the included script to test with 2 simulated clients:

python test_mcp.py

Expected output:

[Client1] Connected
[Client1] Sent offer
[Client2] Connected
[Client2] Received: {"type": "offer", "sdp": "fake-sdp-from-Client1"}

---

πŸ’‘ Technical Decisions

Django Channels: Built-in WebSocket support that works seamlessly with ASGI
Daphne: Production-ready ASGI server compatible with Channels
In-memory rooms: Kept simple using Python dictionaries for development
Room-based signaling: Easier to scale, test, and organize peer communication

---

No reviews yet β€” be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.