Aqara MCP Server is a smart home automation control service built on the Model Context Protocol (MCP). This platform enables seamless integration between AI assistants (like Claude, Cursor, etc.) and the Aqara smart home ecosystem.
- Table of Contents
- Features
- How It Works
- Quick Start
- API Reference
- Project Structure
- Development & Contribution
- License
- ✨ Comprehensive Device Control: Fine-grained control over various attributes of Aqara smart devices, including on/off, brightness, color temperature, and modes.
- 🔍 Flexible Device Query: Ability to query device lists and their detailed statuses by room or device type.
- 🎬 Smart Scene Management: Supports querying and executing user-predefined smart home scenes.
- 📈 Device History: Query the historical status change records of devices within a specified time range.
- ⏰ Automation Configuration: Supports configuring scheduled or delayed device control tasks.
- 🏠 Multi-Home Support: Supports querying and switching between different homes under a user's account.
- 🔌 MCP Protocol Compatibility: Fully compliant with the MCP specification, allowing for easy integration with various AI assistants.
- 🔐 Secure Authentication: Utilizes a login authorization + signature-based security mechanism to protect user data and device security.
- 🌐 Cross-Platform: Developed in Go, can be compiled into executables for multiple platforms.
- 🔧 Easily Extensible: Modular design allows for the convenient addition of new tools and features.
Aqara MCP Server acts as a bridge between AI assistants and the Aqara smart home platform:
graph LR
A[AI Assistant - MCP Host] --> B[MCP Client]
B --> C[Aqara MCP Server]
C --> D[Aqara Cloud API]
D --> E[AIOT Devices]
- AI Assistant: The user issues a command through an AI assistant (e.g., "Turn on the living room light").
- MCP Client: Parses the user's command and calls the corresponding tool provided by the Aqara MCP Server (e.g.,
device_control
) according to the MCP protocol. - Aqara MCP Server (This Project): Receives the request from the client, communicates with the Aqara Cloud API using the configured Aqara credentials, and executes the actual device operation or data query.
- Response Flow: The Aqara Cloud API returns the result, which is passed back to the MCP client via the Aqara MCP Server and finally presented to the user.
- Aqara Account with registered smart devices.
- MCP-enabled Client (e.g., Claude for Desktop, Cursor).
- Go 1.24+ (only required for local deployment from source).
Regardless of the deployment mode, you first need to obtain Aqara authentication credentials:
-
Visit the Login Page: 🔗 https://cdn.aqara.com/app/mcpserver/login.html
-
Complete the Login Process:
- Log in with your Aqara credentials.
- Obtain the
api_key
andbase_url
.
-
Store Credentials Securely:
⚠️ Please keep yourapi_key
information safe and do not disclose it to others.
Choose the deployment method that suits your needs:
Suitable for: Users who want to get started quickly without local environment setup.
Advantages:
- ✅ Ready to Use: No need to download or compile; configure and use directly.
- ✅ Automatic Updates: The server is automatically maintained and updated.
- ✅ High Availability: Professional operations ensure service stability.
- ✅ Multi-Platform Compatibility: No operating system restrictions.
Configure MCP Client:
-
Open Settings:
- Launch Cursor.
-
Add Server Configuration:
{ "mcpServers": { "aqara": { "type": "http", "url": "https://[mcp-server-domain]/echo/mcp", // base_url "headers": { "Authorization": "Bearer [YOUR_API_KEY_HERE]" // api_key } } } }
-
Restart the Application:
- Restart Cursor for the changes to take effect.
Suitable for: Users who require data sovereignty, custom configurations, or offline use.
Advantages:
- ✅ Data Privacy: All data is processed locally.
- ✅ Full Control: Customizable configuration and extensible features.
- ✅ Offline Availability: Basic functions are not affected by network interruptions.
- ✅ No Restrictions: Not limited by cloud services.
Installation Steps:
-
Download the Program (choose one):
Recommended: Download Pre-compiled Version
Visit GitHub Releases to download the latest version for your operating system.
Alternatively: Build from Source
git clone https://github.com/aqara/aqara-mcp-server.git cd aqara-mcp-server go mod tidy go build -ldflags="-s -w" -o aqara-mcp-server
-
Set Environment Variables:
export aqara_api_key="your_api_key_here" export aqara_base_url="your_base_url_here"
Configure MCP Client (e.g., Claude for Desktop):
-
Open Settings:
- Launch Claude for Desktop.
- Navigate to: Settings → Developer.
-
Edit Configuration File:
- Click "Edit Configuration".
-
Add Server Configuration (claude_desktop_config.json):
{ "mcpServers": { "aqara": { "command": "/path/to/aqara-mcp-server", "args": ["run", "stdio"], "env": { "aqara_api_key": "your_api_key_here", "aqara_base_url": "your_base_url_here" } } } }
-
Restart the Application:
- Restart Claude for Desktop for the changes to take effect.
Use the following test commands to verify that the configuration is successful:
User: "Show all devices in my home"
Assistant: [Queries device list via MCP]
User: "Turn on the living room light"
Assistant: [Executes device control via MCP]
User: "Run the evening scene"
Assistant: [Executes scene via MCP]
If you see a message like "🔧 Connected to Aqara MCP Server," the configuration is successful!
Tool Category | Tool | Description |
---|---|---|
Device Control | device_control |
Direct device operations |
Device Query | device_query , device_status_query , device_log_query |
Comprehensive device information |
Scene Management | get_scenes , run_scenes |
Automated scene control |
Home Management | get_homes , switch_home |
Multi-home environment support |
Automation | automation_config |
Scheduled task configuration |
Controls the state or attributes of smart home devices (e.g., on/off, temperature, brightness, color, color temperature).
Parameters:
endpoint_ids
(Array<Integer>, required): A list of device IDs to be controlled.control_params
(Object, required): A control parameter object containing specific actions:action
(String, required): The action to perform (e.g.,"on"
,"off"
,"set"
,"up"
,"down"
,"cooler"
,"warmer"
).attribute
(String, required): The device attribute to control (e.g.,"on_off"
,"brightness"
,"color_temperature"
,"ac_mode"
).value
(String | Number, optional): The target value (required whenaction
is "set").unit
(String, optional): The unit of the value (e.g.,"%"
,"K"
,"℃"
).
Returns: A message indicating the result of the device control operation.
Retrieves a comprehensive list of devices based on specified locations (rooms) and device types, with support for filtering (does not include real-time status information).
Parameters:
positions
(Array<String>, optional): A list of room names. An empty array queries all rooms.device_types
(Array<String>, optional): A list of device types (e.g.,"Light"
,"WindowCovering"
,"AirConditioner"
,"Button"
). An empty array queries all types.
Returns: A Markdown-formatted list of devices, including device names and IDs.
Gets the current status information of devices (used to query real-time status like color, brightness, on/off).
Parameters:
positions
(Array<String>, optional): A list of room names. An empty array queries all rooms.device_types
(Array<String>, optional): A list of device types. Same options asdevice_query
. An empty array queries all types.
Returns: Markdown-formatted device status information.
Queries the historical log information of devices.
Parameters:
endpoint_ids
(Array<Integer>, required): A list of device IDs for which to query history.start_datetime
(String, optional): The query start time inYYYY-MM-DD HH:MM:SS
format (e.g.,"2023-05-16 12:00:00"
).end_datetime
(String, optional): The query end time inYYYY-MM-DD HH:MM:SS
format.attributes
(Array<String>, optional): A list of device attribute names to query (e.g.,["on_off", "brightness"]
). If not provided, all logged attributes are queried.
Returns: Markdown-formatted historical device status information.
Queries all scenes in a user's home or scenes in specified rooms.
Parameters:
positions
(Array<String>, optional): A list of room names. An empty array queries scenes for the entire home.
Returns: Markdown-formatted scene information.
Executes specified scenes by their scene IDs.
Parameters:
scenes
(Array<Integer>, required): A list of scene IDs to be executed.
Returns: A message indicating the result of the scene execution.
Gets a list of all homes under the user's account.
Parameters: None
Returns: A comma-separated list of home names. Returns an empty string or a corresponding message if no data is available.
Switches the user's currently active home. After switching, subsequent device queries, controls, etc., will target the newly switched home.
Parameters:
home_name
(String, required): The name of the target home.
Returns: A message indicating the result of the switch operation.
Configures automation (currently only supports scheduled or delayed device control tasks).
Parameters:
scheduled_time
(String, required): The scheduled execution time in standard Crontab format"min hour day month week"
. E.g.,"30 14 * * *"
(execute at 14:30 every day),"0 9 * * 1"
(execute at 9:00 every Monday).endpoint_ids
(Array<Integer>, required): A list of device IDs to be controlled on a schedule.control_params
(Object, required): Device control parameters, in the same format as thedevice_control
tool (including action, attribute, value, etc.).task_name
(String, required): The name or description of this automation task (for identification and management).execution_once
(Boolean, optional): Whether to execute only once.true
: Executes the task only once at the specified time (default).false
: Executes the task periodically (e.g., daily, weekly).
Returns: A message indicating the result of the automation configuration.
.
├── cmd.go # Cobra CLI command definitions and program entry point (contains main function)
├── server.go # Core MCP server logic, tool definitions, and request handling
├── smh.go # Aqara smart home platform API interface wrapper
├── middleware.go # Middleware: user authentication, timeout control, panic recovery
├── config.go # Global configuration management and environment variable handling
├── go.mod # Go module dependency management file
├── go.sum # Go module dependency checksum file
├── readme/ # README documents and image resources
│ ├── img/ # Image resource directory
│ └── *.md # Multi-language README files
├── LICENSE # MIT open source license
└── README.md # Main project document
cmd.go
: CLI implementation based on the Cobra framework, definingrun stdio
andrun http
start modes and the main entry function.server.go
: Core MCP server implementation, responsible for tool registration, request handling, and protocol support.smh.go
: Aqara smart home platform API wrapper layer, providing device control, authentication, and multi-home support.middleware.go
: Request handling middleware, providing authentication validation, timeout control, and exception handling.config.go
: Global configuration management, responsible for handling environment variables and API configuration.
# Clone the repository
git clone https://github.com/aqara/aqara-mcp-server.git
cd aqara-mcp-server
# Install dependencies
go mod tidy
# Run tests
go test ./...
# Optimized build
go build -ldflags="-s -w" -o aqara-mcp-server
- Go Language: Follows official Go coding standards.
- Documentation: Comprehensive API documentation.
- Testing: Minimum 80% code coverage.
- Security: Regular security audits.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add some amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright © 2025 Aqara-Copilot. All rights reserved.