配置 MQTT 连接
mqtt_configureAdd or update a named MQTT connection configuration by passing host and optional credentials, then reference it by name in mqtt_connect or mqtt_send for reusable broker connections.
Instructions
新增或更新一个命名 MQTT 连接配置。连接参数在此时传入并保存到本地;后续用 mqtt_connect 或 mqtt_send 按名称引用。host 为必填,其余使用默认值。
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"name": "<name>",
"host": "<host>"
},
"name": "mqtt_configure"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ca | No | CA 证书 PEM 内容 | |
| key | No | 客户端私钥 PEM 内容 | |
| cert | No | 客户端证书 PEM 内容 | |
| host | Yes | Broker 地址,如 127.0.0.1 或 example.com | |
| name | Yes | 连接名称,唯一标识,例如 factory-broker | |
| path | No | WebSocket 路径(ws/wss) | |
| port | No | 端口,默认按协议推断 | |
| clean | No | 清除会话,默认 true | |
| query | No | WebSocket 查询串,不含 ? | |
| clientId | No | 客户端 ID,留空自动生成 | |
| password | No | 密码 | |
| protocol | No | 协议,默认 mqtt | |
| username | No | 用户名 | |
| keepalive | No | 心跳秒数,默认 60 | |
| description | No | 备注说明 | |
| autoSubscribe | No | 连接后自动订阅,如 {"a/+/b": 0} | |
| connectTimeout | No | 连接超时毫秒,默认 10000 | |
| protocolVersion | No | MQTT 版本,默认 5 | |
| reconnectPeriod | No | 重连间隔毫秒,默认 3000,0 表示禁用 | |
| rejectUnauthorized | No | 是否校验证书,默认 true |