mqtty
mqtty bridges MQTT topics to either your local terminal or a pseudoterminal (PTY), and now also ships log capture and replay helpers for the same serial stream format.
This is useful for debugging, automation, or tunneling serial communication through a networked MQTT broker.
Commands
mqtty [-b <baud-rate>] mqtt://<host>/<topic> [--pts-only]
mqtty [-b <baud-rate>] <path-below-$MQTTY_URI> [--pts-only]
mqtty [--config /path/to/mqtty-serial-bridge.toml] /dev/ttyUSB0
mqtty --list [mqtt://<host>/<topic-base>] [--config /path/to/mqtty-serial-bridge.toml]
mqtty runs in bidirectional terminal mode by default:
- bytes from
stdinare published to.../device_serial_input - bytes from
.../device_serial_outputare written tostdout - if
stdinis a TTY, it is placed into raw mode whilemqttyis running - type
Ctrl-A Ctrl-Xto exit, matching picocom's default exit sequence - type
Ctrl-A Ctrl-Ato send a literalCtrl-A - before forwarding data, mqtty asks the serial bridge to activate the port and waits for a ready response
--startup-timeout SECONDSsets the initial deadline for connecting to the broker and activating the port (default10)- the default serial baud rate is 115200
Use -b or --baud-rate to request a different baud rate for the connected device:
mqtty -b 9600 mqtt://broker.local/mydevice
mqtty -b 57600 /dev/ttyACM0
Pass the local device alias, such as /dev/ttyUSB0, to resolve it through discovery and connect to its MQTT topic. When MQTTY_URI is unset, mqtty reads the broker and topic base from /etc/mqtty-serial-bridge.toml, the default config used by mqtty-serial-bridge:
mqtty /dev/ttyUSB0
Use --config to select a different bridge config file. The configured topic base scopes discovery to that bridge, so local listing includes devices below it without requiring hostname segments in device paths. For /dev/... aliases and mqtty -l without a URI, an available bridge config takes precedence over MQTTY_URI; pass a full mqtt:// URI to select a different scope. Device paths must exactly match the advertised alias, including /dev/.
Use --pts-only if you only want a PTY device:
--pts-only,-p: Print the path to the PTS device and keep it open without attaching local stdin/stdout. Useful for tools or scripts that want to use the virtual serial port.
Use --list to discover serial ports below a base topic:
--list,-l: Subscribe below<topic-base>for retained.../_mqtty/availablediscovery messages, print local bridge devices, and exit. If no URI is provided, mqtty usesMQTTY_URIor the bridge config's broker and topic base. With the bridge config, direct device entries undertopic_baseare local;-aincludes nested host paths too.-awith--list(for example,-la): Include devices advertised by all hostnames below the topic base.--list-timeout: Seconds to wait for retained discovery messages. Defaults to1.0.
mqtty-log records .../device_serial_output into replay files:
mqtty-log device mqtt://<host>/<serial-server>/<device> capture.jsonl.zst
mqtty-log prefix mqtt://<host>/<topic-prefix> logs/
devicerecords one full device URL into a single compressed replay file and adds.zstif omittedprefixsubscribes to<topic-prefix>/#, keeps topics ending indevice_serial_output, and rotates per-device logs under<outdir>/<topic-path-below-prefix>/YYYY-MM-DD_replay.jsonl.zst- each replay record stores an absolute Unix epoch timestamp in milliseconds (
ts) before relative delay (t) and payload (d)
mqtty-log-replay replays either plain or compressed replay logs:
mqtty-log-replay path/to/replay.jsonl.zst [--raw] [--follow] [--info]
Raw .jsonl logs are still accepted for replay and inspection. With --raw, stdout contains only the recorded bytes.
mqtty-serial-bridge discovers local serial devices and bridges them to MQTT:
mqtty-serial-bridge [--config /etc/mqtty-serial-bridge.toml]
It subscribes to:
<topic_base>/<port>/device_serial_input
And publishes:
<topic_base>/<port>/device_serial_output- retained
<topic_base>/<port>/_mqtty/available
The retained availability payload is JSON and is published as soon as the bridge opens a device; it does not wait for serial output:
{"port":"<port>","alias":"<alias>","active":true,"baud_rate":115200}
The bridge listens on <topic_base>/<port>/_mqtty/control for activation and baud-rate commands, and replies on <topic_base>/<port>/_mqtty/status. Control messages are non-retained JSON with a request ID; status replies acknowledge whether the port is open and report its baud rate. Serial bytes continue to use device_serial_input and device_serial_output unchanged.
The MQTT broker stores retained discovery messages, so clients only need to connect to the broker. The bridge does not use a database. The bridge clears a port's retained availability message during normal unplug and shutdown paths. If the bridge process crashes before cleanup, removed ports may remain listed until the bridge restarts or the retained messages are cleared from the broker.
Port aliases are resolved in this order:
[serial_aliases]entries in the bridge config<serial-base-path>/<port>.aliastext files- the resolved local device path, such as
/dev/ttyACM0
Default config path:
/etc/mqtty-serial-bridge.toml
The <topic> segment of the URI is used as the base path for MQTT messages across both live commands:
.../device_serial_inputreceives bytes from local input and sends them to the device.../device_serial_outputcarries device output back to your terminal or PTY
Example
mqtty mqtt://broker.local/mydevice
This connects your terminal directly to mydevice/device_serial_input and mydevice/device_serial_output.
To expose a PTY instead:
mqtty mqtt://broker.local/mydevice --pts-only
This prints the local PTY path and keeps it bridged to the same MQTT topics until interrupted.
For repeated use, set MQTTY_URI to your usual broker and base topic:
export MQTTY_URI=mqtt://broker.local/testbench/mark-desktop
mqtty --list
mqtty usb-c
mqtty platform-ci_hdrc.1-usb-0:1.2:1.0
mqtty --pts-only platform-ci_hdrc.1-usb-0:1.2:1.0
Short paths are appended to MQTTY_URI; full mqtt://, ws://, and wss:// URLs are still accepted anywhere a URI is accepted. Bare names, such as usb-c, are resolved against discovered port names and aliases before connecting. If a bare name is not listed by discovery, mqtty exits before opening the MQTT session.
To capture a replay log while a device is running:
mqtty-log device mqtt://broker.local/mydevice mydevice.jsonl.zst
To capture every device under one serial-server or a broader base prefix:
mqtty-log prefix mqtt://broker.local/testbench/mark-pantry logs/
mqtty-log prefix mqtt://broker.local/testbench logs/
To inspect or replay that log later:
mqtty-log-replay mydevice.jsonl.zst --info
mqtty-log-replay mydevice.jsonl.zst
To run the serial bridge:
mqtty-serial-bridge
To list retained serial bridge ports under a base topic:
export MQTTY_URI=mqtt://broker.local/testbench/serial
mqtty --list
mqtty --list mqtt://broker.local/testbench/serial
mqtty --list mqtt://broker.local/testbench/
Example output:
mqtt://broker.local/testbench/serial/platform-ci_hdrc.1-usb-0:1.2:1.0 (/dev/ttyACM0)
mqtt://broker.local/testbench/mark-desktop/platform-ci_hdrc.1-usb-0:1.2:1.0 (/dev/ttyACM0)
Testing
Run the test suite with:
pytest
Integration tests in tests/test_integration_mqtt_apps.py spin up a temporary local mosquitto broker and use Linux PTYs (pty.openpty) as fake serial devices.
Integration tests require mosquitto and fail if it is not available on PATH.
Repeatable Docker run (includes mosquitto in the container):
./scripts/run-tests-docker.sh
Show each executed test (verbose):
./scripts/run-tests-docker.sh --verbose
License
MIT
Metadata
Release files for mqtty 0.1.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mqtty-0.1.18.tar.gz | 56.9 kB | With provenance | Details for mqtty-0.1.18.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mqtty-0.1.18-py3-none-any.whl | Python 3 | none | any | Details for mqtty-0.1.18-py3-none-any.whl |
Total release size: 82.9 kB
Release files / mqtty-0.1.18.tar.gz
| Download URL | mqtty-0.1.18.tar.gz |
|---|---|
| Size | 56.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93d74076a45091d4daab44f2355ea184164b9702dcc36f007ebca232789740cd
|
|
BLAKE2b-256 checksum How to use checksums |
3608d58959d2486fb8e564560fe80e42ad8afe48fab5a6ca309faebfffe7b133
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / mqtty-0.1.18-py3-none-any.whl
| Download URL | mqtty-0.1.18-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
199d146f850f9e6793850df0b4a343ed2dfbef1d559e0e803ef472222b3f2c1c
|
|
BLAKE2b-256 checksum How to use checksums |
9187165dda20e7ff28424f5f3afc5cf0b29b151bb2523bf630e324310d58af8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for mqtty 0.1.18
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mqtty-0.1.18.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.