The package exports two client layers:
MccClient- typed high-level command methods
- typed event subscriptions
- reconnect policy
- plain-text chat and serialized MCC slash-command support
MccProtocolClient- raw WebSocket transport lifecycle
- raw frame and envelope events
- explicit
sendCommand()andsendPlainText()primitives
Key helpers and types:
createMccUrl(host = "127.0.0.1", port = 8043, secure = false)commandDefinitionsKNOWN_PROTOCOL_EVENT_NAMES- protocol/event payload types from the package root
import { MccClient, createMccUrl } from "mcc.js";
const client = new MccClient({
url: createMccUrl(),
password: "CHANGE_THIS_PASSWORD",
reconnect: { attempts: 3, delayMs: 1_000 },
});
client.on("ready", () => {
console.log("ready");
});
client.on("OnChatRaw", ({ text }) => {
console.log(text);
});
await client.connect();Use on(), once(), or waitFor() with typed event names:
const [payload] = await client.waitFor("OnMccCommandResponse", {
timeoutMs: 5_000,
});Forward-compatible hooks are available on the low-level client:
rawFrameSentrawFrameReceivedrawEnveloperawProtocolEventunknownProtocolEventparsingError
client.sendChat("hello")- sends plain text over the socket
- MCC forwards it to in-game chat
client.sendMccCommand("help")- sends
/help - waits for
OnMccCommandResponse - serialized internally because the protocol does not include a request ID for plain-text MCC commands
- sends
client.protocolClient.sendCommand("GetUsername")- raw protocol command path
- resolves from
OnWsCommandResponse
- The WebSocket endpoint is the root path, not
/mcc. OnWsCommandResponsereturnsmessage, notresult.- The workspace copy of
WebSocketBot.csincludes a session-routing fix forChangeSessionId, andMccClient.connect()appliessessionIdafter authentication when provided. - If you connect this SDK to an older unpatched
WebSocketBot.cs, session renaming may still fail there. - Browser packaging is present, but browser execution testing is intentionally deferred in this pass.
npm run lint
npm test
npm run build
npm run test:runtime:node
npm run test:runtime:bun
npm run test:runtime:deno
MCC_WS_PASSWORD=CHANGE_THIS_PASSWORD npm run integration:local