Skip to main content
Glama

定义业务消息协议模板

mqtt_template_save

Save 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

NameRequiredDescriptionDefault
qosNoQoS,默认 0
nameYes模板名称,唯一标识
topicYes主题模板,如 device/{{deviceId}}/control
retainNo是否保留,默认 false
strictNo缺少变量时是否报错,默认 true
payloadYes消息体模板,任意 JSON 结构,字符串中用 {{变量}} 插值
connectionYes默认使用的连接名称
descriptionNo协议说明
userPropertiesNoMQTT 5 用户属性模板

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full behavioral burden. It does usefully disclose the templating engine's capabilities (dot paths, default values, built-in $now/$timestamp/$date/$uuid) that are not in the schema, but it omits key operational behavior: whether an existing template name is overwritten or rejected, persistence of the definition, and any validation errors.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the definition act and the template syntax, then the follow-up usage. No filler and nothing structurally wasteful.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 9-parameter, nested-payload tool with no annotations and no output schema, the description covers the essential concept and the syntax an agent needs to build a valid template. The remaining gap is lifecycle behavior — duplicate-name handling and what a successful definition returns — which is minor but not negligible given the absence of annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description earns a bump by explaining what topic/payload templating actually supports — {{variable}} placeholders, dot-path access, default values, and built-in variables — which meaningfully extends the schema's one-line '字符串中用 {{变量}} 插值'. It still says nothing about qos/retain/strict/connection defaults beyond what the schema already documents.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource — '定义一个命名业务协议模板' — and immediately names the templating capabilities and the downstream consumer (mqtt_send). It does not explicitly distinguish itself from mqtt_template_remove or mqtt_templates, and 'define' vs 'save' leaves overwrite-vs-create slightly ambiguous, so it stops short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear downstream workflow hint: after defining, call mqtt_send with variable names and values. However, there is no explicit when-to-use/when-not guidance versus siblings like mqtt_publish (one-off send) or mqtt_templates (list existing), so the selection logic is only implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.