Labsco
MCP SERVER

Coreflux MQTT MCP Server

by CorefluxCommunity

Publish, subscribe and read MQTT topics on a Coreflux broker, and create the rules, models, actions and routes that automate what happens next.

Network, Endpoint & Fleet Management
Summary
MQTT plumbing and Coreflux automation from the same connection.

Most MQTT servers stop at publish and subscribe; this one also installs and removes the broker's own rules, models, actions and routes, so an agent can go from watching a sensor topic to writing the automation that reacts to it. LOT is the language it writes, and two tools exist to draft and vet it.

What it is

An MCP server for Coreflux MQTT brokers. One half is plain MQTT: connect, publish, subscribe, monitor a topic and read buffered messages. The other half drives Coreflux itself — the rules, models, actions and routes written in LOT, the broker's Logic Object Tree language — with a Copilot-backed tool that drafts LOT from a plain-language description and another that checks a snippet before you install it.

What you get
  • Messages published to a topic with a QoS level and a retain flag, and JSON payloads detected or forced — `mqtt_publish`
  • Subscriptions with wildcards, the current subscription list, and buffered messages read back per topic or across all of them — `mqtt_subscribe`, `mqtt_unsubscribe`, `mqtt_list_subscriptions`, `mqtt_read_messages`
  • A single retained value read once, or a topic watched for a window — `mqtt_read_topic_once`, `mqtt_monitor_topic`
  • Broker connections configured, retried and diagnosed at run time, so a bad host or credential is fixed without restarting the server — `setup_mqtt_connection`, `mqtt_connect`, `reconnect_mqtt`, `check_broker_health`, `get_connection_status`
  • LOT rules, models, actions and routes added and removed individually, plus bulk clears for each kind — `add_rule`, `add_model`, `add_action`, `add_route`, `remove_rule`, `remove_model`, `remove_action`, `remove_route`, `remove_all_models`, `remove_all_actions`, `remove_all_routes`
  • Actions discovered on the broker and executed by name — `list_discovered_actions`, `run_action`
  • LOT drafted from a description, and a snippet checked for syntax and practice before it goes live — `request_lot_code`, `verify_lot_snippet`, `lot_diagnostic`
  • A component-by-component health check across broker connectivity, message processing and API availability — `comprehensive_health_check`
Requirements

Python 3.11 or higher and reach to a Coreflux MQTT broker. Credentials go in the environment: `MQTT_BROKER` and `MQTT_PORT` (1883 plain, 8883 with TLS), `MQTT_USER` and `MQTT_PASSWORD`, and `MQTT_USE_TLS` with `MQTT_CA_CERT`, `MQTT_CERT_FILE` and `MQTT_KEY_FILE` when certificates are in play. `DO_AGENT_API_KEY` is the separate Coreflux Copilot key and only the LOT generation tool needs it. Run `python setup_assistant.py` to fill all of that in interactively, or bring the Docker Compose file up. The server starts even when the broker is unreachable, so a failed connection is something you diagnose through the tools rather than a startup crash.