Skip to content
Agentmart
Submit a tool

mdk-worker-plugin

Integrate a new device into MDK as a device Worker.

Skill by tetherto

IndexedApache-2.0★ 11
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/tetherto-mdk-worker-plugin

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Integrate a new device into MDK as a device Worker. Use for any task like "new device / miner / power meter / sensor / container Worker", "build a Worker", "integrate hardware", "wrap a device protocol (Modbus / CGMiner / HTTP / MQTT)", or anything creating or editing an mdk-contract.json, a Worker Plugin, or telemetry/command handlers under backend/workers/.

Use cases: documents, backend, writing, productivity

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found
Runs as
Node.js package

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/mdk-worker-plugin

What's inside

Skill name
mdk-worker-plugin
Description
Integrate a new device into MDK as a device Worker. Use for any task like "new device / miner / power meter / sensor / container Worker", "build a Worker", "integrate hardware", "wrap a device protocol (Modbus / CGMiner / HTTP / MQTT)", or anything creating or editing an mdk-contract.json, a Worker Plugin, or telemetry/command handlers under backend/workers/.
License
Apache-2.0
Metadata
suite: mdk-developer-skill · mdk_version: 0.7.0
Instructions
186 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts

Agent Skills spec issues

  • files: referenced but missing: references/mdk-contract.schema.json, examples/mvp-site/deploy/run-process.js

Files (8)

  • SKILL.md
  • mdk-contract.template.json · assets/
  • contract-authoring.md · references/
  • device-families.md · references/
  • local-testing.md · references/
  • worker-base-api.md · references/
  • validate-contract.mjs · scripts/
  • worker-smoke.mjs · scripts/

SKILL.md (first lines)

# Integrate a new MDK device Worker

A device Worker is a **Worker Plugin**: a package directory holding an
`mdk-contract.json` plus one small handler module per telemetry channel and
per command. It exports no module of its own. `WorkerRuntimeV2`
(`@tetherto/mdk-worker`) loads the directory and instantiates the plugin once
per device — handlers are plain `(params)` functions that read device context
from `require('@tetherto/mdk-worker/device')`. Workers are **site-agnostic**:
they know nothing about the site they run in, so everything here is testable
locally against a device mock before a Kernel ever exists.

The final package shape (this is `assets/worker-template/`, a verbatim copy of
`packages/cli/templates/worker/` — the same tree `mdk create worker` scaffolds):

```
<your-worker>/
├── mdk-contract.json            # single source of truth (package root)
├── package.json                 # no main/exports — the runtime loads the dir
├── smoke.config.js              # glue for scripts/worker-smoke.mjs
├── src/
│   ├── client.js                # vendor-protocol I/O via ambient device context
│   ├── telemetry/<name>.js      # one file per telemetry channel
│   └── commands/<name>.js       # one file per command
└── mock/server.js               # vendor firmware simulator
```

## Workflow

### 1. Start from the Worker template

The default starting point for every new Worker is `assets/worker-template/`
— a complete minimal Worker Plugin (contract + client + handlers + mock) with
no assumptions about your device category.

Do **not** model a new Worker on the MDK monorepo's shipped device families
(Whatsminer, Antminer, ABB, Seneca, …) by default — those still use the older
`plugin/` layout and are tightly coupled to the mining use cases they were
built for. Only when the user **explicitly asks** to follow the existing MDK
Worker families and their structure (e.g. contributing a Worker into this
monorepo, or deliberately mirroring a shipped family's protocol handling)
should you read [`references/device-families.md`](./references/device-families.md)
and copy from the named family instead.

### 2. Scaffold

In a CLI-managed project, scaffold and register in one step:

```bash
mdk create worker <name>
```

This copies the CLI Worker template into `workers/<name>`, links it as an npm
workspace member (root `npm install`, skip with `--no-install`), and appends
it under `mdk.yaml` → `spec.workers` with a `mock: true` seed device (skip
with `--no-stack-entry`) — so it is runnable immediately with
`mdk run worker <name>` before you change a line.

Outside the CLI (e.g. contributing inside the monorepo, or no `mdk.yaml`
project), copy `assets/worker-template/` to your Worker's location instead.
Either way, rename the template-specific parts (contract metadata, client
methods, mock behavior). Remember to adapt `smoke.config.js` (mock boot,
device opts, sample command params) and `package.json` (name, description).
The plugin is location-independent — put the package wherever your project
keeps packages. (Only Workers contributed to the MDK monorepo itself follow
its `backend/workers/<category>/<family>/` layout.)

### 3. Author `mdk-contract.json`

Start from [`assets/mdk-contract.template.json`](./assets/mdk-contract.template.json); the field-by-field guide is
[`references/contract-authoring.md`](./references/contract-authoring.md) — load it now. Non-negotiables:

- Every telemetry/command entry needs a `handler` path (e.g. `src/telemetry/<name>.js`)
  — the loader hard-fails without it.
- **Every `number` command param must declare `min` and `max`.** The Kernel
  enforces bounds only when declared (`ERR_PARAM_RANGE`); an undeclared bound
  is an unprotected physical setpoint.
- Read-only devices (meters, sensors) declare `"commands": []`.
- `description` / `overview` / `constraints` are simultaneously machine docs
  and AI operator context — write real semantics ("If 0, device is booting"),
  and put safety thresholds in the contract, not in code comments.

### 4. Validate the contract — loop until clean

```
node <this-skill>/scripts/validate-contract.mjs <worker>/mdk-contract.json
```

Validates against `references/mdk-contract.schema.json` plus semantic
checks (handler files exist, no duplicate names, numeric params bounded).
Fix and re-run until it exits 0. Handler files must exist first — stubs from
the template are enough at this stage.

### 5. Build the mock, then the device client

Write `mock/server.js` first — a standalone simulator of the vendor firmware
API that knows nothing about MDK. The template's self-contained HTTP JSON
mock is the pattern to follow; adapt it to your device's protocol. (Workers
living inside the MDK monorepo may instead reuse its shared mock framework in
[`backend/workers/mock/`](../../../../../backend/workers/mock/README.md).) Then write `src/client.js`: plain vendor-protocol
I/O. Bind to ambient device context
(`require('@tetherto/mdk-worker/device')` → `{ opts, env, config, logger }`)
rather than exporting a `createClient(opts)` factory — the runtime loads the
module fresh per device. Throw `ERR_*` errors. No envelopes, no base classes.

### 6. Wire the handlers

There is no `connect()` and no `plugin/index.js`. Each handler is
`async (params) => result` and talks to the device through `src/client.js`
(or by reading ambient context itself). Telemetry returns the channel value
(matching the contract's declared `type`); commands return a result object or
throw an `ERR_*` error. Full runtime semantics: [`references/worker-base-api.md`](references/worker-base-api.md).

Template pattern:

```js
'use strict'
const client = require('../client')
module.exports = async () => (await client.getSummary()).hashrate_ths
```

From tetherto/mdk, Apache-2.0.

More from tetherto/mdk

Signals

Stars
11
Forks
13
Open issues
0
Last commit (this folder)
Oct 22, 2026 (6 days ago)
Last release
Oct 19, 2026 (9 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from tetherto

Cite this page

mdk-worker-plugin skill. Agent Mart. https://agentmart.dev/skills/tetherto-mdk-worker-plugin (last updated 2026-10-24)