miot-mcp
米家 MCP Server
中文文档 | English
mijiaAPI 3.x をベースにした製品化された米家 MCP サービスです。クライアントが did、siid/piid/aiid といったプロトコル詳細を事前に理解する必要はなく、「家庭、部屋、デバイス名、シーン名」を優先した、より自然なクエリと制御を提供します。
このバージョンで解決する問題
AI クライアント向け: 低レベルのプロトコルフィールドではなく、安定した明確な製品レベルのツールを優先的に公開
実際の家庭シーン向け: まず家庭と部屋を確認し、次にデバイスを特定し、その後で制御を実行
MCP 標準向け: ツールは構造化された結果を返し、サービス状態とログイン状態をクライアントが直接利用可能
拡張性向け: 標準能力スキーマ、プロファイル駆動制御、リソースモデルは今後も進化可能
Related MCP server: Xiaomi smart home MCP server
現在の機能
サービスとログイン
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 installPoetry を使わない場合:
pip install -r requirements.txt起動
poetry run python mcp_server/mcp_server.pyハンドシェイクのテスト:
poetry run python mcp_server/mcp_test.pyログイン方法
mijiaAPI 3.x ではアカウント・パスワードログインは廃止され、QR コードログインのみ対応しています。
初回ログインが必要な場合、サービスは以下を実行します:
ブラウザページを生成:
~/.miot-mcp/qr.html同時に QR コード画像を生成:
~/.miot-mcp/qr.pngデフォルトではシステムブラウザで
qr.htmlを優先的に開くブラウザが開けない場合のみ、画像ビューアまたはターミナル QR コードにフォールバック
認証情報は以下に保存されます:
~/.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: 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
QR コードログインを事前に準備します。デフォルトでは既存の QR コードページを優先的に再利用します。スキャンをやり直す必要がある場合は、force_reauth=true を渡します。
get_service_status
サービス接続状態、認証ファイルパス、ログパス、QR コードページパス、次のステップの提案を返します。
get_home_overview
家庭と部屋ごとにデバイスの概要を出力します。クライアントが家庭構造を先に理解するのに適しています。
get_device_status
単一デバイスの現在の状態、利用可能な操作、推奨される次のステップを確認します。
get_device_capabilities
標準能力スキーマとプロファイル駆動の制御項目を返します。安定したルーティングが必要なクライアントに適しています。
control_by_intent
自然言語による制御エントリです。「寝室のテーブルランプの明るさを 30% に調整して」など、日常的な使用シーンのほとんどに適しています。
control_device
統一された構造化制御エントリです。クライアントが対象の操作とパラメータをすでに把握している場合に適しています。
speaker_say
小愛スピーカーに任意のテキストを音声読み上げさせます(「呼びかけ」)。長時間タスクの完了通知、アラーム形式の読み上げ、指定したスピーカーでのテキスト読み上げに適しています。
{
"name": "speaker_say",
"arguments": {
"text": "任务完成啦,图片已生成",
"speaker_name": "城市之光音响"
}
}execute-text-directive ではなく play-text を使う理由:
小愛スピーカーには関連する 2 つのアクションがあります:
execute-text-directive— テキストを質問/指示として小愛に送信して解析させる → AI の応答(「聞かれても困ります」など)が発生し、純粋な読み上げではないplay-text— テキストの純粋な再生。パラメータ_in=[text]の単一引数で、AI 対話を発生させない ←speaker_sayはこちらを使用
注意: 汎用の
run_actionパスでパラメータをvalueフィールドに入れると、クラウド API が-704220025 Action参数个数不匹配を返します。_inkwargs 形式(device.run_action('play-text', _in=[text])→method['in']=[text])を使用する必要があります。
コマンドライン方式(MCP クライアント不要、スクリプト直接呼び出し):
python speaker_say.py "任务完成啦" --speaker "城市之光音响"
python speaker_say.py "任务完成啦" --speaker "客厅音箱" --quiet # 静默(只执行不播报)パラメータ:
text: 読み上げるテキスト(自然言語)--speaker: スピーカー名(あいまい一致。未指定の場合は最初のオンラインスピーカーを選択)--quiet: サイレント実行(音声読み上げなし)
使用例
サービス状態の確認
{
"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": "客厅"
}
}能力スキーマの確認
{
"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 は、最も一般的な家庭制御パスを重点的にカバーしています:
家庭と部屋の閲覧
デバイスの特定
汎用能力制御
標準化された能力スキーマの公開
シーンの実行
消耗品の照会
重点的にカバーされている代表的な能力は以下の通りです:
オン/オフ
明るさ
色温度
目標温度
モード
風速
開閉位置
より低レベルで高度なカスタマイズ能力は、引き続き control_device に拡張できますが、デフォルトの使用方法としては外部に公開されません。
コード構造
現在のサービス内部は主に 3 つのレイヤーで構成されています:
adapter/mijiaAPIとの対話、ログイン、デバイス検出、QR コードログイン体験を担当mcp_server/core/結果のカプセル化、能力計算、インテントルーティング、標準化を担当mcp_server/device_definitions/とmcp_server/device_resources/標準能力定義、インテント定義、製品化されたリソースモデルを担当
現在の能力とルーティングはプラグインの自動検出に依存せず、定義テーブルを明示的にインポートします。これにより明確になり、AI クライアントが安定して呼び出すのにも適しています。
DSH(DeepSeek Harness)統合プラグイン
このリポジトリには、MCP サービスに加えて、DeepSeek Harness 用の Cordis プラグイン(dsh-plugin/dsh-task-notify)も同梱されており、DSH エージェントが小愛スピーカーでの呼びかけ + 飛書通知を能動的に行えます(長時間タスクの完了通知):
ツール | 機能 |
| 長時間タスク完了通知: 飛書の個別チャットで必ず送信 + おやすみモード状態に応じて小愛スピーカーで呼びかけ |
| 指定した小愛スピーカーに任意のテキストを読み上げさせる(純粋な再生、小愛の AI 対話は発生しない) |
| おやすみモードのオン/オフ / 現在のスピーカーの切り替え / 飛書の送信先変更(セッションをまたいで永続化) |
| 現在の状態を確認 |
DSH プラグインのインストール
# 1. 复制到 DSH profiles 的 node_modules
cp -r dsh-plugin/dsh-task-notify C:\Users\<you>\.dsh\profiles\node_modules\@oadank\dsh-task-notify
# 2. 注册到 ~/.dsh/profiles/web/cordis.patch.yml 的 insert 列表
- id: dsh-task-notify
name: '@oadank/dsh-task-notify'
# 3. 重启 dsh-web 生效プラグインは speaker_say.py(このリポジトリ内)を呼び出して小愛での読み上げを実行します。デフォルトのスピーカーは set_notify_state(currentSpeaker, "スピーカー名") で切り替えられ、状態は ~/.dsh/profiles/notify-state.json にセッションをまたいで永続化されます。
詳細は dsh-plugin/README.md を参照してください。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot 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.
- AlicenseAqualityCmaintenancemijia-control A production-ready MCP server that enables AI agents (Claude Code, Claude Desktop, Cursor, Hermes, etc.) to directly control Xiaomi/Mijia smart home devices through natural language. What it does Turns conversations into physical actions — "turn on the desk lamp to 50%" becomes actual device control in real-time.1260MIT
- FlicenseNot gradedqualityCmaintenanceMCP server for controlling Xiaomi/Mi Home smart devices via natural language, supporting device listing, property read/write, action calls, and camera snapshots.11
- AlicenseNot gradedqualityCmaintenanceMCP server that enables AI agents to control Xiaomi Mi Home smart devices through natural language, with support for listing devices, controlling properties, and running scenes.MIT
Related MCP Connectors
Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.
Self-hosted MCP gateway: turn any API, database or MCP server into AI connectors — no code.
Markdown-first MCP server for Notion API with 8 composite tools and 39 actions.
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/oadank/miot-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server