Home Assistant MCP server

Enables direct control of smart home devices through Home Assistant API, allowing natural language searching of entities and management of device states, light colors, and brightness levels.
Back to servers
Provider
hpohlmann
Release date
Mar 16, 2025
Language
Python
Stats
21 stars

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.

Prerequisites

  • Python 3.11 or higher
  • Home Assistant instance running and accessible via API
  • Home Assistant Long-Lived Access Token

Installation

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 .

Configuration

Getting a Home Assistant Access Token

  1. Go to your Home Assistant instance
  2. Navigate to your profile (click on your username in the sidebar)
  3. Scroll down to "Long-Lived Access Tokens"
  4. Create a new token with a descriptive name like "MCP Integration"
  5. Copy the token (you'll only see it once)

Setting up Cursor AI Integration

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 directory
  • your_home_assistant_token_here with your Home Assistant Long-Lived Access Token

Customizing Home Assistant URL

By 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.

Using the MCP Server

Once configured properly, you can use Cursor AI to control your Home Assistant devices with natural language commands:

Basic Commands

  • Finding devices: "Find my living room lights"
  • Controlling devices: "Turn on the kitchen light"
  • Setting colors: "Set my living room lights to red"
  • Adjusting brightness: "Set my dining room lights to blue at 50% brightness"

Light Control Features

The MCP supports advanced light control capabilities:

Color Control

You can set any RGB color for compatible lights:

  • Specify colors using RGB values (0-255 for each component)
  • Example: set_device_color("light.living_room", 255, 0, 0) for red

Brightness Control

Adjust the brightness of your lights:

  • Brightness parameter ranges from 0-255
  • Can be combined with color changes
  • Example: set_device_color("light.dining_room", 0, 0, 255, brightness=128) for medium-bright blue

Troubleshooting

If you encounter issues while using the MCP server:

  • Authentication errors: Verify your token is correct and has not expired
  • Connection issues: Check that your Home Assistant instance is reachable at the configured URL
  • Color control problems:
    • Ensure your light entity supports RGB color control
    • Verify the light is turned on before attempting to change colors

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later