Skip to main content
Glama

订阅 MQTT 主题

mqtt_subscribe

Subscribes to one or more MQTT topics, including + and # wildcards, and caches incoming messages in memory for later retrieval with mqtt_messages.

Instructions

订阅一个或多个主题(支持 + 和 # 通配符)。收到的消息会缓存在内存中,可用 mqtt_messages 读取。

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>"
    },
    "name": "mqtt_subscribe"
  }
}

Input Schema

NameRequiredDescriptionDefault
qosNoQoS,默认 0
topicYes主题或主题数组
connectionYes连接名称

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description carries the full behavioral burden. It does disclose an important non-obvious trait: messages are buffered in memory rather than returned synchronously, and must be fetched with mqtt_messages. However it omits whether subscriptions survive reconnects or process restarts, how buffer growth is bounded, whether duplicate subscriptions are idempotent, and what happens if the connection is not established.

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 short sentences, both load-bearing: the first defines the action and its topic capabilities, the second defines the asynchronous delivery model and where to retrieve results. The most decision-relevant information (subscription behavior and wildcard support) is front-loaded with no filler.

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 three-parameter mutation-like tool with no annotations and no output schema, the description explains the crucial async return path via mqtt_messages, which is a real gap-filler. It still leaves out connection prerequisites and subscription lifecycle details, leaving the agent to infer how this fits with mqtt_connect and mqtt_unsubscribe.

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% and all three parameters are documented in the schema, so the schema supplies the baseline semantics. The description does add meaning beyond the schema for `topic` by declaring wildcard support, which the schema only describes as '主题或主题数组'. Since it adds nothing about `qos` or `connection` beyond the schema, this is a modest rather than substantial addition.

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?

The description states a specific verb (subscribe) and resource (one or more MQTT topics), plus the wildcard support ('+ 和 #') that defines the tool's scope. It also names mqtt_messages as the reader of the resulting messages, which implicitly separates it from the sibling that retrieves messages. It does not distinguish itself from mqtt_unsubscribe or mqtt_connect, but the core purpose is unambiguous.

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?

Usage is implied by the delivery model: subscribe here, then read via mqtt_messages. There is no explicit when-not guidance, no mention of a prerequisite mqtt_connect/connection existence, and no statement about what to do if the topic is already subscribed. The agent can infer the workflow but must guess at prerequisites and alternatives like mqtt_unsubscribe.

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