usb-rea
usb-rea's MCP server reverse-engineers USB device protocols from labelled captures, turning clicks in a vendor app into an evidence report, a pyusb driver, or a Wireshark dissector.
Capture live traffic —
capture_start/capture_stoprecord usbmon (Linux) or USBPcap (Windows) traffic to a pcapng.Label actions —
mark_actionrecords each click (e.g.brightness 50%) orseenobservation (e.g.seen rpm 1180 temp 34) into a sidecar markers file.Infer the protocol —
diff_actionsreturns JSON with byte roles, fitted value scales, counters, checksums, device replies, handshakes, state/switch commands, and image streams.Write it up —
reportproduces a Markdown report with every claim linked to Wireshark frame numbers.Generate code —
scaffold_driveremits a standalone pyusb driver (set_*/query_*/send_imagemethods);wireshark_dissectoremits a Lua dissector with checksum verification.Decode HID —
hid_descriptorparses a report descriptor from a capture or hex, optionally decoding a payload.Check before capturing —
lookup_devicematches a VID:PID against liquidctl, rivalcfg and other open-source projects (offline, or online via OpenDeviceDB).Test on hardware —
replay_packetsends a single approved packet to a real device (refuses without explicit human confirmation).
Generates Wireshark Lua dissectors from an inferred USB protocol, so captured traffic is displayed as named commands with decoded values, counters, lookup labels, and checksum checks (filterable via tshark/Wireshark), and parses Wireshark/USBPcap pcapng captures as input for protocol inference.
usb-rea
usb-rea reads a USB capture (pcap or pcapng, from usbmon or USBPcap) and does the step after Wireshark: it infers the command and protocol structure from labelled actions, then writes a Markdown report and a standalone pyusb driver. I built it for gadgets that only ship a Windows vendor app, such as a case LCD, an RGB controller, a mouse or a "smart" lamp. No hardware is needed to try it.

From captures of the NZXT Kraken X (1e71:170e) fan command, it recovers 02 4d <channel> 00 <duty> byte for byte, as liquidctl's kraken2.py sends it, and the generated driver emits identical packets for duty values it never saw. The same holds for the SteelSeries Rival 100 DPI, polling and RGB tables from rivalcfg. Those checks run in CI; details are in validation.
Install
pip install usb-reaOn Arch Linux, use pipx install usb-rea instead; the FAQ has the packages for capture.
Related MCP server: tracea
Example
usb-rea demo --device fanmode 100% 0x5a | counter (+1 per message) | 0x30 | lookup 1→0x11, 2→0x22, 3→0x47 | 0x00 | 0x00 | u16le crc16_modbus(bytes[0:6])
fan 100% 0x5a | counter (+1 per message) | 0x10 | u16be round(value * 1 + 0) | 0x00 | u16le crc16_modbus(bytes[0:6])
color 100% 0x5a | counter (+1 per message) | 0x20 | RGB bytes | u16le crc16_modbus(bytes[0:6])
color only sent while mode 3: the driver sets it firstIt writes a synthetic capture of a fan controller, recovers the protocol and the replies, and writes report.md (every claim linked to Wireshark frame numbers) plus a working pyusb driver. --device lamp is a simpler 8-bit device; --device lcd is a pump cap screen; --device dial shows 32-bit values and packed bitfields.
On a real device, label each click in the vendor app, then infer:
sudo modprobe usbmon
usb-rea capture start -o lamp.pcapng
usb-rea mark -m lamp.pcapng.actions.json "brightness 0%" # then click it; 3+ values per setting
usb-rea capture stop
usb-rea report lamp.pcapng -o report.md
usb-rea scaffold lamp.pcapng -o lamp_driver.pyCaptured on Windows with USBPcap and no markers? List the actions in order and usb-rea splits the traffic at the pauses. The full CLI, including markers, replies, handshakes, image streams and HID, is in usage.
Before you capture, usb-rea lookup 1e71:170e (or the ID 1e71:170e form from lsusb) checks a VID:PID against devices whose protocol an open-source project already implements. The offline table is in known devices.
Limitations
Status: alpha (v0.7.14, on PyPI). It is validated on synthetic devices, on protocols documented by liquidctl and rivalcfg, on public Wireshark captures, and on a real AIO cooler LCD capture a user shared. Linear fits must survive leave-one-out cross-checks; otherwise usb-rea falls back to a lookup table and says so. A matching USB ID alone does not prove your unit speaks the same protocol.
How this differs from Wireshark is in the FAQ.
Reverse engineering for interoperability is permitted (EU Directive 2009/24/EC Art. 6, US DMCA §1201(f)). usb-rea only analyzes traffic of devices you own and never redistributes vendor code.
Have a Windows-only device? Open a device request with a capture and I will run it and publish the result.
Docs
MCP Registry name: io.github.emirmrkaljevic/usb-rea
License
MIT
Available Tools
10 toolscapture_startA
Start a USB traffic capture into out (usbmon on Linux, USBPcap on Windows).
Side effects: launches a background capture process that keeps writing until capture_stop. Needs elevated privileges on Linux (usbmon; typically root or a usbmon group). Does not touch the device itself. Pair every start with capture_stop; do not start a second capture while one is running. Prefer this over analysis tools when you still need live traffic.
Inputs: bus, out. Returns: result
capture_stopA
Stop the running capture started by capture_start.
Side effects: terminates the background capture process. The pcapng at the path given to capture_start is left on disk for report/diff_actions/scaffold_driver. Returns 'no capture running' if nothing was started (not an error). Call this before analysing.
Inputs: no named parameters. Returns: result
diff_actionsA
Diff packets per labelled action and infer the protocol (JSON: byte roles + evidence frames).
The JSON also has background (periodic polls set aside) and responses: device replies paired
with the query they answer (command, background poll or GET_REPORT), with byte roles
(const, echo of a query byte, value fitted to the labels, counter, checksum, or reading with
its observed min/max) and query/reply frame numbers. A reading that 'seen' markers explain
gets name, scale and bias (raw = value * scale + bias, signed for i8/i16) plus the
observations in observed; a named mode has table (raw value -> word the app showed);
observations lists every 'seen' value and which reply bytes it matched. handshake lists the
messages sent once before the first action (request, reply, expect with ?? for token and
checksum bytes, uses/tokens for reply bytes reused later as a session token, checksums,
retries, reopens, and branches on a step whose reply byte decided what the app sent next).
states lists commands the app only sent after a mode command chose one value (also on the
command as requires: state, value, count, other values seen, evidence frames), and with
source "reply" those it only sent while a named status reply byte showed one mode or flag
value (reply, where, reply_frames, and setter: the command seen to make the reply show it).
switches lists actions where the app sent a state command first (enter) and maybe again
after (restore: "previous", a value or null); that command's packets are kept out of the
action, which carries the same switch.
streams lists continuous image streams to a screen (JPEG/PNG/GIF/BMP/WEBP, or raw RGB565/RGB888 pixels
found by size with raw true): endpoint, endpoints (every host->device endpoint the frame bytes
go to, with endpoint_layout 'alternate' or 'blocks' when there are several) and
header_endpoint (where the draw command goes, when not with the pixels), format, frame and packet counts, chunk size, per-packet
header (nn packet count, ii index, 8 or 16 bit), image size, frame rate, the device's
per-frame ack and for raw streams header_packet (the command before each frame, or at the start of its first packet when
header_inline is true), region
(x/y/width/height fields), byteorder, size_alternatives and channel_order ('rgb' or 'bgr',
null = unknown; only settled by frames showing the usb-rea testcard picture, see
channel_evidence); those packets are kept out of the commands.
Read-only analysis: does not write files or talk to hardware. Requires either markers from
mark_action or labels for a finished capture with pauses between clicks. Prefer report
when the human wants a Markdown evidence write-up; prefer scaffold_driver /
wireshark_dissector when they want generated code.
Inputs: capture (required), device, labels, markers. Returns: result
hid_descriptorA
Decode a HID report descriptor (and optionally one report payload).
Read-only. When source is a capture path, finds GET_DESCRIPTOR type 0x22 transfers
(replug the device while capturing if none are present). When source is hex, parses that
descriptor directly (e.g. from /sys/class/hidraw/*/device/report_descriptor). Use this to
understand report IDs/sizes before or alongside report/scaffold_driver; it does not infer
vendor protocol fields from labelled actions.
Inputs: source (required), decode_hex, report_type. Returns: result
lookup_deviceA
Before capturing: is this device's protocol already documented by an open-source project?
Returns JSON per device: vendor/product names, status ('documented', 'unknown', or
'listed in OpenDeviceDB'), projects (liquidctl, rivalcfg, turing-smart-screen-python,
linux-thermalright-lcd-control, usb-rea's own case studies, with links and notes), limits
(e.g. a generic chip ID shared by unrelated products), same_vendor and with online=true
opendevicedb (matching records and their projects, or error when the network is down).
Read-only: sends only the VID:PID, never capture contents. A matching ID is a hint, not proof
of the same protocol; an unknown device stays 'unknown'. Use it before capture_start.
Inputs: device (required), online. Returns: result
mark_actionA
Record that the human is about to click this action in the vendor app.
Side effects: appends {label, start, end} to .actions.json (creates the file).
Call while capture_start is running, immediately before each click; end times are closed
when the next mark arrives. Use the same label stem with different values (brightness 0%,
50%, 100%) so inference can fit scales. For an already-finished Wireshark capture without
markers, skip this and pass labels to report/diff_actions instead.
A label starting with 'seen' ('seen rpm 1180', 'seen rpm 1180 temp 34') is an observation,
not an action: what the vendor app displays right now. It does not end the current action
and is never diffed; analysis uses it to name and scale the device's reply readings
(rpm = raw, temp = (raw - 40) / 2). Mark it when the human reads a value off the screen.
On/off states ('seen pump on', 'seen pump off, alarm on') name single status-flag bits; words
('seen mode silent', 'seen mode turbo, rpm 3900': the word last or before a comma) name a mode
byte with a value -> word map; negative values ('seen temp -5') allow signed i8/i16 readings.
Inputs: label (required), capture. Returns: result
replay_packetA
Send one packet to real USB hardware (destructive / irreversible on the device).
Side effects: opens the device via libusb/pyusb and writes the packet. Refuses unless user_confirmed=true after the human approved this exact vid/pid/endpoint/hex_data (and setup_hex if any). Needs OS permission to open the device. Prefer scaffold_driver to generate a driver first; never set user_confirmed from an agent guess.
Inputs: pid (required), vid (required), endpoint (required), hex_data (required), +2 more. Returns: result
reportA
Generate a Markdown evidence report: every claim links to frame numbers in the capture.
Includes a 'Device responses' section when the device answers queries (status polls, command ACKs, GET_REPORT), saying which reply bytes could not be explained, a 'Handshake' section for messages sent once before the first action (session setup, tokens), and an 'Observations' section for 'seen' markers (named readings and unmatched observations).
Read-only: returns Markdown text (does not write a file). Same inputs as diff_actions. Use after capture_stop (or on an existing pcap). Choose this over diff_actions when the human should read the protocol; choose scaffold_driver when they need a pyusb driver.
Inputs: capture (required), device, labels, markers. Returns: result
scaffold_driverA
Generate a standalone Python/pyusb driver source for the inferred protocol.
One set_() per command; when the device replies, also query_() methods that send the command/poll (or GET_REPORT), read the reply and return it decoded as a dict (readings named by 'seen' markers come back scaled and modes as words, e.g. {'rpm': 1180, 'temp': 34, 'mode': 'turbo', 'ok': True}). When the capture has a handshake, Device() replays it in open() before any command and checks the fixed reply bytes. A command the app only sent in one mode first calls the mode setter (Device(auto_state=False) raises StateError instead). A capture with an image stream to a screen adds send_image(image), which takes JPEG bytes (or, for a raw stream, a Pillow image or RGB565/RGB888 bytes, optionally a region at x, y), chunks it behind the captured header and returns the device's ack.
Read-only analysis that returns driver source as text (does not write a file or open the device). Same capture/markers/labels inputs as report. Prefer wireshark_dissector when the goal is to keep decoding traffic in Wireshark; use replay_packet only after the human approved a specific packet from this driver.
Inputs: capture (required), device, labels, markers. Returns: result
wireshark_dissectorA
Generate a Wireshark Lua dissector for the inferred protocol.
Read-only: returns Lua source as text. Labels commands, decodes values/counters/lookups,
and verifies checksums (usbrea.checksum_ok + expert warning). Load with
wireshark -X lua_script:<file>.lua capture.pcapng or the same flag on tshark. Prefer
scaffold_driver for a pyusb driver; prefer hid_descriptor to inspect HID report layouts.
Inputs: capture (required), name, device, labels, +1 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool occupies a distinct stage of one pipeline: lookup_device (pre-capture check), capture_start/capture_stop (traffic acquisition), mark_action (labelling), diff_actions (inference), report/scaffold_driver/wireshark_dissector (three different output formats), hid_descriptor (report layout), replay_packet (hardware write). The descriptions explicitly disambiguate the closest pairs ('prefer report when the human wants Markdown', 'prefer scaffold_driver for a pyusb driver', 'prefer hid_descriptor to inspect HID layouts'), so even tools sharing the same capture inputs are clearly separated by output artifact.
All names are snake_case, which is good, but the verb/noun ordering is mixed: lookup_device, mark_action, diff_actions, replay_packet are verb_noun while capture_start and capture_stop are noun_verb, and report, hid_descriptor, wireshark_dissector, scaffold_driver are bare nouns. It remains readable and guessable, but the pattern is not predictable enough to be called consistent.
Ten tools map cleanly onto the reverse-engineering workflow with no filler: acquisition pair, labelling, one analysis engine surfaced through three output generators, plus supporting lookup, HID decode, and hardware replay. Nothing feels bolted on and no stage is doubled up.
The surface covers the full lifecycle from 'is this already documented' through capture, labelling, inference, evidence reporting, driver and dissector generation, to a guarded hardware write, which is strong end-to-end coverage. Minor gaps remain: no device/interface/endpoint enumeration tool (setup_hex and vid/pid/endpoint must be supplied from elsewhere), no way to compare captures or re-run inference with edited labels without redoing markers, and no capture file management (trim/list/export).
Maintenance
Related MCP Connectors
Evidence-oriented REA + Ghidra static-analysis workflows, read-only PE32 and Delphi VMT tools.
Hunt zero-days by talking to binaries. 40+ tools. Hosted, OAuth + SSO, invite: hi@byteray.ai
Captured web interfaces, screenshots, flows and structured evidence for AI coding agents.
Signed sandbox verdicts on any artifact, plus an agent marketplace. No key, no signup, no payment.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceDrive a Cynthion USB test instrument from an LLM via the Model Context Protocol. Sniff, decode, and emulate USB devices over chat.7BSD 3-Clause
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to dynamically inspect running software — API hooks, syscall summaries, memory inspection, and HTTP/TLS/DNS reconstruction from live traffic or pcaps — across Linux, macOS, and Android targets. Every finding is returned as a structured Evidence Record with observation, artifacts, confidence, and explicit limitations, so agents cite proof rather than guess.1MIT
- AlicenseNot gradedqualityBmaintenanceLet an AI agent sniff and reverse-engineer a car's LIN bus with an open-source USB LIN dongle: per-id capture with changing bits, change log, auto-detect speed/checksum, LDF decode/encode; read-only by default, master/slave simulation behind --allow-transmit, --mock simulated bus.94GPL 3.0
- AlicenseBqualityBmaintenancehelps coding agents work out the bluetooth le and classic protocol of gadgets you own; writes need a human to arm the device in a terminal1840 PyPI1MIT