mijia-home-mcp
This server provides a comprehensive MCP interface for monitoring and (optionally) controlling Xiaomi Mi Home (米家) smart home devices.
Read / Monitoring Tools (always available)
get_home_snapshot— Fetch a full snapshot of all home devices organized by home → room → device, with semantic state translation, offline/low-battery alerts, and 30-second cachingget_home_changes— Get a diff of what changed since the last snapshot (property changes, devices going online/offline, devices added/removed)query_history— Query local event history (e.g., door open times, washing machine cycles), filterable by device, property, event type, and time range; data retained for 30 dayslist_homes/list_devices— List all homes/rooms with device counts, or enumerate devices with name/model/online status/roomget_device_status/get_device_spec— Get detailed status of a single device, or its specs (supported properties, actions, read-write/range/enum info)list_scenes— List Mi Home manual sceneslist_consumables— Check consumable status (filters, brush heads, etc.) and which need replacementget_battery_report— Full battery survey of all battery-powered devices, sorted by level ascendingget_device_statistics— Historical statistics (e.g., power consumption, usage duration) for a deviceauth_status/login/login_status— Check login status, initiate QR code login if credentials expire, or check login progress
Control Tools (require --enable-control flag)
set_device_property— Set a property on a device (e.g., turn on a light, set temperature)run_device_action— Execute an action on a devicerun_scene— Trigger a Mi Home manual scenespeaker_announce— Make a Xiaomi smart speaker announce a messagerun_speaker_command— Have a Xiaomi smart speaker execute a natural language command (treated as dangerous)
Notification Tool
send_notification— Push notifications to all configured channels simultaneously (Xiaomi Speaker, MeoW, Bark, ntfy, Feishu, DingTalk, generic webhook)
Key Safety & Other Features
Dangerous devices (locks, cameras, gas/water valves, safes) require an additional
--allow-dangerousflag even with--enable-controlAll write operations (including rejected ones) are logged to an audit log
Multi-home support with options to lock to a default home or override per query
Standalone CLI capabilities: self-diagnosis (
doctor), snapshots, device/battery listing, speaker messaging, and continuous change monitoring (watch)MCP resources for clients that support them, offering device lists, home structure, and real-time snapshots
Allows sending notifications to ntfy.sh or a self-hosted ntfy server, providing real-time alerts about home events and device changes.
Allows monitoring and control of Xiaomi smart home devices (米家 ecosystem), including reading device states, executing actions, and receiving notifications about home changes.
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., "@mijia-home-mcpshow me the current state of my home"
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.
mijia-home-mcp
中文 | English
米家 MCP server。get_home_snapshot 一次调用批量拉全屋设备状态(65 台约 9s),按家/房间分组,枚举值转成可读文本。默认只读,控制工具要显式开启,锁和摄像头另有一层拦截。
基于 Do1e/mijia-api,共用其登录凭证(~/.config/mijia-api/auth.json,扫码一次约一个月)。
安装
先登录(终端出二维码,米家 App 扫):
uvx --from git+https://github.com/jiayunlimailutorontoca/mijia-home-mcp mijia-home-mcp login加到 Claude Code:
claude mcp add mijia-home -- uvx --from git+https://github.com/jiayunlimailutorontoca/mijia-home-mcp mijia-home-mcp serve问一句"家里现在什么情况"就能用了。
帮我安装 mijia-home 米家 MCP:
1. uvx --from git+https://github.com/jiayunlimailutorontoca/mijia-home-mcp mijia-home-mcp login
二维码给我扫;已有有效的 ~/.config/mijia-api/auth.json 就跳过。这步需要我,停下来等。
2. claude mcp add mijia-home -- uvx --from git+https://github.com/jiayunlimailutorontoca/mijia-home-mcp mijia-home-mcp serve
3. 我有多个家庭的话先问我锁哪个,命令加 --env MIJIA_HOME_MCP_HOME_NAME=家庭名
4. 调 get_home_snapshot,报在线设备数帮我安装 mijia-home 米家 MCP:
1. 登录同上,二维码给我扫
2. openclaw mcp add mijia-home --command uvx --arg "--from" --arg "git+https://github.com/jiayunlimailutorontoca/mijia-home-mcp" --arg "mijia-home-mcp" --arg "serve"
3. openclaw mcp probe mijia-home 应显示 14+ tools;会话里看不到就 npm i -g mcporter
4. 调 get_home_snapshot 验证多家庭账号建议锁定默认家庭,否则每次全家庭拉取:
"env": { "MIJIA_HOME_MCP_HOME_NAME": "我的家" }Related MCP server: xiaomi-device-control
通知
配置通道后多一个 send_notification 工具,一次推所有已配置的通道;不配则该工具不出现。
"env": {
"MIJIA_HOME_MCP_SPEAKER": "auto",
"MIJIA_HOME_MCP_MEOW": "MeoW昵称",
"MIJIA_HOME_MCP_BARK": "Bark设备key",
"MIJIA_HOME_MCP_NTFY": "ntfy主题",
"MIJIA_HOME_MCP_FEISHU": "https://open.feishu.cn/open-apis/bot/v2/hook/xxx",
"MIJIA_HOME_MCP_DINGTALK": "https://oapi.dingtalk.com/robot/send?access_token=xxx"
}各通道申请方式:
钉钉:群设置 → 机器人 → 自定义。安全设置选关键词填
米家,或加签(密钥配_DINGTALK_SECRET)。仅内部群,限流 20 条/分飞书:群设置 → 群机器人 → 自定义机器人。签名密钥配
_FEISHU_SECRETMeoW(鸿蒙):装 app 注册昵称,昵称即配置
Bark(iOS):app 里复制 device key;自建填
https://host/keyntfy(安卓):订阅一个 topic,topic 即配置。公开 topic 谁都能订,名字取随机
控制
默认只读。开启:
mijia-home-mcp serve --enable-control --allow "客厅*" --deny "*camera*"规则:
锁/摄像头/燃气水阀/保险柜不吃通配符,必须
--allow精确写设备名或 did,或--allow-dangerousrun_speaker_command(小爱执行语音指令)能触达全屋设备,按危险设备同等门控;经run_device_action调execute-text-directive走同一道闸,绕不过去。纯播报用speaker_announce,普通门控run_scene不看白名单——场景内容是你在米家 App 定义的,不想让 AI 碰的别做成手动场景所有写操作(含被拒的)记
~/.config/mijia-home-mcp/audit.log
工具
读:get_home_snapshot(home/room 过滤,30s 缓存)、get_home_changes(diff)、query_history(本地 30 天事件史)、get_battery_report、get_device_statistics、list_homes/list_devices/get_device_status/get_device_spec/list_scenes/list_consumables、auth_status/login/login_status、send_notification
控制:turn_on/turn_off(自动匹配开关属性)、set_device_property、run_device_action、run_scene、speaker_announce、run_speaker_command
resources:mijia://devices、mijia://homes、mijia://snapshot
耗材:list_consumables 返回云端算好的三态(充足/不足/耗尽),该换的进 needs_attention,同时出现在快照的 attention 里。
命令行
不接 MCP 也能用:
mijia-home-mcp doctor # 自检 + 更新检查
mijia-home-mcp snapshot # --home --room --full --json
mijia-home-mcp devices
mijia-home-mcp battery
mijia-home-mcp say "吃饭了"
mijia-home-mcp watch --speak --only "门锁*" --ignore left-timewatch 轮询变化,推送到已配置的通道,每小时查一次耗材,事件写本地历史。--ignore left-time 建议加上,洗碗机倒计时一分钟变一次。
局域网
mijia-home-mcp serve --transport http --host 0.0.0.0 --port 8423 --http-token 随机串
claude mcp add --transport http mijia-home http://<host>:8423/mcp --header "Authorization: Bearer 随机串"不设 token 无鉴权,启动会警告。别暴露公网。token 建议走环境变量 MIJIA_HOME_MCP_HTTP_TOKEN,命令行参数在进程列表可见。
环境变量
变量 | 说明 |
| 认证文件,默认 |
| 默认家庭 |
|
|
| 白/黑名单,逗号分隔 |
| 放行危险设备 |
| 状态目录,默认 |
| 通知通道 |
| http Bearer token |
已知问题
走小米云端(上游为逆向接口),秒级延迟,无推送,轮询别太密
凭证约一个月过期,
login重扫红外类设备(空调伴侣的"空调")spec 页缺中文数据,解析失败会进
attention.spec_errors,不影响其他设备readOnlyHint注解只是提示,真正的门在服务端
开发
uv venv && uv pip install -e ".[dev]"
uv run pytest测试离线,不需要米家账号。
License
GPL-3.0-or-later。上游 mijia-api 为 GPL-3.0 且声明仅供学习交流,本项目相同。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jiayunlimailutorontoca/mijia-home-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server