Judge hardware timing/serial against a contract: pass/marginal/fail (WS2812, DShot, logs)
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
A zero-dependency MCP server that judges hardware against a contract. Coding agents (Claude Code, Codex, opencode) write firmware that's correct on paper but wrong on the wire β a WS2812 pulse 180ns short, an ESC bit out of spec, a boot log that silently panics. This closes the loop: it captures what the hardware actually did and returns pass / marginal / fail the agent can iterate on.
marginal is the valuable verdict β in-spec but low-headroom, the bug that works on
your bench and fails on a cold board in the field.
python3 demo/ws2812b_neopixel.py downloads a real 24-LED NeoPixel capture
(recorded off hardware by the sigrok project, 24 MHz), extracts the data line, and
judges it against two contracts:
Same real signal: it fails the generic WS2812 contract (correctly β a WS2812B isn't a WS2812) and passes the matching WS2812B one. That's the tool doing its job: measure the real signal, hold it to a spec, and make contracts chip-specific.
judge.py β the pure judge (timing + serial). No hardware, no framework, cached.sigrok_adapter.py β logic-analyzer capture β pulse-width observations (WS2812/DShot).serial_adapter.py β serial log capture (or replay a saved log).server.py β the MCP server (stdio JSON-RPC, stdlib only).*.contract.yaml β what "correct" looks like. Human-editable. Also serve as regression tests.Also needs sigrok-cli on PATH for live logic-analyzer capture (check_ws2812 /
check_dshot). Judge-only tools (judge_contract, judge_serial) need nothing extra.
One stanza per client (not auto-discovered β add it once). After pip install, the
hwcontract command is on your PATH.
Claude Code
Codex CLI β ~/.codex/config.toml
opencode / Cursor / Gemini / any stdio MCP client
Transport is stdio by default (local, no auth surface). For remote-only clients (e.g. ChatGPT connectors), run
hwcontract --http 8791and expose it via a tunnel withHWCONTRACT_TOKENset for bearer auth.
hwcontract (PATH issues)GUI apps and some agents don't inherit your shell PATH, so a bare hwcontract
can fail with "command not found". Two robust fixes:
which hwcontract β put that full path in command.command: "python3",
args: ["-m", "hwcontract.server"] β works from any directory once installed.Contract paths: pass an absolute contract_path, or set HWCONTRACT_ROOT
to your contracts folder β relative paths resolve against it (default: the process's
working directory, which the client controls and may not be your project). Paths
outside the root are rejected. Bundled examples install with the package under
hwcontract/examples/.
| Tool | Hardware? | What it does |
|---|---|---|
judge_contract | no | Judge given observations against a timing contract. Replay / testing. |
judge_serial | no | Judge a given log string against a serial contract's expect/forbid. |
check_ws2812 | yes | Capture a live WS2812 line and judge it, one call. |
check_dshot | yes | Same, for a DShot600 ESC signal. |
capture_ws2812 | yes | Just capture β observations (no judging). |
check_serial | yes | Read a serial port for N seconds and judge the log. |
Timing (ws2812.contract.yaml, dshot.contract.yaml) β pulse widths in ns:
Serial (boot.contract.yaml) β Python regex:
Add a protocol = drop a new YAML. No code change for another timing signal.
Instantly disable every hardware-touching tool (captures) while leaving the pure judge tools working:
Every tool argument is treated as hostile (the caller is an LLM that can be prompt-
injected): contract paths are confined to the server dir (override HWCONTRACT_ROOT),
driver/channel/port are charset-validated, samples/seconds/samplerate are
clamped, sigrok-cli runs with a timeout, YAML is safe_load. Do not expose this
server over the network without adding authentication.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/hwcontract)<a href="https://allmcps.com/mcp/hwcontract"><img src="https://allmcps.com/api/badge/hwcontract?style=directory" alt="Hwcontract on AllMCPs" /></a>