
通过MCP(模型上下文协议)通过AI助手控制小米智能家居设备。二维码登录,零配置。
概览
通过模型上下文协议(MCP)通过AI助手控制您的小米智能家居设备。 可支持Claude Code、Claude Desktop、Cursor及任何兼容MCP的客户端。 - — 自动查找你小米账户中的所有设备 - — 读取电源状态、亮度、温度、湿度、电池、锁定状态 - — 开关、调整亮度、色温、目标温度 - — 播放/暂停音乐、TTS、音量控制、语音指令 - — 用Mi Home应用扫描,无需密码 - — 只需两个Python文件,无需安装PIP - Python 3.10+ - uv(推荐)或 pip - 手机上的小米应用(用于二维码登录) 浏览器中会打开二维码。用小米家宝应用扫描(右上角的“个人资料→扫描图标”)。 代币保存到 ~/.xiaomi-mcp/tokens.json,权限为 600 个。 就是这样!现在你可以和你的设备对话了: “开灯” “室温多少?”“门锁着吗?”“亮度调到50%” “放点音乐”
概述(AI 翻译)
中文文档
通过模型上下文协议(MCP)通过AI助手控制您的小米智能家居设备。
可支持Claude Code、Claude Desktop、Cursor及任何兼容MCP的客户端。
特色
- 设备发现 — 自动找到你小米账户中的所有设备
- 状态监控 — 读取电源状态、亮度、温度、湿度、电池、锁定状态
- 设备控制 — 开关、调整亮度、色温、目标温度
- 小米艾音箱 — 播放/暂停音乐、TTS、音量控制、语音指令
- 二维码登录 — 用Mi Home应用扫描,无需密码
- 零依赖设置 — 只需两个Python文件,无需pip安装
快速启动
先决条件
- Python 3.10+
- UV(推荐)或PIP
- 手机上的Mi Home应用(用于二维码登录)
1.登录
浏览器中会打开二维码。用小米家宝应用扫描(右上角的“个人资料→扫描图标”)。
代币保存到~/.xiaomi-mcp/tokens.json,权限为600。
2.连接Claude代码
就是这样!现在你可以和你的设备对话了:
“打开灯” “室温是多少?” “门锁着吗?” “将亮度设置为50%”
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Xiaomi Home MCP Server
Control your Xiaomi smart home devices through AI assistants via the Model Context Protocol (MCP).
Works with Claude Code, Claude Desktop, Cursor, and any MCP-compatible client.
Features
- Device Discovery — Automatically find all devices in your Xiaomi account
- Status Monitoring — Read power state, brightness, temperature, humidity, battery, lock status
- Device Control — Turn on/off, adjust brightness, color temperature, target temperature
- XiaoAi Speaker — Play/pause music, TTS, volume control, voice commands
- QR Code Login — Scan with Mi Home app, no password needed
- Zero Dependencies Setup — Just two Python files, no pip install required
Quick Start
Prerequisites
- Python 3.10+
- uv (recommended) or pip
- Mi Home app on your phone (for QR code login)
1. Login
uv run --script login.py
A QR code will open in your browser. Scan it with the Mi Home app (Profile → Scan icon in top-right corner).
Tokens are saved to ~/.xiaomi-mcp/tokens.json with 600 permissions.
2. Connect to Claude Code
claude mcp add xiaomi-home -- uv run --script /path/to/mcp_server.py
That’s it! Now you can talk to your devices:
“Turn on the lamp” “What’s the room temperature?” “Is the door locked?” “Set brightness to 50%” “Play some music”
2a. Connect to Claude Desktop
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"xiaomi-home": {
"command": "uv",
"args": ["run", "--script", "/path/to/mcp_server.py"]
}
}
}
Available Tools
| Tool | Description |
|---|---|
get_devices() |
List all devices and online status |
get_device_status(name?) |
Query detailed status (power, brightness, temperature, battery, etc.) |
control_device(name, action) |
Control device: on/off, brightness, color_temp, target_temp |
play_music(keyword?) |
Play music on XiaoAi speaker |
pause_music() |
Pause playback |
resume_music() |
Resume playback |
set_volume(volume) |
Set speaker volume (0-100) |
tts(text) |
Text-to-speech on speaker |
xiaoai_command(command) |
Send voice command to XiaoAi |
get_speaker_status() |
Get playback status |
Supported Devices
The server auto-detects device types by model prefix:
| Type | Models | Status Query | Control |
|---|---|---|---|
| Light | philips.light.*, yeelink.light.* |
Power, Brightness | On/Off, Brightness, Color Temp |
| AC Partner | lumi.acpartner.* |
Power | On/Off |
| Heater | xiaomi.heater.* |
Power, Target Temp | On/Off, Target Temp |
| Fan | xiaomi.fan.* |
Power, Speed, Oscillate | On/Off |
| Lock | loock.lock.* |
Lock State, Battery | — |
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"xiaomi-home": {
"command": "uv",
"args": ["run", "--script", "/path/to/mcp_server.py"]
}
}
}