Hermejia
Hermejia
π English Β· δΈζ Β· ζ₯ζ¬θͺ
Hermes + Mijia = Hermejia
A one-click MCP server that lets any AI agent control Xiaomi Mi Home (Mijia) smart devices through natural language.
β¨ What is this?
Hermejia wraps the mijiaAPI library into a Model Context Protocol (MCP) server. After a one-time QR-code login, your AI agent can:
List homes, rooms, devices, and scenes
Read device properties (temperature, brightness, power, etc.)
Set properties and run actions
Turn devices on/off/toggle or run entire scenes
π Quick Start
# 1. Clone
git clone https://github.com/HuishanLi1997/HuishanLi1997.git
cd Hermejia
# 2. One-click setup (creates venv, installs deps, runs QR auth)
bash scripts/setup.sh
# 3. Add the generated MCP config to your agent and restart itAfter setup, open mcp_config.json (or the config printed by setup.sh) and add it to your agent.
π Requirements
Linux / macOS / WSL (Windows is untested but may work)
Python 3.10+
Mi Home app on your phone for QR-code login
π§ Manual Installation
git clone https://github.com/HuishanLi1997/HuishanLi1997.git
cd Hermejia
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtπ Authentication
Xiaomi requires QR-code login for new devices. Run the helper and scan the generated QR code with the Mi Home app:
source venv/bin/activate
python scripts/auth_login.pyThe token is saved to ~/.config/mijia-api/auth.json by default. To use a custom path:
export MIJIA_AUTH_PATH=/path/to/your/auth.json
python scripts/auth_login.pyTokens last about 30 days; re-run auth_login.py to refresh.
π€ Agent Configuration
Generic stdio MCP
{
"mcpServers": {
"hermejia": {
"type": "stdio",
"command": "/full/path/to/Hermejia/venv/bin/python",
"args": ["-m", "mijia"],
"env": {
"PYTHONPATH": "/full/path/to/Hermejia"
}
}
}
}Hermes Agent
Add to ~/.hermes/config.yaml:
mcp_servers:
hermejia:
command: "/full/path/to/Hermejia/venv/bin/python"
args: ["-m", "mijia"]
workdir: "/full/path/to/Hermejia"
env:
PYTHONPATH: "/full/path/to/Hermejia"
timeout: 30Kimi CLI / Other stdio MCP clients
Use the mcp_config.json generated in the project root and point your client to it.
Claude Desktop / Cursor
Copy the mcpServers block from mcp_config.json into your client config and adjust paths.
See docs/CONFIG.md for detailed per-client examples.
π οΈ Available Tools
Tool | Description |
| List all Mi Home homes |
| List devices (optionally filtered by home) |
| Show supported properties and actions |
| Get all property values |
| Get a single property value |
| Set a property value |
| Run a device action |
| High-level control: |
| List automations/scenes |
| Run a scene by ID |
π§ͺ Testing
source venv/bin/activate
python test_mijia.pyFor interactive testing:
python test_mijia.py -iπ Project Structure
Hermejia/
βββ mijia.py # MCP server (core tools)
βββ mcp_pipe.py # WebSocket stdio bridge for Xiaozhi-like clients
βββ test_mijia.py # Test / interactive CLI
βββ scripts/
β βββ setup.sh # One-click setup
β βββ auth_login.py # QR-code auth + long-poll login
β βββ auto_qr.py # Auto-refresh QR code while waiting
β βββ gen_qrcode.py # Generate QR image only
βββ docs/
β βββ CONFIG.md # Per-agent configuration guide
βββ requirements.txt
βββ mcp_config.json
βββ LICENSE
βββ README.mdβ οΈ Troubleshooting
Issue | Solution |
QR code expires before scanning | Use |
| Make sure the MCP |
Agent does not see tools | Restart the agent process; MCP tools are loaded at startup |
Token expired | Re-run |
π License
MIT β Copyright (c) 2026 scsagentclub.
Core MCP server files are derived from oujiafan/mcp-mijia, also under MIT.