mcp-mijia

mcp-mijia

Enables AI assistants to control Xiaomi Mi Home smart devices through natural language, supporting device listing, property control, actions, and scenes.

Category
Visit Server

README

MCP Mijia | 米家智能家居 MCP 服务

An MCP server for controlling Xiaomi Mi Home (Mijia) smart home devices, designed for use with Xiaozhi AI assistant.

用于控制小米米家智能家居设备的 MCP 服务器,专为小智 AI 助手设计。

Overview | 概述

This project provides an MCP (Model Context Protocol) server that enables AI assistants like Xiaozhi to control Xiaomi Mi Home smart devices through natural language commands. It supports listing devices, getting/setting properties, running actions, and executing scenes.

本项目提供一个 MCP 服务器,使小智等 AI 助手能够通过自然语言命令控制小米米家智能设备。支持列出设备、获取/设置属性、运行动作和执行场景。

Features | 特性

  • 🏠 List and manage multiple homes | 列出和管理多个家庭
  • 📱 Discover and control all Mi Home devices | 发现和控制所有米家设备
  • 💡 High-level device control (on/off/toggle) | 高级设备控制(开/关/切换)
  • ⚙️ Get and set device properties | 获取和设置设备属性
  • 🎬 Run device actions and scenes | 运行设备动作和场景
  • 🔍 Query device capabilities | 查询设备能力

Available Tools | 可用工具

Tool Description
list_homes List all homes in the Mi Home account
list_devices List all devices (optionally filter by home)
list_device_capabilities List available properties and actions for a device
get_device_properties Get all property values for a device
get_device_property Get a specific property value
set_device_property Set a property value on a device
run_device_action Run an action on a device
control_device High-level control: 'on', 'off', 'toggle', or 'property=value'
list_scenes List all scenes/automations
run_scene Run a scene by its ID

Quick Start | 快速开始

  1. Install dependencies | 安装依赖:
pip install -r requirements.txt
  1. First run authentication | 首次运行认证:
python test_mijia.py

Follow the prompts to log in with your Mi Home account by QR code on the first run.

首次运行时按照提示用二维码登录您的米家账号。

  1. Run with Xiaozhi | 配合小智运行:
export MCP_ENDPOINT=wss://api.xiaozhi.me/mcp/?token=xxx
python mcp_pipe.py mijia.py

Or run all configured servers | 或运行所有配置的服务:

export MCP_ENDPOINT=wss://api.xiaozhi.me/mcp/?token=xxx
python mcp_pipe.py
  1. Interactive mode for testing (optional) | 交互模式测试(可选):
python test_mijia.py -i

Enter commands interactively to test device control. | 交互式输入命令测试设备控制。

Commands:

  1. List device capabilities
  2. Get device properties
  3. Get specific property
  4. Set property
  5. Control device (on/off/toggle)
  6. Run device action
  7. List scenes
  8. Run scene

Configuration | 配置

Environment Variables | 环境变量

Variable Description
MIJIA_AUTH_PATH Custom path for authentication file (optional)
MCP_ENDPOINT WebSocket endpoint for Xiaozhi connection, such as wss://api.xiaozhi.me/mcp/?token=<YourToken>

MCP Config | MCP 配置

The mcp_config.json defines the server configuration:

{
  "mcpServers": {
    "local-stdio-mijia": {
      "type": "stdio",
      "command": "python",
      "args": ["-m", "mijia"]
    }
  }
}

Project Structure | 项目结构

File Description
mijia.py MCP server with all smart home control tools
mcp_pipe.py WebSocket communication pipe for Xiaozhi
mcp_config.json Server configuration
test_mijia.py Test script for verifying functionality

Usage Examples | 使用示例

Once connected to Xiaozhi, you can use natural language commands like:

连接小智后,您可以使用自然语言命令,例如:

  • "Turn on the living room light" | "打开客厅灯"
  • "Set bedroom light brightness to 50%" | "把卧室灯亮度设为50%"
  • "What's the temperature of the air conditioner?" | "空调温度是多少?"
  • "Run the 'Good Night' scene" | "执行'晚安'场景"
  • "List all my devices" | "列出所有设备"

Requirements | 环境要求

  • Python 3.10+
  • python-dotenv>=1.2.1
  • websockets>=15.0.1
  • mcp>=1.20.0
  • pydantic>=2.12.3
  • mcp-proxy>=0.10.0
  • fastmcp>=2.13.0
  • mijiaAPI>=3.0.0

Contributing | 贡献指南

Contributions are welcome! Please feel free to submit a Pull Request.

欢迎贡献代码!请随时提交 Pull Request。

License | 许可证

This project is licensed under the MIT License - see the LICENSE file for details.

本项目采用 MIT 许可证 - 详情请查看 LICENSE 文件。

Acknowledgments | 致谢

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured