Installation

MQTTX CLI supports Windows, macOS, and Linux. You can install MQTTX CLI in the following ways:

  1. Command Line: Quick installation with binaries.
  2. Desktop Client: Install directly via desktop app.
  3. Docker: Use Docker for installation.
  4. NPM: Install using NPM.
  5. Manual or GitHub: Download and install manually.

If you encounter network issues that cause slow or stuck downloads from GitHub, we recommend that you download and install from MQTTX CLI homepage.

If you need to download and use more released versions, you can also check out More Downloads, choose the version that meets your needs, and install it.

Note: When downloading, pay attention to distinguish the CPU architecture of the current system environment, and try to choose the latest version to download.

macOS

Homebrew

brew install emqx/mqttx/mqttx-cli

Intel Chip

curl -LO https://www.emqx.com/zh/downloads/MQTTX/${version}/mqttx-cli-macos-x64
sudo install ./mqttx-cli-macos-x64 /usr/local/bin/mqttx

Apple Silicon

curl -LO https://www.emqx.com/zh/downloads/MQTTX/${version}/mqttx-cli-macos-arm64
sudo install ./mqttx-cli-macos-arm64 /usr/local/bin/mqttx

Linux

x86-64

curl -LO https://www.emqx.com/zh/downloads/MQTTX/${version}/mqttx-cli-linux-x64
sudo install ./mqttx-cli-linux-x64 /usr/local/bin/mqttx

ARM64

curl -LO https://www.emqx.com/zh/downloads/MQTTX/${version}/mqttx-cli-linux-arm64
sudo install ./mqttx-cli-linux-arm64 /usr/local/bin/mqttx

Windows

For Windows users, please go to the MQTTX CLI home page or GitHub and find the exe package for the corresponding system architecture, download it manually and use it.

Note: When using commands that require input string data, please be aware to use double quotes in Windows cmd, while single quotes can be used in PowerShell. Additionally, the paths use \ while in other operating systems they use /.

Docker

First, pull the image:

docker pull emqx/mqttx-cli

Interactive Mode

To start an interactive shell session within the container (allowing multiple commands):

docker run -it --rm emqx/mqttx-cli

Once inside the container's shell, you can run mqttx commands (e.g., mqttx conn, mqttx pub). For example:

❯ docker run -it --rm emqx/mqttx-cli
/app # mqttx conn -h broker.emqx.io -p 1883
✔ Connected
- Press Ctrl+C to disconnect and exit

One-off Command Execution

To execute a single MQTTX command directly without entering the shell:

# Example: Connect to a broker
docker run --rm emqx/mqttx-cli mqttx conn -h broker.emqx.io -p 1883

# Example: Publish a message
docker run --rm emqx/mqttx-cli mqttx pub -t test -m "hello world" -h broker.emqx.io

# Example: Subscribe to a topic
docker run --rm emqx/mqttx-cli mqttx sub -t test -h broker.emqx.io

NPM

npm install mqttx-cli -g

Other platforms

Download packaged binaries from the MQTTX releases page.

Verify installation

After installation, you can verify that the installation is successful by running the following command:

mqttx -v