mqttx-cli
它能做什么
它运行 mqttx 命令来收发 MQTT 消息、检查连接,并模拟示例数据。适合处理 MQTT 消息通信的开发者和测试人员。
适用场景
- ✓当你想测试 MQTT 主题的发布或订阅时。
- ✓当你想检查代理服务器连接在 TLS 或登录方式下能否正常工作时。
- ✓当你想运行快速的 MQTT 基准测试或模拟示例消息时。
技能链接
https://github.com/emqx/MQTTX/blob/main/skills/mqttx-cli/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在我的测试代理服务器上订阅 sensors/temp 主题,并在消息到达时把它们显示给我。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体检查 mqttx 工具及其帮助信息,设置代理服务器详情,并以设定的时间限制运行命令。然后报告它看到的消息或错误。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
MQTTX CLI
Prepare
- Locate
mqttx, readmqttx --version, then inspectmqttx <command> --helpfor the task. Treat installed help as authoritative; release channels can differ. If missing or a required feature is unavailable, follow the repository's rootINSTALL.md, or its standalone installation guide when this skill has been copied elsewhere. Do not update a working CLI on every invocation. - Establish the broker hostname, port, transport (
mqtt,mqtts,ws,wss), MQTT version, credentials, topic and intended operation from the user's context. Ask only for missing information that affects execution. Use the requested broker; do not substitute a public broker after a failure. - Account for
~/.mqttx-cli/config, which can supply default host, port, protocol and credentials. Do not print its secrets or overwrite it for a one-off task. Explicit CLI arguments override defaults;--load-optionsloads command-specific JSON/YAML options, with explicitly supplied CLI arguments taking precedence. See configuration and utility commands for initialization, saving and loading. - Set a finite observation deadline for connection/subscription tasks and retain a handle to each process started. Use the agent's process controller or an available OS timeout tool; a tool returning a session handle is not necessarily a deadline. Terminate and wait for owned processes at completion or timeout.
The CLI command registration in this repository (1.13.0) does not offer general --timeout, --max-messages, --json or --output jsonl flags. Do not invent them. Recheck help for other versions. --reconnect-period 0 disables reconnection; it is not an overall deadline. conn stays connected after success and sub keeps listening until stopped.
Choose a workflow
This skill covers every command registered in the repository's CLI 1.13.0, including command-specific limitations. Read only the references relevant to the task. Coverage describes how to operate available features; it does not make unsupported combinations work or guarantee every broker implements them.
| Task | Read |
|---|---|
conn, pub, sub, bounded checks and round trips |
Basic workflows |
| Transport, TLS/mTLS, WebSocket headers, credentials, SCRAM | Connections and authentication |
| MQTT 3/5, QoS, retained messages, sessions, wills, request/response, subscription properties | MQTT features |
| Text/binary input, interactive line mode, files, codecs, Protobuf/Avro, random payloads | Payloads and files |
bench conn, bench pub, bench sub, simulate, ls --scenarios, custom generators |
Benchmarks and simulation |
init, check, help/version, INI defaults, JSON/YAML options |
Configuration and utilities |
| Exact flag availability by command and version-specific caveats | Capability map |
| Failures and diagnosis | Troubleshooting |
Read workflows for executable examples of a bounded connection check, one-message publish, bounded subscription, and end-to-end verification.
- Connection check: use
conn, capture diagnostics, and stop after observingConnectedor reaching the deadline. Report MQTT connection success separately from publish/subscribe permissions. - Publish: use
pubfor a single message. Prefer--file-reador--stdinfor complex payloads. Honor the requested QoS; use QoS 1 for a diagnostic round trip when unspecified. A publish success is not evidence that a subscriber or application processed the message. - Observe messages: use
subwith the requested topic filters and a bounded observation window. Preserve topic, QoS and relevant payload evidence. Quote wildcard filters in the shell. Never infer that a topic does not exist from an empty observation window. - Verify delivery: start the subscriber first, wait for the expected topic's
Subscribed to ...confirmation, then publish a unique marker and match the exact topic and marker. Do not use a fixed sleep as proof of subscription readiness. Use distinct client IDs and stop both processes on every completion path. - Troubleshoot: consult [troubleshooting](references/troub
常见问题
它会管理 MQTT 代理服务器本身吗?
不会。该技能只涉及通过 mqttx 命令操作 MQTT,不负责管理代理服务器。
它支持 MQTTX 桌面应用吗?
不支持。该技能说明它不操作桌面应用。
保存的连接设置存放在哪里?
存放在你主目录下 mqttx-cli 文件夹的配置文件中。对于一次性任务,智能体不会打印或覆盖该文件。
详情
作者的原始描述
Use MQTTX CLI for MQTT connections, publishing and subscriptions, MQTT 5 features, TLS and SCRAM authentication, payload codecs and schemas, benchmarks, built-in or custom data simulation, configuration, installation and troubleshooting. Use when operating or testing MQTT through the mqttx command. Does not operate MQTTX Desktop or administer a broker.
repo: emqx/MQTTX
热度
- GitHub 星标
- 5.1k
- 排名
- #15048
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …