ZigBee2MQTT MCP Server
Enables AI assistants to discover, monitor, and control ZigBee smart home devices through ZigBee2MQTT. Provides intelligent device discovery, state monitoring, and automation integration with support for remote deployment.
README
ZigBee2MQTT MCP Server
A Model Context Protocol (MCP) server for ZigBee2MQTT that provides intelligent device discovery and control for AI assistants.
🌐 Remote-Capable! This MCP server can run on a remote server (e.g., where your MQTT broker runs) and you can access it from your Mac via HTTP. See REMOTE-SETUP.md for details!
Deployment Options
- Local (stdio): Container runs on your Mac, accessed via stdio
- Remote (HTTP/SSE): Container runs on server, accessed via HTTP → REMOTE-SETUP.md
Overview
This MCP server connects to your MQTT broker and automatically analyzes all ZigBee devices connected via ZigBee2MQTT. It learns the structure and capabilities of each device and makes this information available to AI assistants through MCP tools.
Core Features
- 🔍 Intelligent Schema Discovery: Automatically learns the structure and capabilities of your devices
- 💾 Compact Data Storage: Stores only metadata and schemas, not complete message history
- 📚 Zigbee2MQTT Documentation: Direct access to official device documentation
- 🐳 Docker-Ready: Easy deployment with Docker Compose
- 🌐 Remote-Capable: Runs on server, access via HTTP/SSE from anywhere
- 🔒 Security: Optional API key authentication
- 🔌 Retained Messages: Uses MQTT retained messages for instant access to device information
- 🏠 Home Automation: Perfect for n8n, Home Assistant and other automation tools
What is Stored?
✅ Device Metadata (Name, model, manufacturer) ✅ Field Schemas (Which fields does a device have? What data types?) ✅ Capabilities (Can dim, change color, measure temperature, etc.) ✅ Current State (Only last value, no history)
❌ Not Stored: Complete message history, time-based sensor data
Estimated Database Size: ~1-2 MB for 100 devices (instead of GB with full history!)
Prerequisites
- Node.js 20+ or Docker
- Running ZigBee2MQTT installation
- MQTT Broker (e.g., Mosquitto)
Installation
Option 1: Docker (Recommended)
-
Clone repository
git clone <repository-url> cd zigbeeMCP -
Create environment file
cp .env.example .env -
Configure .env
MQTT_BROKER_URL=mqtt://192.168.1.100:1883 MQTT_USERNAME=your_user MQTT_PASSWORD=your_password MQTT_BASE_TOPIC=zigbee2mqtt DB_PATH=/data/zigbee2mqtt.db # Log Level: debug, info, warn, error, silent # Recommended: error (minimal output) LOG_LEVEL=error -
Start container
docker compose up -d -
View logs
docker compose logs -f
Option 2: Local Installation
-
Install dependencies
npm install -
Compile TypeScript
npm run build -
Start
npm start
MCP Configuration
Claude Desktop
Add the following to Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"zigbee2mqtt": {
"command": "docker",
"args": [
"exec",
"-i",
"zigbee2mqtt-mcp",
"node",
"dist/index.js"
]
}
}
}
Or for local installation:
{
"mcpServers": {
"zigbee2mqtt": {
"command": "node",
"args": ["/path/to/zigbeeMCP/dist/index.js"],
"env": {
"MQTT_BROKER_URL": "mqtt://localhost:1883",
"MQTT_BASE_TOPIC": "zigbee2mqtt",
"DB_PATH": "/path/to/zigbee2mqtt.db"
}
}
}
}
Available Tools
The MCP server provides the following tools:
1. list_devices
Lists all ZigBee devices.
Example:
Show me all my ZigBee devices
2. get_device_info
Shows detailed information about a specific device.
Parameters:
device: Device friendly name or IEEE address
Example:
Show me details for the living room lamp
3. find_devices
Searches for devices by name, model, or description.
Parameters:
query: Search term
Example:
Find all lamps in the living room
4. get_device_state
Shows the current state of a device.
Parameters:
device: Device friendly name or IEEE address
Example:
Is the living room lamp on?
5. send_command
Sends a command to a device.
Parameters:
device: Device friendly name or IEEE addresscommand: Command as JSON object
Example:
Turn on the living room lamp
Set brightness to 50%
6. find_by_capability
Finds all devices with a specific capability.
Parameters:
capability: Capability type (e.g.,on_off,brightness,temperature_sensor)
Example:
Show all dimmable devices
Which devices can measure temperature?
Common Capabilities:
on_off- Can be turned on/offbrightness- Dimmablecolor_temperature- Color temperature adjustablecolor- Color changeabletemperature_sensor- Temperature sensorhumidity_sensor- Humidity sensorcontact_sensor- Contact sensoroccupancy_sensor- Motion sensor
7. get_integration_info
Provides integration information for n8n or other tools.
Parameters:
device: Device friendly name or IEEE address
Example:
How can I integrate the living room lamp into n8n?
8. get_stats
Shows statistics about the ZigBee network.
Example:
How many devices are connected?
9. get_device_documentation
Provides links to official Zigbee2MQTT documentation for a specific device.
Parameters:
device: Device friendly name or IEEE address
Example:
Show me the documentation for my Philips Hue lamp
How can I best control the "living_room_lamp" device?
What can my IKEA TRADFRI switch do?
Returns:
- Link to device documentation on zigbee2mqtt.io
- Model and vendor information
- Known capabilities of the device
- Direct link to search for the specific model
10. get_recent_devices
Lists devices that were added to the ZigBee network within the last N days.
Parameters:
days: Number of days to look back (default: 7)
Example:
Which devices were added in the last week?
Show me all new devices since yesterday
Which devices have I paired in the last 30 days?
Returns:
- Number of days
- Number of devices found
- List of devices with:
- Name, model, manufacturer
created_at: Timestamp when device was addedlast_seen: Timestamp of last messageupdated_at: Last update
Note: All timestamps are Unix timestamps (milliseconds since 1970-01-01).
Usage Examples
With Claude Desktop
User: "Is there a lamp in the living room?"
Claude: [Uses find_devices with query="living room"]
→ "Yes, I found 'living_room_ceiling_lamp' (Philips Hue White)"
User: "Turn it on"
Claude: [Uses send_command with {"state": "ON"}]
→ "The lamp has been turned on"
User: "How can I use this lamp in n8n?"
Claude: [Uses get_integration_info]
→ "You can use these MQTT topics:
- Read: zigbee2mqtt/living_room_ceiling_lamp
- Write: zigbee2mqtt/living_room_ceiling_lamp/set
Example payload: {"state": "ON", "brightness": 200}"
User: "What can my IKEA TRADFRI switch do?"
Claude: [Uses get_device_documentation]
→ "Your IKEA TRADFRI switch (Model: E1743) supports:
- Capabilities: button, battery
- Documentation: https://www.zigbee2mqtt.io/supported-devices/#s=E1743
- There you'll find all button events and MQTT payloads!"
User: "Which devices did I add in the last week?"
Claude: [Uses get_recent_devices with days=7]
→ "3 devices were added in the last 7 days:
1. living_room_outlet (OSRAM Smart+ Plug) - 2 days ago
2. bathroom_sensor (Aqara Temperature Sensor) - 5 days ago
3. hallway_lamp (Philips Hue) - 6 days ago"
Architecture
┌─────────────────────┐
│ AI Assistant │
│ (Claude Desktop) │
└──────────┬──────────┘
│ MCP Protocol (stdio)
┌──────────▼──────────┐
│ MCP Server │
│ - Tools Handler │
│ - Response Gen. │
└──────────┬──────────┘
│
┌──────────▼──────────┐ ┌──────────────────┐
│ SQLite Database │ │ MQTT Listener │
│ - Devices │ │ - Subscribe All │
│ - Fields │◄─────┤ - Process Msgs │
│ - Capabilities │ │ - Discovery │
│ - Current State │ └────────┬─────────┘
└─────────────────────┘ │
│
┌───────▼────────┐
│ MQTT Broker │
│ (Mosquitto) │
└───────┬────────┘
│
┌───────▼────────┐
│ ZigBee2MQTT │
│ - ZigBee Net │
│ - Devices │
└────────────────┘
Troubleshooting
Container won't start
# Check logs
docker compose logs
# Rebuild container
docker compose down
docker compose build --no-cache
docker compose up -d
MQTT connection fails
- Check MQTT broker URL in
.env - If broker runs on host, use
mqtt://host.docker.internal:1883 - Check firewall settings
No devices found
- Check if ZigBee2MQTT is running:
zigbee2mqtt/bridge/stateshould be "online" - Check base topic in
.env- must match ZigBee2MQTT config - Check MQTT permissions
Database errors
# Reset database
docker compose down
rm -rf data/
docker compose up -d
Too many logs in Claude Desktop
The MCP server uses a configurable logging system:
Adjust in .env:
# Minimal output (recommended)
LOG_LEVEL=error
# For debugging
LOG_LEVEL=debug
Log Levels:
silent- No outputerror- Only errors (recommended for Claude Desktop)warn- Warnings + errorsinfo- Normal outputdebug- All details
After changes:
docker compose restart
Development
Local Development
# Install dependencies
npm install
# TypeScript in watch mode
npm run watch
# In another terminal: start server
npm run dev
Project Structure
src/
├── index.ts # Main entry point
├── types.ts # TypeScript definitions
├── database.ts # SQLite database logic
├── mqtt-listener.ts # MQTT client & message handler
├── schema-discovery.ts # Schema discovery engine
└── mcp-server.ts # MCP server & tools
License
MIT
Support
For questions or issues, please create an issue on GitHub.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。