miot-mcp MCP Server
Mijia smart device MCP server, providing device discovery, property read/write, action invoke and other functions
miot-mcp scores 50 (Fair), licensed MIT and written in Python. It installs as a local process. It declares 7 tools. Filed under Version control. GitHub shows 79 stars. Package registries report about 39 downloads a week. Install configs are generated for 10 clients. Being listed in the registry is not the same as being vendor-official.
Fair trust
50 of 100 from six public signals. Nobody can buy a point.
- OSI-style license: mit.
License, quality and maintenance
Quality: Grade B
75/100 for listing completeness. Lost points: 7 of 7 tools barely described, short summary.
How quality is graded
Where the 50 comes from
0 + 20 + 6 + 10 + 4 + 10 = 50. Each factor is capped, so no single signal can carry a listing.
Active in the official MCP registry, plus a known vendor namespace.
Registry: 0 of 30 points.How recently the repository saw a commit or release.
Maintenance: 20 of 20 points.GitHub stars and weekly downloads, on a log scale.
Popularity: 6 of 20 points.A clear, OSI-style open-source license.
License: 10 of 10 points.Not archived, a secure install path, a pinned version.
Security: 4 of 10 points.A real summary, a README with depth, listed tools.
Docs: 10 of 10 points.Install
Pick your client, copy the config, paste it in.
Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.
{ "mcpServers": { "javen-yan-miot-mcp": { "command": "uvx", "args": [ "miot-mcp" ] } }}
Environment variables
This server does not declare environment variables.
Tools7Tool docs quality grade F
All capabilitiescontrol_devicetoolprepare_logintool
About
米家 MCP Server
中文文档 | English
一个基于 mijiaAPI 5.x 与小米官方 miot-spec.org 物模型源的产品化米家 MCP 服务。它不再要求客户端先理解 did、siid/piid/aiid 这些底层协议细节,而是优先面向“家庭、房间、设备名、场景名”提供稳定、快速的查询和控制能力。
这版解决什么问题
- 面向 AI 客户端:优先暴露稳定、清晰的产品级工具,而不是底层协议字段
- 面向真实家庭场景:先看家庭与房间,再定位设备(含共享设备、多键开关拆分的分路子设备
.s2/.s3),再执行控制 - 官方物模型与强类型对齐:基于
mijiaAPI 5.0对接miot-spec.org,自动处理多服务属性去重(如on-2/mode-2)、中英文枚举映射(制冷/睡眠/日光/月光/无线开关等)及数值步长对齐 - 高速批量读写:单次请求批量读取设备状态,支持静默 Token 续期与后台非阻塞扫码登录
- 面向扩展:标准能力 schema + 原始物模型
set_property/run_action双层覆盖,支持任意标准 MIoT 设备
当前能力
服务与登录
get_service_statusprepare_loginreconnect_serviceclear_saved_loginrefresh_devicesget_tool_catalogping
家庭与设备
get_home_overviewlist_homeslist_devicesget_deviceget_device_statusget_device_capabilities
设备控制
control_by_intentcontrol_deviceturn_on_deviceturn_off_deviceset_brightnessset_color_temperatureset_target_temperatureset_hvac_modeset_fan_speedset_cover_position
场景与耗材
list_scenesexecute_sceneget_consumable_items
MCP 资源
mijia://servicemijia://homesmijia://devicesmijia://scenesmijia://capabilitiesmijia://tooling
安装
建议使用 Python 3.10+。
poetry install
如果你不用 Poetry:
pip install -r requirements.txt
启动
poetry run python mcp_server/mcp_server.py
测试握手:
poetry run python mcp_server/mcp_test.py
登录方式
mijiaAPI 5.x 采用二维码扫码登录,并支持基于 passToken 的静默 Token 自动续期。
首次需要登录时,服务会(后台非阻塞等待扫码,不卡死 MCP 调用):
- 生成浏览器页:
~/.miot-mcp/qr.html - 同时生成二维码图片:
~/.miot-mcp/qr.png - 默认优先用系统浏览器打开
qr.html - 只有浏览器打不开时,才回退到图片查看器或终端二维码
认证信息会保存到:
~/.miot-mcp/auth_data.json
推荐登录主路径
- 调用
prepare_login - 调用
get_service_status - 读取
service.qr.page_path或service.qr.image_path - 完成扫码后调用
reconnect_service或直接refresh_devices
登录相关状态
get_service_status 和 mijia://service 都会返回结构化登录状态,重点字段包括:
service.connectedservice.has_saved_loginservice.qr.open_modeservice.qr.page_pathservice.qr.image_pathservice.qr.login_urlassistant_summarynext_steps.should_scan_qr
环境变量
export MIJIA_ENABLE_QR="true"
export MIJIA_QR_OPEN_MODE="browser"
export MIJIA_LOG_LEVEL="INFO"
说明:
MIJIA_ENABLE_QR:是否启用二维码登录,默认trueMIJIA_QR_OPEN_MODE:高级配置,支持browser/viewer/none,默认browserMIJIA_LOG_LEVEL:日志级别,支持DEBUG/INFO/WARNING/ERROR
MCP 客户端配置示例
推荐直接使用虚拟环境里的 Python,而不是 poetry run。
{
"mcpServers": {
"mijia": {
"command": "/path/to/venv/bin/python",
"args": [
"/path/to/miot-mcp/mcp_server/mcp_server.py"
],
"env": {
"MIJIA_ENABLE_QR": "true",
"MIJIA_QR_OPEN_MODE": "browser",
"MIJIA_LOG_LEVEL": "INFO"
}
}
}
}
推荐调用路径
对于大多数 AI 客户端,建议优先这样使用:
prepare_loginget_service_statusrefresh_devicesget_home_overviewget_device_statuscontrol_by_intentlist_scenesexecute_scene
如果客户端需要更稳定、更显式的路由,再补充:
list_homeslist_devicesget_deviceget_device_capabilitiescontrol_device
常用工具说明
prepare_login
主动准备二维码登录。默认优先复用已有二维码页;如果需要重新走一轮扫码,可以传 force_reauth=true。
get_service_status
返回服务连接状态、认证文件路径、日志路径、二维码页路径、下一步建议。
get_home_overview
按家庭和房间输出设备总览,适合客户端先理解家庭结构。
get_device_status
查看单个设备当前状态、可用操作和推荐下一步。
get_device_capabilities
返回标准能力 schema 和 profile 驱动控制项,适合需要稳定路由的客户端。
control_by_intent
自然语言式控制入口。适合大多数日常使用场景,例如“把卧室台灯亮度调到 30%”。
control_device
统一结构化控制入口。适合客户端已经知道目标操作和参数时使用。
使用示例
查看服务状态
{
"name": "get_service_status",
"arguments": {}
}
主动准备登录
{
"name": "prepare_login",
"arguments": {
"reopen_qr": true
}
}
刷新设备与房间映射
{
"name": "refresh_devices",
"arguments": {}
}
查看家庭总览
{
"name": "get_home_overview",
"arguments": {}
}
查看单个设备状态
{
"name": "get_device_status",
"arguments": {
"device_name": "吸顶灯",
"room": "客厅"
}
}
查看能力 schema
{
"name": "get_device_capabilities",
"arguments": {
"device_name": "台灯",
"room": "卧室"
}
}
自然语言控制
{
"name": "control_by_intent",
"arguments": {
"query": "把卧室台灯亮度调到30%"
}
}
结构化控制
{
"name": "control_device",
"arguments": {
"operation": "set_color_temperature",
"device_name": "台灯",
"room": "卧室",
"value": 4000
}
}
执行场景
{
"name": "execute_scene",
"arguments": {
"scene_name": "回家模式"
}
}
当前边界
这版 MCP 重点覆盖的是最常见的家庭控制路径:
- 家庭与房间浏览
- 设备定位
- 通用能力控制
- 标准化能力 schema 暴露
- 场景执行
- 耗材查询
已重点覆盖的典型能力包括:
- 开关
- 亮度
- 色温
- 目标温度
- 模式
- 风速
- 开合位置
更底层、更强定制的能力仍然可以继续往 control_device 扩展,但不再作为默认使用方式对外暴露。
代码结构
当前服务内部主要有三层:
adapter/负责与mijiaAPI交互、登录、设备发现和二维码登录体验mcp_server/core/负责结果封装、能力计算、意图路由、标准化mcp_server/device_definitions/与mcp_server/device_resources/负责标准能力定义、意图定义和产品化资源模型
当前能力和路由不依赖插件自动发现,而是显式导入定义表。这样更清晰,也更适合 AI 客户端稳定调用。
Frequently asked questions
What is miot-mcp MCP Server?
Mijia smart device MCP server, providing device discovery, property read/write, action invoke and other functions
How do I install miot-mcp MCP Server in Claude Desktop, Cursor, or VS Code?
Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. miot-mcp MCP Server runs locally from the PyPI package miot-mcp with the command uvx miot-mcp.
Is miot-mcp MCP Server free and open source?
Yes. miot-mcp MCP Server is released under the MIT license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.
Does miot-mcp MCP Server support remote (HTTP) connections?
No remote endpoint is listed for miot-mcp MCP Server. It runs locally on your machine over stdio, started by your MCP client.
What tools does miot-mcp MCP Server provide?
miot-mcp MCP Server provides 7 tools, including control_by_intent, control_device, get_device_capabilities, and get_device_status. See the full tool list for descriptions and parameters.
How is miot-mcp MCP Server's trust score calculated?
miot-mcp MCP Server scores 50 out of 100 (Fair). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.
Reviews
No reviews yet—Be the first to review
No published reviews yet. Used it? Tell the next person how it went.
Sign inA verified email is required to review this server.
Add badge to your README
Paste either snippet into the repository README. The image links to this listing.
