WebSocket Bot
The WebSocket Bot is an external example bot that lets you remotely control MCC over WebSocket. It runs a local WebSocket server inside your MCC session, accepts commands as JSON messages, and pushes game events back to connected clients in real time.
External Bot
This bot is not built into MCC. You load it as a standalone script with /script ChatBots/WebSocketBot.cs.
Quick Start
- Copy
config/ChatBots/WebSocketBot.csinto your MCCconfig/ChatBots/folder (it ships in the repo under that path). - Open the file and edit the line near the top:
MCC.LoadBot(new WebSocketBot("127.0.0.1", 8043, "CHANGE_THIS_PASSWORD"));- Replace
127.0.0.1with the IP to bind (use+or*for all interfaces). - Replace
8043with your preferred port. - Replace
CHANGE_THIS_PASSWORDwith a strong, unique password.
- Replace
- Optionally enable debug logging:
MCC.LoadBot(new WebSocketBot("127.0.0.1", 8043, "mypassword", debugMode: true)); - In MCC, run:
/script ChatBots/WebSocketBot.cs
The bot starts a WebSocket server. Connect to ws://127.0.0.1:8043/ with any WebSocket client.
Protocol Overview
All communication uses JSON over WebSocket text frames.
Authentication Flow
Connect via WebSocket
|
v
(Optional) Send "ChangeSessionId" to set a friendly session name
|
v
Send "Authenticate" with the configured password
|
v
Send commands and receive eventsSending Commands
Commands are JSON objects with this shape:
{
"command": "CommandName",
"requestId": "any-unique-string",
"parameters": [1, "text", true]
}command- the procedure name (case-sensitive)requestId- a client-generated ID so you can match responses to requestsparameters- an ordered array of arguments (types depend on the command)
Every command produces an OnWsCommandResponse event with success, requestId, and optionally message.
Sending Plain Text
You can also send plain text directly:
- Text starting with
/is forwarded to MCC as an internal command (e.g.,/move north). - Other text is sent as chat.
Receiving Events
Events arrive as JSON:
{
"event": "EventName",
"data": "{ ... serialized payload ... }"
}The data field is a JSON string that you parse separately to get the event payload.
Enum Serialization (String Names)
All enum values (ItemType, EntityType, Direction, Hand, etc.) are serialized as string names, not numeric IDs.
For example, an entity of type Zombie appears as:
{ "type": "Zombie", "location": { "x": 10, "y": 64, "z": -20 } }When sending commands that accept enum parameters, you can pass either a string name or a numeric value:
{ "command": "InteractEntity", "requestId": "abc", "parameters": [42, "Interact", "MainHand"] }or:
{ "command": "InteractEntity", "requestId": "abc", "parameters": [42, 0, 0] }Two dedicated commands let you query the full mapping tables:
GetItemTypeMappingsreturns{ "DiamondSword": 798, "Stone": 1, ... }GetEntityTypeMappingsreturns{ "Player": 128, "Zombie": 119, ... }
These are useful if your client needs a name-to-ID lookup for the current MCC version.
Reference
Compatibility
- Requires any MCC version that supports
/script(standalone MCCScript 1.0 bots). - Uses only
System.Text.Json(built into .NET), so no extra DLLs are needed. - Compatible with MCC.js and any WebSocket client library.
