Run a Whatsminer Worker
Start an MDK Worker for a MicroBT Whatsminer device.
TL;DR
Run from your project folder (holding
mdk.yaml). Runtime:mdk run.mdk add workerinstalls the plugin there, andmdk runwrites the Kernel key to.mdk/kernel.key.
mdk add worker github:whatsminer/whatsminer-mdk-worker#<ref> --name whatsmineradds the plugin with its mock switched onmdk runstarts the Worker and its mock;mdk statusin a second terminal shows itREADY- Check the device reports telemetry with
curlthrough the Gateway:READYproves the Worker registered, not that its device answers
Overview
Whatsminer support ships as the external whatsminer-mdk-worker contract plugin: a plain
mdk-contract.json plus handler files, with no model allowlist. Compatibility comes from the firmware API each miner
reports. mdk add worker installs it into an MDK project from GitHub, and mdk run hosts it against its bundled mock or
a real miner. A Node.js service can host it on WorkerRuntimeV2 instead, through the adapter this
repo ships.
Prerequisites
Review the common deployment prerequisites before you start.
Deployment-specific requirements:
- An MDK project with
mdk.yaml, frommdk onboard - A supported Whatsminer device reachable from the machine or container running the Worker
- The miner API reachable over encrypted TCP: with no
portset, the plugin probes API v3 on4433first, then API v2 on4028; set either port to pin that version - The Whatsminer API password, from which the plugin derives its auth tokens. API v3 firmware also takes an API
account: the account set up on your miner
Add the Worker
whatsminer-mdk-worker is a git dependency, not a package on the npm registry. Add it at the commit MDK tests against,
the ref of its entry in external-workers.json, from the project directory:
mdk add worker github:whatsminer/whatsminer-mdk-worker#a47fa82020454f9bfa9963ccaaa319b7948e8aa2 --name whatsminer --seed-optsThe command pins that commit in package.json and writes the Worker into mdk.yaml with the plugin's mock switched on:
config.mock names mock/api-v3-server.js, and one device points at that mock on a local port. --seed-opts runs one file
of the plugin, its smoke.config.js, to seed the device with the address, port, API version, account, and password the mock
expects. Without it, every telemetry read fails: the device gets placeholder options. The
mdk add worker reference covers how that file runs and every field the command seeds. npm prints a
deprecation warning for crypto-js, a dependency the plugin declares, and a warning that it skips the integrity check for the
git dependency; the install still succeeds, and Worker troubleshooting explains both.
What the command writes to mdk.yaml
spec:
workers:
- name: whatsminer
package: whatsminer-mdk-worker
config:
mock: mock/api-v3-server.js
telemetryPollIntervalMs: 60000
devices:
- id: whatsminer-0
opts:
address: 127.0.0.1
port: 18080
apiVersion: 3.0.3
account: admin
password: super
type: miner-wm-m56sRun against the mock
The mock answers the API v3 protocol the Worker speaks. mdk run starts it with the Worker:
mdk runExpected output includes a line for the Worker, with your own key:
✔ worker whatsminer ready 11db6adad0a9bea8Check the stack from a second terminal in the project directory:
mdk statusExpected output ends with:
WORKER REGISTERED STATE HEALTH DEVICES
whatsminer yes READY HEALTHY 1
✔ Health: healthyWhile the stack runs, the Worker serves live telemetry (hashrate, power, temperature) from the mock.
READY and HEALTHY prove the Worker registered, not that its device answers: what a healthy run shows
covers the difference. To see a reading, check the device reports telemetry.
Connect a miner
3.1 Declare your miner
Replace the whatsminer entry mdk add worker wrote, rather than adding a second one: point the device at the real miner,
drop mock, and drop the mock's port and apiVersion so the plugin probes the
firmware. Replace the example address and account with your miner's values:
spec:
workers:
- name: whatsminer
package: whatsminer-mdk-worker
config:
telemetryPollIntervalMs: 60000 # written by mdk add worker
devices:
- id: WM-001
opts: { address: 192.168.1.10, password: "${WHATSMINER_PASSWORD}", account: admin, type: miner-wm-m56s }The password is a ${WHATSMINER_PASSWORD} placeholder, so it stays out of mdk.yaml. Add it to the project's .env, quoted as
writing a value in .env describes:
WHATSMINER_PASSWORD='<your-miner-password>'Keep .env out of version control and readable by you alone (chmod 600 .env).
The CLI resolves the placeholder when it loads mdk.yaml, and stops with an error naming the variable when it
is unset.
Leave port unset so the plugin probes API v3 on 4433 and then API v2 on 4028; set it only to pin one version.
account is read by API v3 firmware and ignored by API v2. Leave it unset and the plugin sends super. The
whatsminer-mdk-worker README lists every device option.
Run mdk run and mdk status again, then read WM-001 through the telemetry route: the status row looks
the same when the miner is unreachable, so only the read proves it answers.
mdk run warns that the device may be missing apiVersion; that is expected, since the plugin probes the firmware for it.
The read doesn't test the password: only commands use it. For an error on every channel, read a failed check.
Make sure each miner's IP is reachable from the machine or container running the Worker before registering. Commands act on physical hardware. Prioritize thermal safety.
The device list is fixed when the Worker starts. There is no registerThing/updateThing/forgetThings equivalent:
adding, updating, or removing a device means editing devices and restarting the Worker.
3.2 (Optional) Host the Worker in your own service
A Node.js service that hosts its own Workers runs the plugin on WorkerRuntimeV2 instead of
mdk run. Copy the Whatsminer adapter and the miner-metadata.js it loads,
and add debug to your dependencies. The adapter maps a seed device list onto the runtime and forwards allowedKeys and
allowAll; the metadata schema declares the Starter site's own placement fields (container, pdu, socket), so
replace them with your site's. startWhatsminerWorker in that example's backend/site.js shows the call. After
kernel.registerWorker, check that the Kernel accepted the Worker, then
check a device reports telemetry from the same service.
The whatsminer-mdk-worker README documents the plugin's own mdk-contract.json, supported
models, and connection options in full; the shared install pattern covers the broader deployment
mechanics.
Check the device reports telemetry
Under mdk run, add the telemetry route to an app once, sign in, then read the device from a second
terminal:
curl -sS -H "Authorization: Bearer $TOKEN" http://localhost:3847/apps/fleet/api/fleet/devices/whatsminer-0/telemetryExpected output against the mock, with your own values, shortened:
{"deviceId":"whatsminer-0","metrics":{"hashrate_rt":101.84,"hashrate_avg":101.84,"power":3247.64,"temperature":92.9,"fan_speed_in":4980,"fan_speed_out":5070,"status":"mining","uptime":1175,"accepted_shares":0,"rejected_shares":0,"pool_url":"stratum+tcp://pool.example:3333","efficiency":31.88,"power_mode":"normal","api_version":"3.0.3",...mdk add worker seeds the mock's device ID; for a real miner, put the ID you declared in mdk.yaml in the path.
An error instead of a value? Read a failed check.
Troubleshooting
An unreachable miner doesn't fail at load time: the Worker reports the device online and the failure surfaces inside the telemetry channel or command response that touched the network. If the Worker doesn't come up, or a mock port is already in use, follow Worker troubleshooting.
Next steps
- Understand the deployment topologies for running the Worker service
- Review
whatsminer-mdk-worker's ownmdk-contract.jsonfor telemetry units, command shapes, and error codes; it isn't vendored into this repo