miot
基于 MijiaAPI 的米家设备智能控制代理,提供标准化的 MCP 服务,支持动态设备发现、属性读写和动作调用
claude mcp add --transport stdio javen-yan-miot-mcp python mcp_server/mcp_server.py \ --env MIJIA_PASSWORD="your_mijia_password" \ --env MIJIA_USERNAME="your_mijia_username" \ --env MIJIA_ENABLE_QR="false" \ --env MIJIA_LOG_LEVEL="INFO"
How to use
This MCP server implements a Chinese Mi Home (Mijia) device control service based on the Model Context Protocol. It automatically discovers Mi Home devices, exposes their properties and actions, and provides real-time status monitoring and batch operations. You can connect to Mi Home cloud, discover devices, read and set properties, call device actions, and monitor device statuses. The server also includes tools for home and scene management, consumables information, and server health checks. The tools are organized into categories such as connect, discover_devices, get_property_value, set_property_value, batch_set_properties, call_action, get_device_status, refresh_all_device_status, get_homes, get_scenes_list, run_scene, get_server_status, and clear_cache. You can integrate these tools into AI assistants or other MCP clients to automate Mi Home workflows.
To use it, start the Python MCP server as described in the installation instructions, ensure the MIJIA_USERNAME and MIJIA_PASSWORD environment variables are set (and optionally enable QR login with MIJIA_ENABLE_QR), then invoke tools via the standard MCP interface. Examples in the documentation show how to connect to Mi Home, discover devices, read and set properties, invoke actions, fetch device statuses, and access device lists and configurations through the provided resource URIs.
How to install
Prerequisites:
- Python 3.8+ and pip
- Access to the repository containing the Miot MCP agent (miot-agent)
Installation steps:
- Create and activate a Python virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
- Install dependencies from requirements.txt:
pip install -r requirements.txt
- Set up environment variables (adjust to your credentials or use a secrets manager):
export MIJIA_USERNAME="your_username"
export MIJIA_PASSWORD="your_password"
export MIJIA_ENABLE_QR="false" # set to true to enable QR login
export MIJIA_LOG_LEVEL="INFO" # DEBUG|INFO|WARNING|ERROR
- Run the MCP server:
python mcp_server/mcp_server.py
- (Optional) Run tests to verify connectivity:
python mcp_test.py
Note: If you modify the server code or configuration, restart the server to apply changes.
Additional notes
Tips and common issues:
- Ensure MIJIA_USERNAME and MIJIA_PASSWORD are correct; authentication failures are reported as AUTHENTICATION_FAILED.
- Enabling MIJIA_ENABLE_QR allows login via QR code; ensure the environment supports the needed GUI operations if using QR on a headless server.
- MIJIA_LOG_LEVEL controls the verbosity of logs; use DEBUG for troubleshooting.
- The server exposes a rich set of tools for device management, including connect, discover_devices, get_property_value, set_property_value, batch_set_properties, call_action, get_device_status, refresh_all_device_status, get_homes, get_scenes_list, run_scene, get_consumable_items, and various resources under mijia:// URIs.
- When integrating with AI tools, provide the proper python path to mcp_server.py and pass environment variables as shown in the configuration examples.
- If you run behind a firewall or VPN, ensure outbound access to Mi Home services is allowed for successful authentication and device discovery.
Related MCP Servers
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
mcp-yfinance
Real-time stock API with Python, MCP server example, yfinance stock analysis dashboard
pfsense
pfSense MCP Server enables security administrators to manage their pfSense firewalls using natural language through AI assistants like Claude Desktop. Simply ask "Show me blocked IPs" or "Run a PCI compliance check" instead of navigating complex interfaces. Supports REST/XML-RPC/SSH connections, and includes built-in complian
cloudwatch-logs
MCP server from serkanh/cloudwatch-logs-mcp
servicenow-api
ServiceNow MCP Server and API Wrapper
the -company
TheMCPCompany: Creating General-purpose Agents with Task-specific Tools