Skip to main content

Home Assistant Model Context Protocol (MCP) server

Project description

Hass-MCP

A Model Context Protocol (MCP) server for Home Assistant integration with Claude and other LLMs.

Hass-MCP MCP server

Overview

Hass-MCP enables AI assistants like Claude to interact directly with your Home Assistant instance, allowing them to:

  • Query the state of devices and sensors
  • Control lights, switches, and other entities
  • Get summaries of your smart home
  • Troubleshoot automations and entities
  • Search for specific entities
  • Create guided conversations for common tasks

Screenshots

Screenshot 2025-03-16 at 15 48 01 Screenshot 2025-03-16 at 15 50 59 Screenshot 2025-03-16 at 15 49 26

Features

  • Entity Management: Get states, control devices, and search for entities
  • Domain Summaries: Get high-level information about entity types
  • Automation Support: List and control automations
  • Guided Conversations: Use prompts for common tasks like creating automations
  • Smart Search: Find entities by name, type, or state
  • Token Efficiency: Lean JSON responses to minimize token usage

Installation

Prerequisites

  • Home Assistant instance with Long-Lived Access Token
  • One of the following:
    • Docker (recommended)
    • Python 3.13+ and uv

Setting Up With Claude Desktop

Docker Installation (Recommended)

  1. Pull the Docker image:

    docker pull voska/hass-mcp:latest
    
  2. Add the MCP server to Claude Desktop:

    a. Open Claude Desktop and go to Settings b. Navigate to Developer > Edit Config c. 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"
          }
        }
      }
    }
    

    d. Replace YOUR_LONG_LIVED_TOKEN with your actual Home Assistant long-lived access token e. 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

    f. Save the file and restart Claude Desktop

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

uv/uvx

  1. Install uv on your system.

  2. Add the MCP server to Claude Desktop:

    a. Open Claude Desktop and go to Settings b. Navigate to Developer > Edit Config c. Add the following configuration to your claude_desktop_config.json file:

    {
      "mcpServers": {
        "hass-mcp": {
          "command": "uvx",
          "args": ["hass-mcp"],
          "env": {
            "HA_URL": "http://homeassistant.local:8123",
            "HA_TOKEN": "YOUR_LONG_LIVED_TOKEN"
          }
        }
      }
    }
    

    d. Replace YOUR_LONG_LIVED_TOKEN with your actual Home Assistant long-lived access token e. 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

    f. Save the file and restart Claude Desktop

  3. The "Hass-MCP" tool should now appear in your Claude Desktop tools menu

Other MCP Clients

Cursor

  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
      
    • Replace YOUR_LONG_LIVED_TOKEN with your actual Home Assistant token
    • Update the HA_URL to match your Home Assistant instance address
  3. Click "Add" to save

Claude Code (CLI)

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

Using Docker (recommended):

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.

HTTP Transport (Streamable)

For deployments that can't use stdio — running behind an MCP gateway, hosting on Smithery, sharing one server across multiple clients, or connecting from network-based tools like LibreChat or OpenWebUI — Hass-MCP supports the MCP streamable HTTP transport. The server runs in stateless mode (no Mcp-Session-Id, JSON responses), suitable for horizontally-scaled hosts.

[!CAUTION] HTTP mode exposes full Home Assistant control over the network. Anyone who can reach the port can call any tool — turn off lights, unlock doors, trigger automations, restart HA. The MCP spec does not yet ship a built-in auth layer in this server. Until it does, you must put it behind one of:

  • A reverse proxy (nginx, Caddy, Traefik) doing basic-auth or bearer-token validation
  • A VPN or zero-trust network (Tailscale, WireGuard, Cloudflare Access)
  • Localhost binding only (the default — change --host only if you know what you're doing)

Do not expose :8000 to the open internet without auth.

Running locally

Using uvx:

HA_URL=http://homeassistant.local:8123 \
HA_TOKEN=YOUR_LONG_LIVED_TOKEN \
uvx hass-mcp --http --port 8000

The server binds 127.0.0.1 by default. Override with --host 0.0.0.0 only when you've also configured auth in front of it.

Running in Docker

docker run --rm -p 8000:8000 \
  -e HA_URL=http://homeassistant.local:8123 \
  -e HA_TOKEN=YOUR_LONG_LIVED_TOKEN \
  voska/hass-mcp:latest --http --host 0.0.0.0 --port 8000

--host 0.0.0.0 is required inside Docker so the port is reachable through the bridge. Bind the publish (-p) to 127.0.0.1:8000:8000 if you only want it reachable from the host, or put a reverse proxy in front.

Endpoint

The MCP endpoint is at /mcp. Point your client at http://<host>:<port>/mcp.

Smithery / PaaS

The server honors the PORT environment variable (Smithery's convention) in addition to MCP_PORT. Smithery deployment requires --http mode and reads PORT automatically.

Usage Examples

Here are some examples of prompts you can use with Claude once Hass-MCP is set up:

  • "What's the current state of my living room lights?"
  • "Turn off all the lights in the kitchen"
  • "What's the temperature in the master bedroom?"
  • "List everything in the guest room"
  • "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
  • get_entities_by_area: List entities in a specific area / room

Prompts for 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 based on actual behavior
  • automation_health_check: Review all automations, find conflicts, redundancies, or improvement opportunities
  • entity_naming_consistency: Audit entity names and suggest standardization improvements
  • dashboard_layout_generator: Create optimized dashboards based on user preferences and usage patterns

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

Development

Running Tests

uv run pytest tests/

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hass_mcp-0.4.0.tar.gz (73.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hass_mcp-0.4.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file hass_mcp-0.4.0.tar.gz.

File metadata

  • Download URL: hass_mcp-0.4.0.tar.gz
  • Upload date:
  • Size: 73.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hass_mcp-0.4.0.tar.gz
Algorithm Hash digest
SHA256 248f916cc0e7c18ce7be7864e3db49e9d9e7ca298f771d9993ae8b2559330fca
MD5 8576f46e2839d110f4d05726926e3a9f
BLAKE2b-256 ed42b09c97dc1f43ae6846e38f1ad44ce8e886a93db19fe9e86ecf5b5e0cc8c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for hass_mcp-0.4.0.tar.gz:

Publisher: release.yml on voska/hass-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hass_mcp-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: hass_mcp-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hass_mcp-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50a48688ea3178a16a2ccb7873bf85c16071daed7fe22b9d2b225c39bf517ad5
MD5 0c25d464666074cfc5df8343fb58b055
BLAKE2b-256 c3b22f7e0187f8925dc5caa4d759567477265e5c4b2ea256361315059329c132

See more details on using hashes here.

Provenance

The following attestation bundles were made for hass_mcp-0.4.0-py3-none-any.whl:

Publisher: release.yml on voska/hass-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page