Yeelight MCP Server Natural Language Smart Lighting Control
Control Yeelight smart devices with natural language using the MCP server for seamless, efficient human-AI lighting management.
npx -y @Yeelight/yeelight-iot-mcpOverview
Yeelight MCP Server is a lightweight bridge that lets developers control Yeelight smart lighting using natural language and structured tool calls. It implements a Model Context Protocol (MCP) interface so language models, chat agents, or other automation systems can request device discovery, read device state, and execute lighting actions (turn on/off, set color, set brightness, etc.) in a predictable, machine-friendly way.
The server translates between human-friendly prompts and concrete device operations, exposing RESTful endpoints and a tools/schema surface for LLM agents. This makes it easier to build conversational assistants, automation workflows, or agent-driven scenes that manage Yeelight devices without deep knowledge of the device APIs or network discovery mechanics.
Features
- Natural language → actionable device commands via MCP-compatible endpoints
- REST API for device discovery, state inspection, and action execution
- Tool/schema metadata for LLM agents (tool signatures, parameter schemas)
- Local and containerized deployment options
- Example payloads and sample integrations for quick prototyping
- Extensible mapping layer to add or override device actions and business rules
Installation / Configuration
Prerequisites (typical):
- Docker (optional)
- Node.js >= 16 or Python 3.9+ depending on chosen runtime (check repository)
- Network access to Yeelight devices (same LAN or cloud credentials)
Clone the repository:
Run with Docker (recommended for isolation):
# build (if Dockerfile is present)
# run with default port 8080 (example)
Run locally (example Node.js flow — adjust if repository uses a different runtime):
# install dependencies
# copy example env and edit credentials
# edit .env to set YEELIGHT credentials, AUTH_TOKEN, and MCP_PORT
# start server
Example .env variables (table):
| Variable | Purpose |
|---|---|
| AUTH_TOKEN | Bearer token for API access to MCP endpoints |
| MCP_PORT | HTTP port the server listens on (e.g., 8080) |
| YEELIGHT_DISCOVERY | Enable local LAN device discovery (true/false) |
| YEELIGHT_CLOUD_TOKEN | Cloud token if using Yeelight Cloud APIs |
| LOG_LEVEL | debug/info/warn/error |
Note: Always protect AUTH_TOKEN and any cloud credentials. If exposing the server to remote LLMs, use HTTPS and an access control layer.
Available Resources
The server exposes a small set of HTTP endpoints (example routes; check the repo for exact paths):
- GET /health
- Returns server health and version.
- GET /devices
- Lists discovered/registered Yeelight devices with IDs and capabilities.
- POST /mcp
- MCP entrypoint: accepts model prompts or structured tool calls and returns structured results/action proposals.
- POST /execute
- Execute a validated device action (turn on/off, set brightness/color, etc.).
- GET /schema
- Returns tool signatures and parameter schemas for LLMs and agent frameworks.
Example device object (typical response):
Use Cases
Conversational assistant: “Dim the living room lights to 30% for movie time.”
- Client: send natural language prompt to /mcp.
- Server: returns an action proposal:
- Client: POST the proposal to /execute to apply it.
Scheduled scene creation:
- User: “Every evening at 9pm, set the hallway light to warm white and 50%.”
- Flow: /mcp suggests a structured schedule + actions; your scheduler stores the returned actions and calls /execute at the appointed times.
Multi-device orchestration:
- Prompt: “Turn off all lamps in the kids’ room and set night-light on at 10%.”
- Server discovers matching devices via GET /devices, synthesizes multiple tool calls, and returns an atomic execution plan to be applied sequentially.
Safety-aware automation:
- The mapping layer can validate actions (e.g., prevent blinding brightness overnight), returning warnings or requiring explicit confirmation before /execute.
Examples (curl)
Discover devices:
Request an MCP action from natural language:
Execute an action:
Next Steps
- Inspect the repository for sample agent integrations and test scripts.
- Wire the server into an LLM agent framework (make sure to supply /schema/tool metadata to the model).
- Add custom validation or policies to the mapping layer for safer automations.
Repository and source: https://github.com/Yeelight/yeelight-iot-mcp