Dump the structure of an MQTT topic
Find a file
2025-12-11 19:01:23 +01:00
src add tests 2025-12-11 18:54:29 +01:00
.gitignore initial commit 2025-12-11 18:51:42 +01:00
Cargo.lock initial commit 2025-12-11 18:51:42 +01:00
Cargo.toml license: MIT 2025-12-11 18:58:53 +01:00
LICENSE license: MIT 2025-12-11 18:58:53 +01:00
README.md add README.md 2025-12-11 19:01:23 +01:00

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 like solar.
  • 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