- Home
- MCP servers
- MCP Websocket Server
MCP Websocket Server
- python
28
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
You run an MCP server that exposes data access over HTTP while also pushing real-time updates to clients via WebSocket. This combination lets clients fetch data on demand and subscribe to live changes as soon as new information becomes available, all handled efficiently with asynchronous I/O.
How to use
Connect your MCP client to the HTTP endpoint to perform standard requests and retrieve data as needed. Open a WebSocket connection to receive real-time push notifications whenever new data becomes available, and use the subscribe action to start receiving updates.
Key endpoints you will interact with are the HTTP MCP server on port 8080 for standard requests and the WebSocket MCP endpoint on port 8765 for live updates. Start by subscribing over WebSocket, then issue MCP requests over HTTP as your application needs.
To ensure you receive timely updates, keep the WebSocket connection alive and handle incoming messages as event-driven data. The architecture is asynchronous, which helps maintain responsiveness even as updates arrive rapidly.
# Start the servers (in a single terminal)
python server.py
# WebSocket endpoint for subscriptions
ws://localhost:8765
# MCP HTTP endpoint for data requests
http://localhost:8080
How to install
Prerequisites you need on your machine: Python 3.8+ and a modern package manager. You will install the required Python dependencies and then start the server.
Step 1: Install Python 3.8 or newer on your system. If you need to upgrade, use your operating system’s package manager or download from the official Python website.
Step 2: Create a project directory and install dependencies.
# Create project directory (optional)
mkdir mcp-websocket-server
cd mcp-websocket-server
# Install dependencies
pip install websockets mcp-sdk
Step 3: Start the servers.
python server.py
Configuration and usage notes
The server runs two endpoints: an MCP HTTP interface on port 8080 for standard requests, and a WebSocket interface on port 8765 for real-time subscriptions. Clients can subscribe to updates and receive push notifications whenever new data becomes available.
If you need to verify connectivity, you can check that the HTTP endpoint responds to MCP requests and that the WebSocket endpoint accepts subscription messages. Typical client behavior includes subscribing to updates and then making data requests as needed.
Available tools
subscribe
Connect to the WebSocket endpoint and subscribe to real-time updates so you receive push notifications when new data becomes available.
get_data
Send MCP requests to the HTTP server to retrieve data or perform actions supported by the MCP API.
push_notifications
Automatic delivery of updates to all subscribed clients whenever new data becomes available.