MQTT Client
Publish to MQTT Broker.
Connects to an MQTT broker, publishes one message to a topic and disconnects.
How it works
- Resolves the config.
connection_id,topic,messageandretain(default false) fall back to the same keys of the incoming payload; the first three are required. - Resolves the credential: the broker URL is
config.url, ormqtt://<config.host>:<config.port>(port default 1883);usernameandpasswordcome from the secret when present. - Connects, publishes
messagetotopicwith theretainflag, and closes the connection. - Returns
{ result: { published: true, topic } }throughout; any failure leaves througherror.
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-publish-command",
"label": "Publish line command",
"operator_slug": "io.mqtt",
"operator_version": "1.0.0",
"config": {
"connection_id": "pi-credential-xxxx",
"topic": "plant/line-2/commands",
"message": "{{ JSON.stringify($json.command) }}",
"retain": false
}
}{
"ok": true,
"data": {
"result": {
"published": true,
"topic": "plant/line-2/commands"
}
},
"port": "out"
}Configuration
-
connection_idstring Required -
Credential for the MQTT broker. Accepts credentials of type `basic-auth` (username + password + host + port), `connection-string` (mqtt:// / mqtts:// URI), or `object` (advanced MQTT config).
-
topicstring Required -
messagestring Required -
Message payload
-
retainboolean Optional -
actionstring Optional
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
connection_id - The broker address comes from the credential config (
url, orhost+port);usernameandpasswordfrom an object secret (basic-auth,object). Aconnection-stringsecret is not parsed: put the URI in the credential configurl. A value starting withmqtt://,mqtts://,ws://orwss://is used as the broker URL itself, without credentials. -
action - Ignored: the node always publishes. Subscribing is not supported.
-
message - Sent as the raw payload. To publish JSON, build the string first, for example
{{ JSON.stringify($json.command) }}.
Output ports
out default The broker accepted the publish.
{
"result": {
"published": true,
"topic": "plant/line-2/commands"
}
}error A required field is missing, the credential cannot be resolved, or the connection or publish failed.
{
"error": "connect ECONNREFUSED 203.0.113.10:1883"
}In expressions
What a later node can read from this node's output with $("MQTT Client").item.json.<path> (write your node's label instead of MQTT Client). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("MQTT Client").item.json.publishedPublish success | — | |
$("MQTT Client").item.json.result | — | |
$("MQTT Client").item.json.result.published | — | |
$("MQTT Client").item.json.result.topic | — |
— Editor: The editor suggests it, but the worker does not return it: it reads as undefined.
— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).
Errors
| Message | Port | Cause and fix |
|---|---|---|
connection_id is required | error | No broker credential selected. |
topic is required | error | The topic is empty in the config and in the incoming payload. |
message is required | error | The message is empty. An empty string also fails: publish at least one character. |
Connection refused: Not authorized | error | The broker rejected the user or password in the credential. |
Input contract
-
connection_idstring Required -
topicstring Required -
messagestring Required -
retainboolean Optional -
actionstring Optional
Output contract
-
publishedboolean Optional -
Publish success
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "io.mqtt",
"name": "MQTT Client",
"category": "io",
"version": "1.0.0",
"description": "Publish to MQTT Broker.",
"capabilities": [
"mqtt",
"iot",
"messaging"
],
"config_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "MQTT Broker Credential",
"description": "Credential for the MQTT broker. Accepts credentials of type `basic-auth` (username + password + host + port), `connection-string` (mqtt:// / mqtts:// URI), or `object` (advanced MQTT config).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"basic-auth",
"connection-string",
"object"
],
"types": [
"mqtt"
]
}
},
"topic": {
"type": "string"
},
"message": {
"type": "string",
"description": "Message payload"
},
"retain": {
"type": "boolean",
"default": false
},
"action": {
"type": "string",
"enum": [
"publish"
],
"default": "publish"
}
},
"required": [
"connection_id",
"topic",
"message"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"topic": {
"type": "string"
},
"message": {
"type": "string"
},
"retain": {
"type": "boolean"
},
"action": {
"type": "string"
}
},
"required": [
"connection_id",
"topic",
"message"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"published": {
"type": "boolean",
"description": "Publish success"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Published",
"description": "Message successfully published",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Publish failed",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"standard-io",
"iot"
],
"tags": [
"iot",
"messaging"
],
"is_stateful": false,
"publisher": {
"identity": "org_link_loom",
"profile": {
"name": "Link Loom",
"verified": true,
"url": "https://me.veripass.com/link-loom",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "MQTT Broker Credential",
"description": "Credential for the MQTT broker. Accepts credentials of type `basic-auth` (username + password + host + port), `connection-string` (mqtt:// / mqtts:// URI), or `object` (advanced MQTT config).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"basic-auth",
"connection-string",
"object"
],
"types": [
"mqtt"
]
}
},
"topic": {
"type": "string"
},
"message": {
"type": "string",
"description": "Message payload"
},
"retain": {
"type": "boolean",
"default": false
},
"action": {
"type": "string",
"enum": [
"publish"
],
"default": "publish"
}
},
"required": [
"connection_id",
"topic",
"message"
]
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"topic": {
"type": "string"
},
"message": {
"type": "string"
},
"retain": {
"type": "boolean"
},
"action": {
"type": "string"
}
},
"required": [
"connection_id",
"topic",
"message"
]
}{
"type": "object",
"properties": {
"published": {
"type": "boolean",
"description": "Publish success"
}
}
}[
{
"port_id": "out",
"label": "Published",
"description": "Message successfully published",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Publish failed",
"is_default": false,
"supports_condition": false
}
]Execution
- Execution
async- Stateful
- No
- Credentials
- Resolved on the server from
connection_id; the secret never reaches the workflow. - Capabilities
mqttiotmessaging- Tags
iotmessaging
Notes and limits
- Publishes with the client's default QoS 0; no QoS option is exposed. A new connection is opened and closed on every run.
- The output contract declares
publishedat the top level; the worker returns it insideresult.
Reviewed against the orchestrator code · 31e874b · 2026-11-26