Skip to main content
Glama

zigbee2mqtt-mcp

CI npm version License: MIT zigbee2mqtt-mcp MCP server Zigbee2MQTT MCP on mcprush

A Model Context Protocol server for administering a Zigbee2MQTT estate.

Most Zigbee integrations already let an assistant turn a light on. This one is for the layer underneath: mesh health, weak links, devices that keep rejoining, stale batteries, firmware updates, pairing, binding, reporting intervals and device options — the things you normally open the Zigbee2MQTT frontend for.

It talks directly to the Zigbee2MQTT MQTT bridge API, so it works regardless of whether you use Home Assistant, Node-RED, openHAB or nothing at all. Tested against Zigbee2MQTT 2.x; several tools depend on bridge endpoints that only exist there, including bridge/health, device/binds/clear and the OTA scheduling topics.

Why this exists

If you already run Home Assistant, your Zigbee devices are exposed there and an assistant can control them. What Home Assistant does not expose is the bridge itself: link quality, mesh topology, interview state, OTA availability, permit_join, device options, bindings and reporting configuration. This server fills exactly that gap.

Related MCP server: music-assistant-mcp-plus

Design

  • No database. Zigbee2MQTT publishes its bridge topics as retained messages, so a fresh subscription yields a complete picture in a few hundred milliseconds. The server keeps only the latest payload per topic in memory.

  • No daemon. Pure stdio. It starts and dies with the MCP session.

  • Correlated requests. Every bridge/request/* carries a transaction id and is matched to its bridge/response/*, so concurrent calls cannot cross wires.

  • Tiered writes. Destructive operations are gated behind a write mode and an explicit confirm argument.

Install

Requires Node.js 22 or newer and network access to the MQTT broker that Zigbee2MQTT uses.

npx zigbee2mqtt-mcp

VS Code / GitHub Copilot

Add to your MCP configuration:

{
  "servers": {
    "zigbee2mqtt": {
      "command": "npx",
      "args": ["-y", "zigbee2mqtt-mcp"],
      "env": {
        "Z2M_MQTT_URL": "mqtt://192.168.1.10:1883",
        "Z2M_MQTT_USERNAME": "mqtt",
        "Z2M_MQTT_PASSWORD": "${input:z2mPassword}"
      }
    }
  }
}

Claude Desktop

{
  "mcpServers": {
    "zigbee2mqtt": {
      "command": "npx",
      "args": ["-y", "zigbee2mqtt-mcp"],
      "env": {
        "Z2M_MQTT_URL": "mqtt://192.168.1.10:1883"
      }
    }
  }
}

Point Z2M_MQTT_URL at your MQTT broker, not at the Zigbee2MQTT frontend port. If Zigbee2MQTT's configuration.yaml says mqtt.server: mqtt://192.168.1.10:1883, use that value verbatim.

Behind a corporate npm proxy? If npm config get registry is not https://registry.npmjs.org/, your proxy's upstream feed may not carry this package. Add an explicit override to the args rather than changing your global registry: "args": ["-y", "--registry", "https://registry.npmjs.org/", "zigbee2mqtt-mcp"]

Configuration

Variable

Default

Purpose

Z2M_MQTT_URL

required

Broker URL. mqtt://, mqtts://, ws://, wss://

Z2M_MQTT_USERNAME / Z2M_MQTT_PASSWORD

–

Broker credentials

Z2M_BASE_TOPIC

zigbee2mqtt

Must match mqtt.base_topic

Z2M_MQTT_CLIENT_ID

zigbee2mqtt-mcp-<pid>

Override if your broker requires a fixed client ID

Z2M_WRITE_MODE

safe

off, safe or full

Z2M_LOG_LEVEL

error

Diagnostics on stderr

Z2M_WEAK_LINK_THRESHOLD

30

Link quality below this is flagged

Z2M_LOW_BATTERY_THRESHOLD

20

Battery percentage below this is flagged

Z2M_STALE_HOURS

24

Hours of silence before a device is stale

Z2M_CONNECT_TIMEOUT_MS

10000

Broker connect timeout

Z2M_REQUEST_TIMEOUT_MS

15000

Default bridge request timeout

Z2M_MQTT_REJECT_UNAUTHORIZED

true

Set false for self-signed TLS

Z2M_MQTT_CA / _CERT / _KEY

–

Paths to TLS material

Write modes

Tools above the active tier are not registered at all, so a model cannot reach for them.

Mode

Exposes

off

Read-only tools

safe

Default. Read plus non-destructive writes: pairing, options, rename, configure, interview, binding, reporting, groups, state

full

Everything, including device removal, OTA flashing, Touchlink and bridge restart

Irreversible tools (z2m_remove_device, z2m_ota_update, z2m_touchlink, z2m_restart_bridge, z2m_set_bridge_options) additionally require confirm: true on every call. Three safe tools reduce state rather than only adding to it, so they are annotated destructive: z2m_rename_device, z2m_manage_group and z2m_bind. Their reducing actions also require confirm: true — z2m_manage_group (remove, remove_all_members) and z2m_bind (clear). z2m_rename_device is annotated destructive because it breaks anything referencing the old name, but stays unconfirmed since renaming back restores it.

Every tool also advertises MCP tool annotations so a client can decide what may run without prompting:

Annotation

Meaning here

readOnlyHint: true

The nine read tools. They never change the network.

destructiveHint: true

z2m_remove_device, z2m_ota_update, z2m_touchlink, z2m_restart_bridge, z2m_set_bridge_options, plus z2m_rename_device, z2m_manage_group and z2m_bind

idempotentHint

True where repeating the call has no additional effect

openWorldHint: true

Always — every tool reaches a live Zigbee network

Annotations describe the tool, not the tier: a safe tool can still be destructive. The tier decides what is registered, the annotation tells the client what to ask about.

Opt in to the destructive tier only when you want it:

"env": { "Z2M_WRITE_MODE": "full" }

Tools

Read

Tool

Purpose

z2m_connection_status

Broker reachability, TLS posture and cached message counts — reports instead of throwing, even when nothing is configured yet

z2m_bridge_info

Version, coordinator, channel, PAN ID, permit_join, restart_required, runtime stats

z2m_list_devices

Filter and sort devices by type, availability, link quality, battery, pending update

z2m_get_device

Exposes, settable options, endpoints, bindings, configured reportings, current state

z2m_health_report

Whole-estate audit in one call

z2m_network_map

Mesh topology with parent, depth, link quality, orphan detection

z2m_list_groups

Groups, members and scenes

z2m_get_logs

Bridge logs and lifecycle events, buffered or watched live

z2m_coordinator_check

Routers missing from the coordinator's memory (Texas Instruments adapters only)

Safe writes

z2m_check_updates, z2m_permit_join, z2m_set_device_options, z2m_rename_device, z2m_configure_device, z2m_interview_device, z2m_set_state, z2m_manage_group, z2m_bind, z2m_configure_reporting

Full writes

z2m_remove_device, z2m_ota_update, z2m_restart_bridge, z2m_set_bridge_options, z2m_touchlink

Data availability caveats

Some fields depend on your Zigbee2MQTT configuration. The server detects what is available and tells you rather than silently returning nothing.

Field

Requires

If missing

last_seen

advanced.last_seen set to e.g. ISO_8601 (default is disable)

Staleness checks are skipped and a hint is returned

availability

availability.enabled: true

Offline detection is skipped and a hint is returned

linkquality, battery, update

Live device traffic — Zigbee2MQTT does not retain device state topics

Pass collect_seconds to listen briefly, or use z2m_network_map for authoritative link quality

z2m_coordinator_check

An adapter that supports coordinator backups (TI zStack, Silicon Labs EmberZNet; not deCONZ or ZiGate)

Returns an error on unsupported adapters; z2m_bridge_info reports the expectation

Security notes

  • The broker URL may carry credentials (mqtt://user:pass@host). They are redacted everywhere the URL is echoed back to a model or written to a log, and error text from the MQTT client is scrubbed before it leaves the process. Zigbee2MQTT logs its own broker URL at startup, so lines relayed by z2m_get_logs are scrubbed too.

  • safe mode can actuate anything on the mesh via z2m_set_state, including locks, valves and sirens. Use off if that matters.

  • z2m_permit_join opens the network to any nearby Zigbee device for the duration of the window. It is in safe because it is routine and reversible, but it is a security boundary.

Example prompts

  • "Is my Zigbee network healthy?"

  • "Which devices have the weakest signal?"

  • "Which batteries need replacing?"

  • "Any firmware updates available?"

  • "Open the network for pairing via the kitchen router for two minutes."

  • "This sensor stopped reporting temperature — fix it."

  • "Bind the hallway remote to the hallway light so it works if the bridge is down."

Development

npm install
npm run build
npm run watch

# Unit tests. No broker required; they run on every push across Node 22 and 24.
npm test

# Manual smoke test against a real instance
Z2M_MQTT_URL=mqtt://192.168.1.10:1883 node scripts/smoke.mjs
Z2M_MQTT_URL=mqtt://192.168.1.10:1883 node scripts/smoke.mjs z2m_list_devices '{"only_problems":true}'

# Sequential read-after-write test. Renames a device and creates a group, then
# restores both, including on failure. Set Z2M_TEST_DEVICE to pick the device,
# or ROUNDTRIP_GROUPS_ONLY=1 to skip the rename.
Z2M_MQTT_URL=mqtt://192.168.1.10:1883 node scripts/roundtrip.mjs

Note that an MCP server may receive requests concurrently. When testing ordering, await each response before sending the next, as roundtrip.mjs does — piping several requests at once will produce misleading results.

The unit tests cover health classification, capability detection, topic routing, write-mode gating and configuration parsing. They are broker-free by design, so anything that needs a live mesh belongs in scripts/ instead.

A passing suite only proves the tests ran, so scripts/mutate.mjs breaks the source one change at a time and checks the suite notices each one:

node scripts/mutate.mjs          # every mutant
node scripts/mutate.mjs redact   # only mutants whose name matches

A surviving mutant marks behavior nothing actually tests, and exits non-zero. Add a mutant alongside any fix worth keeping fixed.

Releases are tag-driven: npm version <patch|minor|major> then git push --follow-tags. CI publishes to npm with provenance, rewrites server.json's version from the tag and publishes to the MCP Registry, then creates the GitHub release. The version committed in server.json is therefore not authoritative — the tag is.

Safety

This server can remove devices from your network and flash firmware. Both are irreversible and OTA failures can brick hardware. Those tools live in the full tier, which is not enabled by default — you must opt in with Z2M_WRITE_MODE=full. Broker credentials are read from the environment and never logged.

Status

Early release. Developed and tested against a 50-device EmberZNet estate on Zigbee2MQTT 2.12.x. Other adapters (Texas Instruments, deCONZ/ConBee, zStack), TLS and WebSocket brokers, and large estates are unverified. Bug reports and pull requests are very welcome — please include your adapter type and Zigbee2MQTT version from z2m_bridge_info.

License

MIT

Available Tools

17 tools
z2m_bindA

Bind or unbind clusters between two devices, or between a device and a group. Binding lets a remote control a light directly over Zigbee without a round trip through the coordinator, so it keeps working even if the bridge is down. Reversible with action='unbind'; action='clear' removes all binds from the source device at once. Append /ENDPOINT to target a specific endpoint, e.g. 'my_remote/left' — check z2m_get_device endpoints first. Both devices must be awake.

Inputs: from (required), action (required), to, clusters.

z2m_bridge_infoA
Read-onlyIdempotent

Get Zigbee2MQTT bridge status: version, coordinator type and firmware, Zigbee channel and PAN ID, permit_join state, log level, whether a restart is required, and host OS/memory. Read-only. Start here to understand the estate, then use z2m_health_report for problems or z2m_list_devices for individual devices. Returns a JSON object; set include_config only if you need the full Zigbee2MQTT configuration, which is large.

Inputs: include_config.

z2m_check_updatesA
Idempotent

Actively query devices for available OTA firmware updates. Changes no configuration, but it does put real traffic on the Zigbee network and can take a minute per device. Without arguments it checks every mains-powered router. Prefer z2m_health_report for a passive answer at no network cost, and use this only when you need a fresh check. Follow with z2m_ota_update to actually flash.

Inputs: device, timeout_ms.

z2m_configure_deviceA
Idempotent

Re-run a device's configuration routine (bindings and attribute reporting). Use when a device stopped reporting values. Battery devices must be woken immediately before calling this, or it fails after a timeout. Use z2m_interview_device instead when Zigbee2MQTT does not know the device's capabilities at all, and z2m_configure_reporting to change one specific attribute rather than re-running everything.

Inputs: device (required).

z2m_configure_reportingA
Idempotent

Configure how often a device reports an attribute. Tightening intervals improves responsiveness; loosening them saves battery. Set maximum_report_interval to 65535 to disable reporting. Battery devices must be woken immediately before calling this, and not all devices support the command. Use z2m_get_device to see existing configured_reportings, and z2m_configure_device to re-run the whole default configuration instead of one attribute.

Inputs: device (required), cluster (required), attribute (required), maximum_report_interval (required), +3 more.

z2m_get_deviceA
Read-onlyIdempotent

Get full detail for one device: current state, exposed properties, configurable device options with their schema, endpoints, bindings and configured reportings. Read-only. Call this before z2m_set_device_options, z2m_bind or z2m_configure_reporting to discover valid values. Use z2m_list_devices instead when you want many devices or do not know the exact name.

Inputs: device (required), include_raw.

z2m_get_logsA
Read-onlyIdempotent

Read Zigbee2MQTT bridge logs and lifecycle events (device_joined, device_interview, device_leave, device_announce). Read-only. Returns buffered history by default; watch_seconds instead blocks for that many seconds collecting new lines. Logs are only captured while this server is connected, so history may be empty on a fresh start — use watch_seconds then. Use to diagnose pairing failures and rejoin loops; prefer z2m_health_report to find which devices are affected in the first place.

Inputs: level, limit, contains, watch_seconds, +1 more.

z2m_health_reportA
Read-onlyIdempotent

Audit the whole Zigbee estate in one call and return everything that needs attention: offline devices, weak links, stale devices, low batteries, failed or pending interviews, unsupported devices, disabled devices, pending OTA updates, and devices that keep rejoining or changing network address. Read-only and generates no Zigbee traffic, so prefer it over z2m_check_updates and z2m_network_map for routine checks. Use this to answer 'is my Zigbee network healthy?'. Returns {bridge, totals, capabilities, issues, hints}; an empty issues object means nothing is wrong. Note that collect_seconds makes the call wait for that many seconds before answering.

Inputs: collect_seconds.

z2m_interview_deviceA
Idempotent

Re-interview a device so Zigbee2MQTT re-reads its endpoints, clusters and basic attributes. The device may be briefly unavailable while this runs, and battery devices must be awake. Useful after a firmware upgrade adds functionality, or to recover a device stuck in a failed interview — check interview_state via z2m_get_device first. Use z2m_configure_device instead when the interview succeeded but reporting stopped working.

Inputs: device (required).

z2m_list_devicesA
Read-onlyIdempotent

List Zigbee devices with administrative detail: type, model, vendor, power source, link quality, battery, availability, last_seen, interview state and pending OTA updates. Read-only, though collect_seconds will wait before answering. Use this to answer 'which devices are offline' or 'which have the weakest signal'. Prefer z2m_health_report for a prioritised summary of everything wrong at once, and z2m_get_device when you need one device's exposes, options or bindings. Returns {total, returned, capabilities, devices[]}.

Inputs: type, limit, search, sort_by, +4 more.

z2m_list_groupsA
Read-onlyIdempotent

List Zigbee groups with their members and scenes. Read-only. Use z2m_manage_group to change groups, and z2m_list_devices for individual devices. Returns {total, groups[]}; an empty list means no groups are defined.

Inputs: no named parameters.

z2m_manage_groupA

Create or remove groups, rename them, and add or remove device members. Groups let a single Zigbee multicast control many devices, which is far more responsive than commanding each device in turn. Removing a group does not affect the devices themselves, but fails if a member is unreachable unless force is set — with force the device keeps the group membership internally. Use z2m_list_groups to inspect groups first, and z2m_set_state to control a group once created.

Inputs: group (required), action (required), id, force, +2 more.

z2m_network_mapA
Read-onlyIdempotent

Scan the Zigbee mesh topology and return per-device parent, depth, link quality and route count, plus orphaned or weakly-attached devices. WARNING: the scan makes the network less responsive and can take 10 seconds to several minutes depending on estate size. Run it deliberately, not routinely, and prefer z2m_health_report or z2m_list_devices when you only need per-device link quality. Returns {node_count, link_count, orphans, weak, nodes[]} unless raw is set.

Inputs: raw, timeout_ms, include_routes.

z2m_permit_joinA
Idempotent

Open or close the network for new devices to join. While open, any nearby Zigbee device may join, so keep the window short and close it with time=0 when finished. Optionally scope joining to a single router, which is the recommended way to pair a device into a specific part of the mesh. Use z2m_bridge_info to see whether joining is currently open.

Inputs: time (required), device.

z2m_rename_deviceA

Rename a device's friendly_name. Renaming changes its MQTT topic, so anything referencing the old name (automations, dashboards, scripts) breaks until updated — this is reversible only by renaming back. Set homeassistant_rename to also rename the Home Assistant entity. Use z2m_set_device_options for behaviour changes that do not affect the topic.

Inputs: device (required), new_name (required), homeassistant_rename.

z2m_set_device_optionsA
Idempotent

Change Zigbee2MQTT device options such as transition, retain, debounce, temperature_precision or calibration offsets. Options are merged, not replaced, and persist in the Zigbee2MQTT configuration. Call z2m_get_device first to see settable_options for that device. Use z2m_set_state to change what a device is doing, and z2m_set_bridge_options for bridge-wide settings. The response reports whether a bridge restart is required.

Inputs: device (required), options (required).

z2m_set_stateA

Send a state command to a device or group, e.g. {"state":"ON"} or {"brightness":128}. Physically changes what the device is doing, and is reversible by sending the opposite command. mode='get' instead requests a value without changing anything. The command is published without waiting for the device, so success here means the message was sent, not that the device acted — read z2m_get_device afterwards to confirm. Consult z2m_get_device exposes for valid properties.

Inputs: device (required), payload (required), mode.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 17 tools

    Disambiguation5/5

    Each tool targets a distinct resource and action, with cross-references clarifying when to use similar tools like configure_device vs configure_reporting vs interview_device. The read-only tools (list_devices, get_device, health_report, network_map) have clearly differentiated scopes.

    Naming Consistency4/5

    All tools share the z2m_ prefix and use clear descriptive names, but a few read-only tools (z2m_bridge_info, z2m_health_report, z2m_network_map) use noun phrases rather than the verb_noun pattern seen in most other tools (list, get, set, rename, configure). This is a minor deviation from an otherwise predictable convention.

    Tool Count4/5

    At 17 tools, the set is slightly above the typical 3-15 range, but the Zigbee domain is complex and each tool covers a genuinely distinct operation. No tool feels redundant, and the count is justified by the breadth of device, group, binding, and network management tasks.

    Completeness4/5

    The tool set covers the major lifecycle operations: pairing via permit_join, listing and inspecting devices, changing state and options, configuring reporting, managing groups and bindings, OTA updates, health checks, and logs. The most notable gap is the lack of a device removal/delete tool, and there is no bridge restart or firmware update tool, but these are minor for typical automation scenarios.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      MCP server for full Home Assistant control, enabling AI agents to manage dashboards, automations, files, apps, entities, and more via REST API, WebSocket, and SSH.
      66
      151 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      An MCP server that connects to Z-Wave JS UI's WebSocket to expose controller, node, and configuration information as tools for AI assistants to manage Z-Wave networks.
      24
      1
      MIT