npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mqtt-tail

v0.1.0

Published

Monitor MQTT topics like tail -f

Readme

mqtt-tail

npm version Node.js >= 18 License: MIT

tail -f for MQTT. Watch topics stream live in your terminal.

16:42:03.112 │ sensors/temperature
{
  "value": 23.5,
  "unit": "C",
  "sensor": "living-room"
}

16:42:04.891 │ sensors/humidity
{
  "value": 61,
  "unit": "%"
}

Install

# Run without installing
npx mqtt-tail

# Or install globally
npm install -g mqtt-tail

Usage

mqtt-tail [options] [topics...]

Topics default to # (all) when omitted. MQTT wildcards are fully supported:

  • + matches a single level: sensors/+/temp
  • # matches multiple levels: sensors/#

Examples

# Watch everything on localhost
mqtt-tail

# Single topic
mqtt-tail sensors/temperature

# Multiple topics with wildcards
mqtt-tail "sensors/+" "control/#"

# Remote broker with TLS and auth
mqtt-tail -H mqtt.example.com -p 8883 --tls -u alice -P secret "sensors/#"

# Filter by topic regex
mqtt-tail -f "temperature|humidity" "#"

# Filter by payload content
mqtt-tail --payload-filter "error" "logs/#"

# Exit after 20 messages
mqtt-tail -n 20 "#"

# One line per message (good for grepping)
mqtt-tail --compact "#"

# Pipe to jq
mqtt-tail --output-json "#" | jq '.payload'
mqtt-tail --output-json "sensors/#" | jq 'select(.topic | test("temp")) | .payload.value'

# Skip retained messages, show metadata
mqtt-tail --no-retained --verbose "#"

# CI / scripting (no colors, no timestamps)
mqtt-tail --no-color --no-timestamp --raw "#"

Options

Connection

| Flag | Description | Default | |------|-------------|---------| | -H, --host <host> | Broker host | localhost | | -p, --port <port> | Broker port | 1883 (8883 with --tls) | | -u, --username <user> | Username | | | -P, --password <pass> | Password | | | --tls | Use TLS/SSL (mqtts://) | | | --ca <file> | CA certificate file | | | --cert <file> | Client certificate file | | | --key <file> | Client key file | | | --client-id <id> | MQTT client ID | random | | -q, --qos <level> | Subscription QoS (0|1|2) | 0 |

Filtering

| Flag | Description | |------|-------------| | -n, --count <n> | Exit after n messages | | -f, --filter <regex> | Only show topics matching regex | | --payload-filter <regex> | Only show messages whose payload matches regex | | --no-retained | Ignore retained messages |

Output

| Flag | Description | |------|-------------| | --compact | One line per message | | --output-json | Newline-delimited JSON (for piping) | | --raw | Raw payload, no formatting | | --no-timestamp | Hide timestamps | | --timestamp-format <fmt> | local (default) | iso | unix | unixms | | --no-color | Disable colors | | -v, --verbose | Show connection info and per-message QoS/size/retain |

Misc

| Flag | Description | |------|-------------| | --config <file> | Path to config file (default: ~/.mqtttailrc.json) |

Output formats

Default — pretty-printed, syntax-highlighted JSON, colored topics:

16:42:03.112 │ sensors/temperature
{
  "value": 23.5,
  "unit": "C"
}

--compact — one line per message:

16:42:03.112 │ sensors/temperature  {"value":23.5,"unit":"C"}

--output-json — newline-delimited JSON for scripting:

{"timestamp":"2024-01-15T16:42:03.112Z","topic":"sensors/temperature","payload":{"value":23.5},"qos":0,"retain":false,"size":28}

--raw — no formatting:

sensors/temperature {"value":23.5,"unit":"C"}

Configuration

Options are resolved in this order (highest priority first):

  1. CLI flags
  2. process.env — shell environment variables
  3. .env file — in the current working directory
  4. ~/.mqtttailrc.json — global user config file

This means you can configure a broker once and forget about it, while still being able to override any value inline.

First-run setup wizard

On first run (no broker config found), mqtt-tail starts an interactive setup wizard that asks for your broker host, port, credentials, and TLS settings, then saves them to ~/.mqtttailrc.json. Skip it by passing connection flags directly or by pre-creating the config file.

With npx

Config is read from your home directory and environment, not from the npx temp cache, so it works transparently with npx:

# One-time setup
echo '{"host":"mqtt.example.com","username":"alice","password":"secret"}' > ~/.mqtttailrc.json

# From now on, just run
npx mqtt-tail sensors/#

.env file

Place a .env in your current directory for project-specific settings:

MQTT_HOST=mqtt.example.com
MQTT_PORT=8883
MQTT_TLS=true
MQTT_USERNAME=alice
MQTT_PASSWORD=secret

Then run from that directory:

npx mqtt-tail sensors/#

Add .env to your .gitignore to keep credentials out of version control.

Environment variables

Useful for CI/CD, Docker, or one-off overrides:

MQTT_HOST=broker.example.com MQTT_USERNAME=alice MQTT_PASSWORD=secret npx mqtt-tail "#"

| Variable | Option | |----------|--------| | MQTT_HOST | --host | | MQTT_PORT | --port | | MQTT_USERNAME | --username | | MQTT_PASSWORD | --password | | MQTT_TLS | --tls | | MQTT_CLIENT_ID | --client-id | | MQTT_CA | --ca | | MQTT_CERT | --cert | | MQTT_KEY | --key |

Global config file

mqtt-tail searches the following locations in order:

  1. ~/.mqtttailrc.json
  2. ~/.mqtttailrc
  3. .mqtttailrc.json in the current directory

Override the path with --config <file>.

{
  "host": "mqtt.example.com",
  "port": 8883,
  "tls": true,
  "username": "alice",
  "password": "secret"
}

Requirements

  • Node.js >= 18

License

MIT


Built with Claude Code.