The Home Assistant MCP server allows AI assistants to control your Home Assistant devices through the Model Context Protocol (MCP). This integration provides tools for searching entities, controlling devices, and managing light colors and brightness in your smart home.
Follow these steps to install the Home Assistant MCP server:
cd home-assistant
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -U pip
pip install uv
uv pip install -e .
Add the following configuration to your MCP configuration in Cursor:
{
"mcpServers": {
"home_assistant": {
"command": "uv",
"args": [
"--directory",
"/path/to/your/home-assistant-mcp",
"run",
"main.py"
],
"env": {
"HOME_ASSISTANT_TOKEN": "your_home_assistant_token_here"
},
"inheritEnv": true
}
}
}
Be sure to replace:
/path/to/your/home-assistant-mcp
with the actual path to the installation directoryyour_home_assistant_token_here
with your Home Assistant Long-Lived Access TokenBy default, the MCP connects to Home Assistant at http://homeassistant.local:8123
.
If your Home Assistant instance uses a different URL, you can modify the HA_URL
variable in app/config.py
.
Once configured properly, you can use Cursor AI to control your Home Assistant devices with natural language commands:
The MCP supports advanced light control capabilities:
You can set any RGB color for compatible lights:
set_device_color("light.living_room", 255, 0, 0)
for redAdjust the brightness of your lights:
set_device_color("light.dining_room", 0, 0, 255, brightness=128)
for medium-bright blueIf you encounter issues while using the MCP server:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.