Skip to main content
Glama
caroliny1031

midea-mcp

by caroliny1031

midea-mcp

面向美的空调的本地单用户 MCP Server。MVP 使用 Python 3.12、MCP Python SDK >=1.27,<2 和 stdio,公开七个工具:

  • list_devices

  • get_device

  • get_device_log

  • refresh_device

  • set_device_state

  • discover_lan_devices

  • diagnose_device

设备状态日志

所有 set_device_state 调用都会写入 data/device-log.jsonl,包括请求字段、 Provider、五种写入状态、核验结果和失败原因。每次真实设备状态读取都会与上一份 持久化快照比较,并分别记录:

  • state_change:开关、模式、设定温度;

  • sensor_change:室内温度;

  • availability_change:在线状态;

  • state_snapshot:首次读取时建立的基线。

每条记录同时包含 UTC 和北京时间。通过 midea-mcp 写入后的读回带有同一个 request_id;其他入口造成的变化标记为 external_unknownobserved_via=cloud 只表示变化是通过云端读取发现的,不能证明操作来自美居 App。

读取最近日志:

get_device_log(limit=50)
get_device_log(limit=50, field="mode")
get_device_log(limit=50, event_type="state_change")

可过滤字段为 powermodetarget_temperaturecurrent_temperatureonlinelimit 范围为 1–500。日志只在真实状态读取发生时发现外部变化; midea-mcp 本身不会后台轮询设备。

Related MCP server: xiaomi-device-control

安全与一致性保证

  • 每台逻辑设备使用 midea-mcp 内部 UUID。

  • Cloud ID、LAN ID 和 keyed SN fingerprint 分别保存为 bindings,绝不假设 Cloud ID 与 LAN ID 相同。

  • 写入只返回 rejectednot_delivereddelivery_unknownacceptedverified

  • LAN 或 Cloud 写入投递结果不明时,只通过原 Provider 读取实际状态进行核验, 绝不切换 Provider 或重发。

  • Token/Key 使用 AES-256-GCM 加密落盘;日志和工具响应不返回明文凭证或原始 SN。

  • 路由选择为“可用 LAN 优先;没有可用 LAN binding 时使用 Cloud”。一旦开始写入, 本次请求就锁定 Provider。

  • Cloud 支持空调状态读取及开关、模式、目标温度写入,并使用云端状态读回核验。

安装

py -3.12 -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e ".[dev]"

如果系统没有 py 命令,直接使用 Python 3.12 可执行文件创建虚拟环境。

默认数据目录是当前目录下的 data/,可通过 MIDEA_MCP_DATA_DIR 修改。 首次启动会生成 data/master.key。生产使用时应备份密钥并限制文件访问权限;也可以 使用 MIDEA_MCP_MASTER_KEY 注入一个 URL-safe base64 编码的 32 字节密钥。

Phase 0

1. 局域网扫描

.\.venv\Scripts\midea-mcp.exe phase0

跨子网或广播受限时可指定设备 IP 或广播地址:

.\.venv\Scripts\midea-mcp.exe phase0 --target 192.168.1.255

2. 导入旧 HA V3 凭证

midea_ac_lan 的单设备文件通常位于:

<HA config>/.storage/midea_ac_lan/<device_id>.json

可导入单个文件、整个 midea_ac_lan 目录,也可导入 HA .storage/core.config_entries

.\.venv\Scripts\midea-mcp.exe import-ha C:\path\to\123456789.json

导入器仅接受设备类型 0xAC、协议版本 V3,并将 Token/Key 立即加密后保存。

3. 可选的 Cloud 库存及 Token/Key 补取

不要把账号密码写入命令行历史:

$env:MIDEA_ACCOUNT = "your-account"
$env:MIDEA_PASSWORD = "your-password"
$env:MIDEA_CLOUD_NAME = "美的美居"
.\.venv\Scripts\midea-mcp.exe sync-cloud

旧 Token API 正在被美的关闭,因此该步骤可能无法取得新凭证。已有 HA 凭证优先且 不会被云端候选覆盖。Cloud/LAN 只有在 SN fingerprint 唯一匹配时才合并为同一设备。

sync-cloud 同时会登记 Cloud binding。部署在无法访问家庭局域网的服务器时,应在 启动 MCP Server 前至少执行一次该命令;之后 refresh_deviceset_device_state 会通过 Cloud 路由工作。

4. 加密备份

.\.venv\Scripts\midea-mcp.exe backup-credentials C:\safe\midea.backup.json
.\.venv\Scripts\midea-mcp.exe restore-credentials C:\safe\midea.backup.json

备份使用独立口令通过 scrypt 派生密钥,再使用 AES-256-GCM 加密。

启动 MCP Server

.\.venv\Scripts\midea-mcp-server.exe

客户端配置示例:

{
  "mcpServers": {
    "midea": {
      "command": "C:\\path\\to\\midea-mcp\\.venv\\Scripts\\midea-mcp-server.exe",
      "env": {
        "MIDEA_MCP_DATA_DIR": "C:\\path\\to\\midea-mcp\\data"
      }
    }
  }
}

控制参数

set_device_state 只接受:

{
  "device_id": "midea-mcp-internal-uuid",
  "changes": {
    "power": true,
    "mode": "cool",
    "target_temperature": 26
  }
}

模式为 off / auto / cool / dry / heat / fan_only,目标温度默认限制 为 17–30°C,步长 0.5°C。power=false 不能与模式或温度同时提交。

当前不做

  • 热水器、烤箱及其他设备品类

  • 场景和 execute_scene

  • Home Assistant Provider

  • 多用户或公网认证

测试

.\.venv\Scripts\python.exe -m pytest
.\.venv\Scripts\python.exe -m ruff check .

测试使用模拟 Provider,不会控制真实设备。实机写入只通过显式调用 set_device_state 发生。

本次 Phase 0 与实机验收结果见 PHASE0.md。项目已发现并登记 一台 V3 空调,通过云端 Token API 候选完成 LAN 认证,并实际验证开关、模式 和温度控制。验收结束后设备已恢复为关机、25°C。

Acknowledgments

Unofficial community project, not affiliated with Midea Group.

Available Tools

6 tools
diagnose_deviceC
Read-onlyIdempotent

Check bindings, encrypted credential presence, route policy, and LAN read.

ParametersJSON Schema
NameRequiredDescriptionDefault
device_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

C2.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and idempotentHint=true, so the safety profile is clear. The description adds no additional behavioral context (e.g., permissions, response format, side effects) beyond what annotations convey.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence listing four items, which is concise but lacks structure (e.g., bullets or categorization). Every word serves a purpose, but the listing style could be clearer.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the output schema exists, the description omits what the tool returns or how diagnostics are presented. The tool's role relative to siblings is implied but not explained, leaving gaps for an agent to fully understand its usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and the description does not clarify the device_id parameter—no format, constraints, or relationship to the listed checks is explained.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool checks bindings, encrypted credential presence, route policy, and LAN read. It uses a specific verb ('Check') and lists distinct diagnostic areas, distinguishing it from sibling tools like get_device or refresh_device, though not explicitly contrasting them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use diagnose_device versus alternatives such as get_device or discover_lan_devices. No prerequisites, context, or exclusion criteria are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

discover_lan_devicesB
Idempotent

Scan LAN ACs and reconcile identities; target may be an IP/broadcast address.

ParametersJSON Schema
NameRequiredDescriptionDefault
targetNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

B3.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations provide idempotentHint true and destructiveHint false. The description adds 'reconcile identities,' implying state changes, but lacks further context on side effects or prerequisites. Adequate given annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no fluff, front-loaded with action. Could be clearer but efficient for a single-parameter tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Output schema covers return values, annotations cover safety. Description omits usage scenarios and parameter constraints, but overall adequate for a simple discovery tool with a single optional parameter.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description compensates by noting target may be an IP/broadcast address. However, it omits format, required vs optional, and default behavior, leaving gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool scans LAN ACs and reconciles identities, providing a specific verb and resource. It distinguishes from siblings like list_devices (known devices) by focusing on discovery, though 'LAN ACs' is somewhat cryptic.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives like list_devices or get_device. The context of target being an IP/broadcast address is implied but not elaborated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_deviceA
Read-onlyIdempotent

Get one AC by its midea-mcp internal UUID, including capabilities.

ParametersJSON Schema
NameRequiredDescriptionDefault
device_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, destructiveHint=false. The description adds that it 'includes capabilities', which is a minor behavioral detail. No contradictions with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single 10-word sentence that is front-loaded with the verb and resource. Every word is necessary and no fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple retrieval tool with one parameter and an output schema, the description conveys the core purpose and parameter meaning. It could optionally mention that the output is a device object, but the output schema covers that. Slightly more context about when to use this over siblings would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage for device_id. The description explains that the parameter is a 'midea-mcp internal UUID', providing essential context that the schema lacks. This fully compensates for the missing schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb 'Get' and resource 'one AC', clearly distinguishing from sibling tools like list_devices (plural) and diagnose_device. It mentions the identifier type (midea-mcp internal UUID) and that capabilities are included.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool vs alternatives (e.g., list_devices for all devices, diagnose_device for diagnostics). The description only states what it does, not when to choose it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_devicesA
Read-onlyIdempotent

List registered logical air conditioners, bindings, routes, and cached state.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false. The description adds 'cached state,' implying the list may not be real-time, but lacks other behavioral details like pagination or response size.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with verb and resources, no redundant words, perfectly concise for the tool's simplicity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the low complexity (no params, output schema exists, annotations cover safety), the description sufficiently explains the tool's purpose and output scope. It could mention that the list is complete or lacks filtering, but it's adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With zero parameters, the description adds value by listing what is included (air conditioners, bindings, routes, cached state), which helps the agent understand the output. The baseline is 4 for 0 params.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the verb 'list' with specific resources ('registered logical air conditioners, bindings, routes, and cached state'), clearly distinguishing it from sibling tools like get_device (single device) or discover_lan_devices (discovery).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus siblings (e.g., get_device for details, refresh_device for updates). The agent must infer from tool names alone without explicit context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

refresh_deviceA
Read-onlyIdempotent

Read the actual AC state through LAN and update the local cache.

ParametersJSON Schema
NameRequiredDescriptionDefault
device_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds context beyond annotations: it discloses the side effect of updating local cache and the LAN mechanism, matching the readOnlyHint and idempotentHint.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence with no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given few parameters, presence of annotations and output schema, the description provides sufficient context for the tool's purpose and behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, and the description does not explain the device_id parameter, though its purpose is implicitly clear from context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool reads the actual AC state via LAN and updates the local cache, specifying verb and resource, and distinguishes from siblings like set_device_state.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use when fresh data is needed (vs cached), but does not explicitly state when to use vs alternatives or provide exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

set_device_stateA
Idempotent

Set AC desired state once; never retry an uncertain LAN write via Cloud.

ParametersJSON Schema
NameRequiredDescriptionDefault
changesYes
device_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate idempotentHint=true and destructiveHint=false. The description adds valuable context with 'never retry an uncertain LAN write via Cloud', clarifying the one-shot nature and retry policy beyond what annotations provide. No contradictions with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, short sentence that conveys the core purpose and a critical behavioral note. No wasted words; front-loaded with the action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple (2 params, no enums) but has an output schema and nested objects. The description covers the main behavior and retry policy, but lacks details about the 'changes' parameter, prerequisites (e.g., device must exist), and expected outcomes. Basic but missing some context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must explain parameters. It only mentions 'AC desired state' but does not define the 'changes' object or its allowed keys. The 'device_id' is also not explained. This leaves the agent with insufficient information for correct invocation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Set AC desired state') and the resource ('AC desired state'), using a specific verb. It distinguishes itself from sibling tools (all reads or diagnostics) by indicating a state-setting operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The instruction 'never retry an uncertain LAN write via Cloud' provides a clear behavioral guideline for when to avoid retrying. It implies usage for setting state without retry, but does not explicitly state when to use this tool versus alternatives or when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 6 tool updatesv0.2.0
    • First observeddiagnose_device
    • First observeddiscover_lan_devices
    • First observedget_device
    • First observedlist_devices
    • First observedrefresh_device
    • First observedset_device_state

TDQS

A3.6/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: retrieving device info, refreshing state, listing devices, setting state, discovering LAN devices, and diagnosing. No overlap or ambiguity.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern using lowercase snake_case (get_device, refresh_device, list_devices, set_device_state, discover_lan_devices, diagnose_device).

Tool Count5/5

With 6 tools covering listing, retrieval, state refresh, state setting, discovery, and diagnostics, the set is well-scoped for managing Midea air conditioners without being excessive or insufficient.

Completeness4/5

The tool set covers core operations: listing, reading, refreshing, setting state, discovering, and diagnosing. Minor gaps like device deletion or cloud-only refresh are absent but not critical for the intended domain.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    An 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.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    MCP server for controlling Xiaomi/Mi Home smart devices via natural language, supporting device listing, property read/write, action calls, and camera snapshots.
    11
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that enables LLMs to control Mitsubishi Electric AC units through MELCloud, supporting device listing, power on/off, temperature changes, and smart auto comfort mode.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    Local MCP server for reading temperature/humidity sensors from Tuya/SmartLife devices, exposing tools to list devices, get capabilities, and read sensor data.
    -

Latest Blog Posts

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/caroliny1031/midea-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server