定义业务消息协议模板
mqtt_template_saveSave a reusable MQTT message template with topic and payload placeholders, defaults, and built-in variables, so later sends only need variable values.
Instructions
定义一个命名业务协议模板:主题与消息体支持 {{变量}} 占位符、点号路径、默认值与内置变量($now/$timestamp/$date/$uuid)。之后只需 mqtt_send 提供变量名和值即可发送。
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>",
"connection": "<connection>",
"topic": "<topic>",
"payload": "<payload>"
},
"name": "mqtt_template_save"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| qos | No | QoS,默认 0 | |
| name | Yes | 模板名称,唯一标识 | |
| topic | Yes | 主题模板,如 device/{{deviceId}}/control | |
| retain | No | 是否保留,默认 false | |
| strict | No | 缺少变量时是否报错,默认 true | |
| payload | Yes | 消息体模板,任意 JSON 结构,字符串中用 {{变量}} 插值 | |
| connection | Yes | 默认使用的连接名称 | |
| description | No | 协议说明 | |
| userProperties | No | MQTT 5 用户属性模板 |