Get the FREE Ultimate OpenClaw Setup Guide →

mcp-websocket

This server implements an MCP (Model Context Protocol) server with WebSocket enhancements for real-time data updates.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio virajsharma2000-mcp-websocket python server.py

How to use

The MCP WebSocket Server combines a traditional MCP API over HTTP with a WebSocket-enabled stream for real-time updates. Clients can send standard MCP requests to the HTTP endpoint (for example, to / or an MCP route) and receive responses as usual. Separately, clients can connect to the WebSocket server to subscribe to live data updates. This allows applications to react instantly when new data becomes available without polling. The server listens on two ports: 8080 for MCP HTTP requests and 8765 for WebSocket subscriptions. To receive updates, a client should connect to ws://localhost:8765 and send a subscribe message. When new data arrives, the server broadcasts the update to all subscribed clients. This setup is ideal for dashboards, monitoring tools, or any application requiring timely MCP data synchronized across clients.

How to install

Prerequisites:

  • Python 3.8+ installed on your system
  • Access to install Python packages (pip)
  1. Clone the repository: git clone https://github.com/your-repo/mcp-websocket-server.git cd mcp-websocket-server

  2. Create and activate a virtual environment (optional but recommended): python -m venv env

    Windows

    .\env\Scripts\activate

    macOS/Linux

    source env/bin/activate

  3. Install dependencies: pip install websockets mcp-sdk # Replace with actual MCP SDK package name used by the project

  4. Run the server: python server.py

  5. Verify the server is running:

Additional notes

Notes and tips:

  • Ports: MCP HTTP API uses 8080; WebSocket updates use 8765. Adjustments may be required in a production environment behind a reverse proxy or load balancer.
  • If you encounter connection issues on WebSocket, ensure no firewall rules block port 8765 and that the client specifies the ws:// or wss:// scheme as appropriate.
  • The server relies on an MCP SDK for handling requests; ensure the SDK version in your environment matches the server code expectations.
  • For production deployments, consider enabling TLS for WebSocket (wss://) and implementing authentication for both HTTP and WebSocket endpoints.
  • Check logs for any exceptions related to async tasks or client subscriptions to diagnose subscription-related issues.

Related MCP Servers

Sponsor this space

Reach thousands of developers