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 "Deploy 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-mcp show 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 且声明仅供学习交流,本项目相同。
Available Tools
14 toolsauth_statusARead-only
查看当前米家登录状态与认证文件路径,排查认证问题时先调这个。
Inputs: no named parameters. Returns: object
get_battery_reportARead-only
全屋电量普查:批量读取所有带电池的设备,按电量升序返回。
回答"哪些设备该换电池了"用这个,比逐设备查询快得多。 low 字段列出电量 ≤20% 的设备。
Inputs: home. Returns: object
get_device_specARead-only
获取设备规格:支持的属性(类型/读写/范围/枚举值)与动作列表。
用于确定 get_device_status / set_device_property / run_device_action 可用的属性名与动作名。
Inputs: device_or_model (required). Returns: object
get_device_statisticsARead-only
获取设备历史统计数据(如插座耗电量、净化器使用时长)。
并非所有设备都支持统计;键 siid_piid 需从设备说明或 https://home.miot-spec.com 查询(常见如插座功耗为 "7.1")。
Inputs: device (required), siid_piid (required), limit, granularity. Returns: result
get_device_statusARead-only
读取单个设备的详细状态(批量拉取,含原始值与语义化文本)。
Inputs: device (required), props. Returns: object
get_home_changesARead-only
回答"上次以来家里变了什么":与上一次快照对比,返回变化列表。
变化类型: prop_changed(属性值变化)/ went_offline / came_online / device_added / device_removed。调用后会把本次快照存为新基线 (基线只由本工具读写,get_home_snapshot 不影响它)。 首次调用时没有基线,会先建立基线并说明。
Inputs: home. Returns: object
get_home_snapshotARead-only
一次调用获取全屋设备状态快照(推荐入口)。
返回 家→房间→设备→语义化状态 的结构化结果,并附 attention (离线/低电量/故障设备)与统计信息。批量拉取,整屋通常几秒内完成。 本工具不影响 get_home_changes 的对比基线。
Inputs: home, room, detail, max_props_per_device. Returns: object
list_consumablesARead-only
耗材状态(滤芯/拖布/刷头/电池等),回答"哪些耗材该换了"。
status 是米家云端算好的三态:充足/不足/耗尽。needs_attention 里是不足和耗尽的,items 按紧急程度排序。
Inputs: home. Returns: object
list_devicesARead-only
列出设备(名称/did/model/在线状态/所属家庭房间),支持过滤。
Inputs: home, room, online_only, name_contains. Returns: result
list_homesARead-only
列出所有家庭及其房间(名称与设备数),用于确定 home 参数取值。
Inputs: no named parameters. Returns: result
list_scenesARead-only
列出米家手动场景(名称/scene_id/所属家庭)。
Inputs: home. Returns: result
loginA
发起米家扫码登录(凭证过期时使用)。
先尝试静默刷新 token;不行则返回二维码图片链接,用米家APP在2分钟内 扫码,然后调用 login_status 查询结果。
Inputs: no named parameters. Returns: result
login_statusARead-only
查询 login 发起的扫码登录进度(pending/success/error)。
Inputs: no named parameters. Returns: result
query_historyARead-only
查询本地事件历史,回答"今天门开过几次""洗衣机几点跑完"这类问题。
事件在 mijia-home-mcp watch 运行期间、以及每次 get_home_changes
调用时记录,保留 30 天;记录之外的时段没有数据。
Inputs: prop, limit, since, until, +2 more. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Each tool targets a distinct aspect of the Mi Home ecosystem: authentication, device listing, status retrieval, battery check, consumables, scenes, history, changes, and specs. No two tools have overlapping purposes.
Most tools follow a verb_noun pattern (get_, list_, query_), but 'auth_status' and 'login_status' are noun_verb, which is a minor inconsistency. Overall, the pattern is readable and predictable.
With 14 tools, the set is well-scoped for a home automation server. Each tool serves a clear purpose, covering authentication, device information, battery, consumables, scenes, history, and changes.
The tool surface is missing write operations (e.g., set_device_property, run_device_action), which are referenced in get_device_spec but not implemented. This is a significant gap for a home automation server, as agents cannot control devices.
Maintenance
Related MCP Connectors
One MCP server for the services your AI needs: memory, files, Microsoft 365, kanban and more.
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
MCP server that lets your AI assistant build and deploy apps, hosting each one at a live URL.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server based on the Mastra framework for controlling Xiaomi Mi Home smart devices. It enables device discovery, property management, action execution, and scene control through the Mi Home cloud service.ISC
- FlicenseNot gradedqualityDmaintenanceMCP server for controlling Xiaomi/Mi Home smart devices via natural language, supporting device listing, property read/write, action calls, and camera snapshots.12-
- AlicenseNot gradedqualityDmaintenanceA powerful MCP server that enables AI assistants to discover, commission, and control Matter-compatible smart home devices through a standardized interface.20 npm9MIT
- AlicenseNot gradedqualityAmaintenanceAn MCP server that enables natural language creation and management of Xiaomi Mi Home automation rules, integrating with AI coding assistants to query devices and manipulate automation graphs.144MIT