add_ruleLABSCO 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.
Setup effort
Build from source — git clone https://github.com/CorefluxCommunity/Coreflux-MQTT-MCP-Server.git
USE CASES
Working out why a device stopped reporting
Check whether the broker connection is healthy at all, then subscribe to the device's topic tree with a wildcard and read what has actually arrived in the buffer. Connection faults come back with the state and the reason rather than a silent empty result.
Writing an automation rule without knowing LOT
Describe the behaviour you want in plain language, get LOT back, run it past the snippet check, and install it on the broker as an action or model only once it passes.
Auditing what automation a broker is already running
List the actions the server has discovered on the broker, run one to see what it does, and remove the ones nothing depends on any more — individually, or clearing a whole class at once.
Pointing the server at a different broker mid-session
Supply a new host, port, credentials and TLS choice in the call itself, test that the broker answers, and carry on — no config file edit and no client restart.
Sending a command to a device and confirming it landed
Publish the command with the QoS and retain flag the device expects, then read the status topic once to see the value it left behind.
29 tools
Listed in project docs. Your client may show a different list.
remove_ruleadd_modelremove_modelremove_all_modelsadd_actionrun_actionremove_actionremove_all_actionsadd_routeremove_routeremove_all_routessetup_mqtt_connectionmqtt_connectreconnect_mqttcheck_broker_healthmqtt_publishmqtt_subscribemqtt_unsubscribemqtt_list_subscriptionsmqtt_read_messagesmqtt_monitor_topicmqtt_read_topic_oncecomprehensive_health_checkget_connection_statuslist_discovered_actionsrequest_lot_codeverify_lot_snippetlot_diagnosticBEFORE YOU INSTALL
What to know first
Tools you get
29 tools named in the project's documentation. The README summary names publish_to_coreflux, get_broker_info and copilot_assist, which appear to be older names for mqtt_publish, get_connection_status or check_broker_health, and request_lot_code. The AI-assistance tools need a Coreflux Copilot API key.
Requires
- Python 3.11 or later
- MQTT_PASSWORD in your environment
Where it runs
The documented client runs the server on your machine.
INSTALLATION
Connect your client
You clone this one yourself.
Server setup
Prerequisites: Python 3.11+, access to a Coreflux MQTT broker, optionally a Coreflux Copilot API key
git clone https://github.com/CorefluxCommunity/Coreflux-MQTT-MCP-Server.git
cd Coreflux-MQTT-MCP-Server
pip install -r requirements.txt
python setup_assistant.py # Interactive configurationOr configure by hand: copy .env.example to .env and edit it
Add the mcpServers block to claude_desktop_config.json, with the path to server.py in this folder, then restart Claude Desktop
MCP Clients
Claude Desktop
{
"mcpServers": {
"coreflux": {
"command": "python",
"args": [
"<YOUR_PATH_TO_SERVER>"
],
"env": {
"MQTT_BROKER": "<YOUR_MQTT_BROKER>",
"MQTT_PORT": "8883",
"MQTT_USER": "<YOUR_MQTT_USER>",
"MQTT_PASSWORD": "<YOUR_MQTT_PASSWORD>",
"MQTT_USE_TLS": "true",
"DO_AGENT_API_KEY": "<YOUR_DO_AGENT_API_KEY>"
}
}
}
}