MCP MQTT Light Controller
Provides tools for controlling smart lights via MQTT, including turning lights on/off and adjusting brightness levels (0-100) by publishing control messages to MQTT topics.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP MQTT Light Controllerturn on the living room lights"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-mqtt-light
一个基于 MCP 的 MQTT 智能灯控制示例项目,包含:
mqtt_light_controller.py:提供 MCP 工具(开关灯、调亮度),通过 MQTT 发布控制消息mcp_pipe.py:把 MCP 的 stdio 与远端 WebSocket 端点进行双向转发,并支持按配置启动多个 MCP server
环境要求
Python 3.10+(建议)
Related MCP server: Home Assistant MCP
安装
python -m pip install -r requirements.txt配置
1) MCP Pipe 连接端点
mcp_pipe.py 通过环境变量 MCP_ENDPOINT 连接到 WebSocket 端点:
Linux/macOS:
export MCP_ENDPOINT="ws://localhost:8765"Windows PowerShell:
$env:MCP_ENDPOINT = "ws://localhost:8765"2) MQTT 连接参数(可选)
mqtt_light_controller.py 支持以下环境变量(也可在 .env 中设置):
MQTT_BROKER:MQTT Broker 地址(默认:b11f17c5.ala.cn-hangzhou.emqxsl.cn)MQTT_PORT:端口(默认:8883,TLS)MQTT_CONTROL_TOPIC:控制主题(默认:smartlight/control)MQTT_STATUS_TOPIC:状态主题(默认:smartlight/status)MQTT_CLIENT_ID:客户端 ID(默认:mcp-light-controller)MQTT_USER/MQTT_PASSWORD:认证信息(默认空)
注意:当前 TLS 配置处于“忽略证书验证”的模式,适合本地/测试环境;生产环境建议启用证书校验。
运行
使用配置启动 MCP Server(推荐)
仓库内置 mcp_config.json 示例配置。
启动所有启用的 server:
python mcp_pipe.py只启动某一个 server(配置名或脚本路径均可):
python mcp_pipe.py mqtt-light-controller或:
python mcp_pipe.py mqtt_light_controller.py直接启动 mqtt_light_controller(调试用)
python mqtt_light_controller.py该进程会启动 MCP stdio server,并在首次运行时连接 MQTT Broker。
只想验证 MQTT 订阅能否收到消息(不启动 MCP stdio):
python mqtt_light_controller.py --mqtt-only提供的工具
mqtt_light_controller.py 暴露的 MCP 工具:
control_light(light_state: str):on/offadjust_brightness(brightness: int):亮度0-100
测试
本项目使用标准库 unittest 做基础测试:
python -m unittest discover -s tests -v也可以做一次基础语法/导入检查:
python -m compileall .This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Control your Tesla from your AI assistant - climate, charging, access, and security.
Smart home product intelligence: 1,080+ products with expert consensus scores and compatibility.
Manage your IoT device fleet directly from Claude. Create device templates with datastreams and events, provision new devices, read live sensor data, and control outputs. The Blynk connector integrates with the Blynk IoT platform, enabling direct configuration and monitoring of connected devices and infrastructure.
Control a Loxone Miniserver smart home: lights, blinds, climate, scenes and energy.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables LLM agents to interact with MQTT brokers through publish, subscribe, and query operations. Provides fine-grained topic permissions with wildcard support for secure IoT device communication and sensor data access.1BSD 3-Clause
- AlicenseNot gradedqualityDmaintenanceEnables control and monitoring of Home Assistant smart home devices through MCP protocol. Automatically manages authentication tokens and provides simplified tools for device discovery, switch control, and light brightness adjustment.MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to control Philips Hue smart lighting systems, including individual lights, groups, scenes, brightness, and color adjustments through natural language commands.-
- AlicenseNot gradedqualityDmaintenanceConnects AI assistants to MQTT brokers for smart home automation and IoT device control, enabling topic discovery, sensor reading, command sending, and event monitoring.2MIT