MCP ExplorerExplorer

Hass

@voskaon 10 months ago
98 MIT
FreeCommunity
System Tools
#Home Assistant#Claude#LLM#Automation
Docker-ready MCP server for Home Assistant with entity management, domain summaries, automation support, and guided conversations. Includes pre-built container images for easy installation.

Overview

What is Hass

Hass-MCP is a Model Context Protocol server designed for integrating AI assistants like Claude with Home Assistant. It facilitates direct interaction, allowing AI to control smart devices, query statuses, troubleshoot issues, and provide summaries of the smart home environment.

Use cases

Users can leverage Hass-MCP to check the status of their devices, control lights and switches, summarize their smart home, troubleshoot automations, search for specific entities, and engage in guided conversations for tasks such as creating new automations.

How to use

To set up Hass-MCP, users can install it via Docker or Python. For Docker, users need to pull the image and configure their Claude or other MCP clients to connect with their Home Assistant instance using a long-lived access token and the appropriate Home Assistant URL.

Key features

Hass-MCP offers features such as entity management, domain summaries, automation support, guided conversations for common tasks, smart search capabilities, and token-efficient JSON responses to optimize interactions.

Where to use

Hass-MCP is intended for use in environments where Home Assistant is deployed, allowing seamless interaction with a smart home setup through AI assistants across various platforms, including Claude Desktop and other MCP clients.

Content

Hass-MCP

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

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.

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.

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”
  • “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

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

Tools

get_version
Get the Home Assistant version Returns: A string with the Home Assistant version (e.g., "2025.3.0")
get_entity
Get the state of a Home Assistant entity with optional field filtering Args: entity_id: The entity ID to get (e.g. 'light.living_room') fields: Optional list of fields to include (e.g. ['state', 'attr.brightness']) detailed: If True, returns all entity fields without filtering Examples: entity_id="light.living_room" - basic state check entity_id="light.living_room", fields=["state", "attr.brightness"] - specific fields entity_id="light.living_room", detailed=True - all details
entity_action
Perform an action on a Home Assistant entity (on, off, toggle) Args: entity_id: The entity ID to control (e.g. 'light.living_room') action: The action to perform ('on', 'off', 'toggle') **params: Additional parameters for the service call Returns: The response from Home Assistant Examples: entity_id="light.living_room", action="on", brightness=255 entity_id="switch.garden_lights", action="off" entity_id="climate.living_room", action="on", temperature=22.5 Domain-Specific Parameters: - Lights: brightness (0-255), color_temp, rgb_color, transition, effect - Covers: position (0-100), tilt_position - Climate: temperature, target_temp_high, target_temp_low, hvac_mode - Media players: source, volume_level (0-1)
list_entities
Get a list of Home Assistant entities with optional filtering Args: domain: Optional domain to filter by (e.g., 'light', 'switch', 'sensor') search_query: Optional search term to filter entities by name, id, or attributes (Note: Does not support wildcards. To get all entities, leave this empty) limit: Maximum number of entities to return (default: 100) fields: Optional list of specific fields to include in each entity detailed: If True, returns all entity fields without filtering Returns: A list of entity dictionaries with lean formatting by default Examples: domain="light" - get all lights search_query="kitchen", limit=20 - search entities domain="sensor", detailed=True - full sensor details Best Practices: - Use lean format (default) for most operations - Prefer domain filtering over no filtering - For domain overviews, use domain_summary_tool instead of list_entities - Only request detailed=True when necessary for full attribute inspection - To get all entity types/domains, use list_entities without a domain filter, then extract domains from entity_ids
search_entities_tool
Search for entities matching a query string Args: query: The search query to match against entity IDs, names, and attributes. (Note: Does not support wildcards. To get all entities, leave this blank or use list_entities tool) limit: Maximum number of results to return (default: 20) Returns: A dictionary containing search results and metadata: - count: Total number of matching entities found - results: List of matching entities with essential information - domains: Map of domains with counts (e.g. {"light": 3, "sensor": 2}) Examples: query="temperature" - find temperature entities query="living room", limit=10 - find living room entities query="", limit=500 - list all entity types
domain_summary_tool
Get a summary of entities in a specific domain Args: domain: The domain to summarize (e.g., 'light', 'switch', 'sensor') example_limit: Maximum number of examples to include for each state Returns: A dictionary containing: - total_count: Number of entities in the domain - state_distribution: Count of entities in each state - examples: Sample entities for each state - common_attributes: Most frequently occurring attributes Examples: domain="light" - get light summary domain="climate", example_limit=5 - climate summary with more examples Best Practices: - Use this before retrieving all entities in a domain to understand what's available
1 / 2

Comments

Recommend MCP Servers

View All MCP Servers