Run an Antminer Worker
Start an MDK Worker for a Bitmain Antminer 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:bitmain-official/antminer-mdk-worker#<ref> --name antmineradds 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
Antminer support ships as the external antminer-mdk-worker contract plugin, maintained by
Bitmain. It's a plain mdk-contract.json plus handler files, with no model allowlist: compatibility comes from the
firmware capabilities 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 - An Antminer running stock firmware and reachable from the machine or container running the Worker
- The miner's HTTP CGI API reachable, port
80by default - HTTP Digest credentials for the miner. The factory default is
root/root; use your site's configured credentials
Add the Worker
antminer-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:bitmain-official/antminer-mdk-worker#4fd776b4a048a1bc8284ec2eceed82b4631f960c --name antminer --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/cgi-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, and credentials the mock expects; without it,
the device gets placeholder options. The mdk add worker reference covers how that file runs and every
field the command seeds. npm warns that it skips the integrity check for the git dependency; the install still succeeds,
and Worker troubleshooting explains why.
What the command writes to mdk.yaml
spec:
workers:
- name: antminer
package: antminer-mdk-worker
config:
mock: mock/cgi-server.js
telemetryPollIntervalMs: 60000
devices:
- id: antminer-0
opts:
address: 127.0.0.1
port: 18080
username: root
password: testRun against the mock
The mock enforces real digest authentication, serves every CGI endpoint the Worker uses, and applies command writes to
its state. mdk run starts it with the Worker:
mdk runExpected output includes a line for the Worker, with your own key:
✔ worker antminer ready 4ba643c6bc5e27eaCheck the stack from a second terminal in the project directory:
mdk statusExpected output ends with:
WORKER REGISTERED STATE HEALTH DEVICES
antminer 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 antminer entry mdk add worker wrote, rather than adding a second one: point the device at the real miner and
drop mock. Replace the example address and username with your miner's values:
spec:
workers:
- name: antminer
package: antminer-mdk-worker
config:
telemetryPollIntervalMs: 60000 # written by mdk add worker
devices:
- id: AM-001
opts: { address: 192.168.1.10, port: 80, username: root, password: "${ANTMINER_PASSWORD}", type: miner-am-s21 }The password is a ${ANTMINER_PASSWORD} placeholder, so it stays out of mdk.yaml. Add it to the project's .env, quoted as
writing a value in .env describes:
ANTMINER_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.
Device opts fields the plugin reads:
| Field | Required | Description |
|---|---|---|
address | Yes | Miner IPv4 address or hostname. host is accepted as an alias |
username | No | HTTP Digest username. Defaults to root |
password | No | HTTP Digest password. Defaults to root; override with the real credentials |
port | No | HTTP API port. Defaults to 80 |
timeout | No | Per-request timeout in milliseconds. Defaults to 10000 |
type | No | Device type tag such as miner-am-s21xp_hyd. Resolves the rated J/TH reported in snap |
nominalEfficiencyWThs | No | Overrides the nominal efficiency table for snap |
conf | No | Configured pools (conf.pools, max 3), timeouts, and size limits |
Run mdk run and mdk status again, then read AM-001 through the telemetry route: the status row looks
the same when the miner is unreachable, so only the read proves it answers.
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 Antminer 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. bootAntminerWorker 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 antminer-mdk-worker README and USAGE document the plugin's telemetry channels, commands,
failure semantics, and live-device test scripts 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/antminer-0/telemetryExpected output against the mock, with your own values, shortened:
{"deviceId":"antminer-0","metrics":{"hashrate_rt":198.45,"hashrate_avg":199.61,"hashrate_ideal":200,"power":3420,"efficiency":17.1,"temperature":97,"ambient_temp":32.5,...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
antminer-mdk-worker's ownmdk-contract.jsonfor telemetry units, command shapes, and error codes; it isn't vendored into this repo