GitHub Spotlight: ha-mcp – Control Your Smart Home with AI Context

GitHub Spotlight: ha-mcp – Control Your Smart Home with AI Context
⚡ TL;DR / Quick Take:

  • What it is: An open-source Model Context Protocol (MCP) server for Home Assistant with over 5,000 stars and 87 built-in tools.
  • Key capability: Allows AI assistants like Claude Desktop to control devices, run automations, inspect logs, and modify state using natural conversational commands.
  • Who should use it: Home automation enthusiasts, power users, and developers looking to give LLMs direct agency over smart home infrastructure.

Smart home interfaces are notoriously rigid. Standard voice assistants like Alexa or Google Assistant struggle when you ask them to handle multi-step reasoning, check edge-case device states, or help debug complex automations. You are usually stuck picking specific phrases, toggling options in dense mobile dashboards, or manually crafting YAML config files.

ha-mcp changes how you manage Home Assistant. Built by developer Julien LD and the homeassistant-ai community, this project bridges Anthropic’s open Model Context Protocol (MCP) directly into your Home Assistant environment.

Instead of treating your smart home like a set of disjointed switches, ha-mcp gives an AI model direct tool access to your entire Home Assistant instance. You can sit down with Claude Desktop, ask simple natural-language questions, execute intricate scripts, or overhaul your setup without touching a single code editor.


Why Home Assistant MCP Matters

Standard smart home voice control lacks context. If you say, “Turn off everything in the house except the living room lamp and make sure the garage door is down,” traditional assistants usually fall flat or execute half the command incorrectly.

ha-mcp solves this problem by exposing 87 distinct tools to any AI client that speaks MCP. Rather than relying on simple endpoint calls, the AI can:

  1. Read live device telemetry: Query entity states, battery levels, temperature readouts, and history logs.
  2. Execute home automation tasks: Trigger scenes, call service domains (light.turn_off, climate.set_temperature), and manage scripts.
  3. Inspect and edit configurations: Debug failing automations, evaluate Jinja templates, and examine state histories.

By wrapping Home Assistant’s native API inside the standard Model Context Protocol, your AI assistant turns into an active co-pilot for your house.


How ha-mcp Works Behind the Scenes

The architecture connects your desktop or cloud AI client straight to your Home Assistant hub using an internal or external webhook connection.

graph TD
    A[User Natural Language Prompt] --> B[AI Client / Claude Desktop]
    B --> C[MCP Protocol Client]
    C -- Webhook Request --> D[ha-mcp HACS Integration]
    D --> E[Home Assistant Core API]
    E --> F[Smart Home Devices & Automations]
    F -- State Updates / Responses --> E
    E --> D
    D --> C
    C --> B
    B --> G[Detailed AI Answer or Confirmation]

The easiest way to run ha-mcp is as an in-process Custom Component installed via HACS (Home Assistant Community Store). Running inside Home Assistant natively removes the need to generate, refresh, or manually manage long-lived API access tokens.


Comparing ha-mcp to Traditional Smart Home Control

Here is how ha-mcp stacks up against traditional voice control and basic manual webhooks:

Feature Standard Voice Control Basic REST API / Webhooks ha-mcp Server
Multi-Step Reasoning No. Single-intent commands only. Requires custom client code. Yes. Native LLM tool loop.
Available Tools Basic turn on/off, temperature. Manual endpoint mapping. 87 pre-packaged MCP tools.
Authentication Setup Account linking required. Long-lived access tokens. Zero-token HACS integration webhook.
Automation Diagnostics None. Manual log parsing. Direct history & state inspection.

Real-World Use Cases

What can you actually build or do once ha-mcp is tied to an intelligent client like Claude Desktop?

1. Smart Auditing and Diagnostics

Instead of clicking through dozens of devices in the Home Assistant frontend to see why your heating turned on unexpectedly, ask:

“Check the state history of my main thermostat for the last two hours. Which entity triggered it to turn on, and what was the temperature sensor reading at that time?”

The AI uses tools like ha_get_history and ha_get_state to inspect the exact trace data and output a concise explanation.

2. Dynamic Context-Aware Scenes

Static scenes often fail under changing conditions. With ha-mcp, you can issue broad context statements:

“I’m about to start a movie in the basement. Check if any lights are on down there, set the main lights to 10% warm white, make sure the soundbar is powered up, and tell me if the back entry door is currently unlocked.”

The model evaluates device states sequentially, calls light.turn_on with exact color parameters, queries the lock state, and responds with a progress summary.

3. Complex Automation Crafting

Creating multi-condition automations using Jinja2 templates in Home Assistant can be tedious. You can simply ask:

“Write and test a Home Assistant automation that turns on the porch light when motion is detected, but only if it’s after sunset and no one is currently in the living room.”

The AI drafts the exact YAML logic, runs template evaluations using the built-in MCP rendering tools, and helps you apply it safely.


Quickstart: Installing ha-mcp via HACS

The primary and recommended method to install ha-mcp is via the HA-MCP Custom Component using HACS. This ensures full feature parity across Home Assistant OS, Supervised, Container, and Core setups.

# Step 1: Open Home Assistant
# Step 2: Go to HACS -> Integrations -> Top-right menu (⋮) -> Custom repositories
# Step 3: Add Repository URL: https://github.com/homeassistant-ai/ha-mcp-integration
# Step 4: Set Category to "Integration", then click "Download"

After downloading the component:

  1. Restart Home Assistant to register the new integration files.
  2. Navigate to Settings → Devices & Services → Add Integration.
  3. Search for HA-MCP Custom Component, select HA-MCP Server, and click Submit.
  4. Click Configure on the newly created integration entry to grab your unique webhook connection URL:
    https://<your-ha-domain>/api/webhook/<webhook-id>

Connecting ha-mcp to Claude Desktop

To connect ha-mcp to your local Claude Desktop app, add the server details to your local claude_desktop_config.json file.

On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%\Claude\claude_desktop_config.json

Add the following configuration block:

{
  "mcpServers": {
    "home-assistant": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-fetch",
        "https://<your-ha-domain>/api/webhook/<webhook-id>"
      ]
    }
  }
}

Note: Replace <your-ha-domain> and <webhook-id> with the exact URL provided in your Home Assistant Configure screen.

Restart Claude Desktop. You will see a small hammer icon indicating that the Home Assistant tools are loaded and ready to process requests.


Common Myths and Pitfalls

When getting started with ha-mcp, keep these key considerations in mind:

  • Myth: “ha-mcp replaces local Home Assistant voice control.”
    Fact: ha-mcp is designed primarily for Model Context Protocol clients like Claude Desktop, Cursor, or specialized backend LLM workers. It complements, rather than replaces, local hardware voice pipelines like Home Assistant Assist.
  • Pitfall: Exposing Webhooks Unsafely.
    Always use a secure reverse proxy (like Nabu Casa, Cloudflare Tunnels, or Caddy) with valid SSL certificates if you connect remote MCP clients to your home instance.
  • Myth: “AI will randomly toggle my critical switches without permission.”
    Fact: Most MCP clients require explicit user approval before executing state-changing tools unless configured to run automatically. You remain in control of device execution.

Actionable Tips for Best Results

  1. Assign Clear Entity Names: Ensure your Home Assistant entities have descriptive friendly names (e.g., light.living_room_ceiling_light instead of light.light_bulb_1). This helps the LLM select the right tool targets instantly.
  2. Limit Scope During Initial Setup: Test basic queries ("What temperature is the hallway?") before asking the AI to batch-execute state changes across multiple rooms.
  3. Use History Tools for Debugging: If an automation fails, prompt the AI to run ha_get_history on the affected entity over the past 30 minutes to identify broken triggers quickly.

Take Control of Your Home with AI Context

ha-mcp provides a practical, production-ready solution for managing your smart home through natural language. With 87 built-in tools, zero-token HACS integration, and native support for the Model Context Protocol, it eliminates the friction between high-level reasoning models and physical hardware control.

Install the integration through HACS, connect it to Claude Desktop, and start managing your Home Assistant environment with natural conversational commands today.

📂 Explore the open-source repository on GitHub: https://github.com/homeassistant-ai/ha-mcp

Leave a Reply

Your email address will not be published. Required fields are marked *