Dump the structure of an MQTT topic
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
MQTT Dump
mqtt-dump is a lightweight, structured MQTT inspection tool written in Rust. It subscribes to a topic (recursively by default), collects messages for a specified duration, and outputs the result as a clean, human-readable Markdown tree or structured JSON.
Features
- Structured Output: Generates a hierarchical tree view of your MQTT topics.
- Format Options:
- Markdown (default): Easy to read for humans and parsable by LLMs.
- JSON: Ideal for processing with tools like
jq.
- Type Detection: Automatically detects and formats JSON payloads (Numbers, Booleans, Objects) vs. plain Strings vs. Binary data.
- Secure Authentication: Supports fetching passwords via a shell command (avoiding history logs) or direct input.
- Recursive by Default: Automatically appends
/#if you subscribe to a base topic likesolar. - Single Binary: Statically compiled Rust binary, easy to deploy.
Installation
From Source
cargo build --release
# Binary is located at target/release/mqtt-dump
Usage
Basic Usage
Connect to a local broker and dump everything for 5 seconds (default):
mqtt-dump -H localhost
Advanced Usage
1. Secure Authentication & Specific Topic:
Retrieve the password using a command manager (like pass or rbw) and scan the home/kitchen topic for 1 minute.
mqtt-dump \
-H mqtt.example.com \
-u myuser \
--password-cmd 'pass mqtt/myuser' \
-t home/kitchen \
-d 1m
2. JSON Output for Scripting: Output raw JSON structure to pipe into other tools.
mqtt-dump -H localhost --format json | jq .
Options
Usage: mqtt-dump [OPTIONS] --host <HOST>
Options:
-H, --host <HOST> MQTT Broker Host
-P, --port <PORT> MQTT Broker Port [default: 1883]
-t, --topic <TOPIC> Topic to subscribe to [default: #]
-u, --username <USERNAME> Username
--password-cmd <PASSWORD_CMD> Command to retrieve password (executes in shell)
-p, --password <PASSWORD> Password (direct input, less secure)
-d, --duration <DURATION> Duration (e.g., "5s", "1m") [default: 5s]
-f, --format <FORMAT> Output format [default: markdown] [possible values: markdown, json]
-h, --help Print help
-V, --version Print version
License
MIT