Skip to main content
Glama

发布原始 MQTT 消息

mqtt_publish

Publish a raw message payload to an MQTT topic on a configured connection, with control over QoS, retain flag, and MQTT 5 user properties. Use it when you need exact payload control instead of a business template.

Instructions

向指定主题发布一条原始消息。payload 为字符串,对象请先 JSON.stringify。一般业务消息推荐使用 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": {
      "connection": "<connection>",
      "topic": "<topic>",
      "payload": "<payload>"
    },
    "name": "mqtt_publish"
  }
}

Input Schema

NameRequiredDescriptionDefault
qosNoQoS,默认 0
topicYes目标主题
retainNo是否保留消息,默认 false
payloadYes消息内容(字符串;对象请序列化为 JSON 字符串)
connectionYes连接名称
userPropertiesNoMQTT 5 用户属性

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.7/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the full disclosure burden. It conveys that the message is sent raw/unmodified, but says nothing about whether an active connection is required first, whether the call waits for broker acknowledgement or is fire-and-forget, or what happens on delivery failure — all material behavior for a publish operation.

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?

Three short sentences, front-loaded with the core action, then the one payload gotcha, then the sibling recommendation. Nothing is redundant or padded.

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

Completeness3/5

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

For a 6-parameter mutation-style tool with no annotations and no output schema, the definition covers purpose, payload encoding, and sibling routing, which is the minimum viable set. It leaves out connection prerequisites and delivery/acknowledgement semantics that an agent needs to invoke it safely.

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

Parameters3/5

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

Schema description coverage is 100%, so qos, retain, userProperties and topic are already documented structurally; the description only restates the payload string/JSON.stringify rule that the schema also states. It adds no syntax, format, or interaction detail (e.g. how qos and retain combine) beyond the schema.

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

Purpose5/5

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

"向指定主题发布一条原始消息" names a concrete verb (publish) and resource (raw MQTT message on a topic), and the closing sentence explicitly contrasts it with the sibling mqtt_send/template path. An agent can distinguish raw publish from template-based send without opening either schema.

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

Usage Guidelines4/5

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

It routes the agent: general business messages should go through mqtt_send with a protocol template, implying this tool is for cases where no template fits. What is missing is any prerequisite guidance — e.g. that a connection must already exist (mqtt_connect) — and there is no explicit "do not use when" statement beyond the sibling recommendation.

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