Home Assistant MCP server

Integrates with Home Assistant to enable natural language control of smart home devices, querying device states, troubleshooting automations, and summarizing home configurations through a Docker container that communicates with the Home Assistant API.
Back to servers
Setup instructions
Provider
Matt Voska
Release date
Mar 17, 2025
Language
Python
Stats
116 stars

Hass-MCP is a Model Context Protocol server that enables AI assistants like Claude to interact directly with your Home Assistant instance. It allows for querying device states, controlling smart home entities, and getting summaries of your home automation setup through a standardized interface.

Installation

Prerequisites

  • Home Assistant instance with Long-Lived Access Token
  • Docker (recommended) or Python 3.13+ with uv

Docker Installation (Recommended)

  1. Pull the Docker image:
docker pull voska/hass-mcp:latest
  1. Configure with your preferred MCP client (see specific instructions below)

Client Setup

Claude Desktop Setup

  1. Open Claude Desktop and go to Settings
  2. Navigate to Developer > Edit Config
  3. Add the following configuration to your claude_desktop_config.json file:
{
  "mcpServers": {
    "hass-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "HA_URL",
        "-e",
        "HA_TOKEN",
        "voska/hass-mcp"
      ],
      "env": {
        "HA_URL": "http://homeassistant.local:8123",
        "HA_TOKEN": "YOUR_LONG_LIVED_TOKEN"
      }
    }
  }
}
  1. Replace YOUR_LONG_LIVED_TOKEN with your actual Home Assistant long-lived access token
  2. Update the HA_URL:
    • If running Home Assistant on the same machine: use http://host.docker.internal:8123 (Docker Desktop on Mac/Windows)
    • If running Home Assistant on another machine: use the actual IP or hostname
  3. Save the file and restart Claude Desktop
  4. The "Hass-MCP" tool should now appear in your Claude Desktop tools menu

Note: If you're running Home Assistant in Docker on the same machine, you may need to add --network host to the Docker args for the container to access Home Assistant. Alternatively, use the IP address of your machine instead of host.docker.internal.

Cursor Setup

  1. Go to Cursor Settings > MCP > Add New MCP Server
  2. Fill in the form:
    • Name: Hass-MCP
    • Type: command
    • Command: docker run -i --rm -e HA_URL=http://homeassistant.local:8123 -e HA_TOKEN=YOUR_LONG_LIVED_TOKEN voska/hass-mcp
  3. Replace YOUR_LONG_LIVED_TOKEN with your actual Home Assistant token
  4. Update the HA_URL to match your Home Assistant instance address
  5. Click "Add" to save

Claude Code (CLI) Setup

To use with Claude Code CLI, add the MCP server directly using the mcp add command:

claude mcp add hass-mcp -e HA_URL=http://homeassistant.local:8123 -e HA_TOKEN=YOUR_LONG_LIVED_TOKEN -- docker run -i --rm -e HA_URL -e HA_TOKEN voska/hass-mcp

Replace YOUR_LONG_LIVED_TOKEN with your actual Home Assistant token and update the HA_URL to match your Home Assistant instance address.

Usage Examples

Once Hass-MCP is set up, you can use prompts like these with Claude:

  • "What's the current state of my living room lights?"
  • "Turn off all the lights in the kitchen"
  • "List all my sensors that contain temperature data"
  • "Give me a summary of my climate entities"
  • "Create an automation that turns on the lights at sunset"
  • "Help me troubleshoot why my bedroom motion sensor automation isn't working"
  • "Search for entities related to my living room"

Available Tools

Hass-MCP provides several tools for interacting with Home Assistant:

  • get_version: Get the Home Assistant version
  • get_entity: Get the state of a specific entity with optional field filtering
  • entity_action: Perform actions on entities (turn on, off, toggle)
  • list_entities: Get a list of entities with optional domain filtering and search
  • search_entities_tool: Search for entities matching a query
  • domain_summary_tool: Get a summary of a domain's entities
  • list_automations: Get a list of all automations
  • call_service_tool: Call any Home Assistant service
  • restart_ha: Restart Home Assistant
  • get_history: Get the state history of an entity
  • get_error_log: Get the Home Assistant error log

Guided Conversations

Hass-MCP includes several prompts for guided conversations:

  • create_automation: Guide for creating Home Assistant automations based on trigger type
  • debug_automation: Troubleshooting help for automations that aren't working
  • troubleshoot_entity: Diagnose issues with entities
  • routine_optimizer: Analyze usage patterns and suggest optimized routines
  • automation_health_check: Review all automations, find conflicts or redundancies
  • entity_naming_consistency: Audit entity names and suggest standardization improvements
  • dashboard_layout_generator: Create optimized dashboards based on user preferences

Available Resources

Hass-MCP provides the following resource endpoints:

  • hass://entities/{entity_id}: Get the state of a specific entity
  • hass://entities/{entity_id}/detailed: Get detailed information about an entity with all attributes
  • hass://entities: List all Home Assistant entities grouped by domain
  • hass://entities/domain/{domain}: Get a list of entities for a specific domain
  • hass://search/{query}/{limit}: Search for entities matching a query with custom result limit

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "hass-mcp" '{"command":"docker","args":["run","-i","--rm","-e","HA_URL","-e","HA_TOKEN","voska/hass-mcp"],"env":{"HA_URL":"http://homeassistant.local:8123","HA_TOKEN":"YOUR_LONG_LIVED_TOKEN"}}'

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "hass-mcp": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-e",
                "HA_URL",
                "-e",
                "HA_TOKEN",
                "voska/hass-mcp"
            ],
            "env": {
                "HA_URL": "http://homeassistant.local:8123",
                "HA_TOKEN": "YOUR_LONG_LIVED_TOKEN"
            }
        }
    }
}

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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "hass-mcp": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-e",
                "HA_URL",
                "-e",
                "HA_TOKEN",
                "voska/hass-mcp"
            ],
            "env": {
                "HA_URL": "http://homeassistant.local:8123",
                "HA_TOKEN": "YOUR_LONG_LIVED_TOKEN"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

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