- Python 99.7%
- Dockerfile 0.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
Auto Tag Release / Tag release from pyproject.toml version (push) Successful in 3s
Security / Security scan (push) Successful in 48s
Test & Build / Lint and test (push) Successful in 29s
Test & Build / Build & Push Docker Image (push) Successful in 5m22s
Test & Build / Create Forgejo Release (push) Successful in 2s
|
||
| .forgejo/workflows | ||
| app | ||
| tests | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| .python-version | ||
| .tool-versions | ||
| CHANGELOG.md | ||
| CLAUDE.md | ||
| docker-compose.yml | ||
| Dockerfile | ||
| LICENSE | ||
| pyproject.toml | ||
| README.md | ||
| Taskfile.yml | ||
Hass-MCP
A Model Context Protocol (MCP) server for Home Assistant integration with Claude and other LLMs.
Note
: This is a fork of voska/hass-mcp originally created by Voska.
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
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.14+ and uv
Setting Up With Claude Desktop
Docker Installation (Recommended)
-
Pull the Docker image:
docker pull git.timstoop.nl/tim/hass-mcp:latest -
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.jsonfile:{ "mcpServers": { "hass-mcp": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "HA_URL", "-e", "HA_TOKEN", "git.timstoop.nl/tim/hass-mcp" ], "env": { "HA_URL": "http://homeassistant.local:8123", "HA_TOKEN": "YOUR_LONG_LIVED_TOKEN" } } } }d. Replace
YOUR_LONG_LIVED_TOKENwith your actual Home Assistant long-lived access token e. Update theHA_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
- If running Home Assistant on the same machine: use
-
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 hostto the Docker args for the container to access Home Assistant. Alternatively, use the IP address of your machine instead ofhost.docker.internal.
Running with Read-Only Filesystem (Security Hardening)
The container supports running with a read-only filesystem for improved security. Add these flags to your Docker args:
{
"mcpServers": {
"hass-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--read-only",
"--tmpfs",
"/tmp",
"-e",
"HA_URL",
"-e",
"HA_TOKEN",
"git.timstoop.nl/tim/hass-mcp"
],
"env": {
"HA_URL": "http://homeassistant.local:8123",
"HA_TOKEN": "YOUR_LONG_LIVED_TOKEN"
}
}
}
}
This prevents any runtime modifications to the container filesystem, as all Python bytecode is pre-compiled during the build.
uv/uvx
-
Install uv on your system.
-
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.jsonfile:{ "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_TOKENwith your actual Home Assistant long-lived access token e. Update theHA_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
- If running Home Assistant on the same machine: use
-
The "Hass-MCP" tool should now appear in your Claude Desktop tools menu
Shared HTTP server (one instance for many clients)
By default the server speaks stdio, so every client starts its own process. To run a single
instance that several clients connect to, set HASS_MCP_TRANSPORT=streamable-http:
HASS_MCP_TRANSPORT=streamable-http HA_URL=http://homeassistant.local:8123 HA_TOKEN=... \
uvx --from git+https://git.timstoop.nl/tim/hass-mcp hass-mcp
From a checkout: uv run hass-mcp with the same environment.
| Variable | Default | Meaning |
|---|---|---|
HASS_MCP_TRANSPORT |
stdio |
stdio, streamable-http or sse |
HASS_MCP_HOST |
127.0.0.1 |
Bind address for the HTTP transports |
HASS_MCP_PORT |
8089 |
Port for the HTTP transports |
The endpoint is http://127.0.0.1:8089/mcp. Connect with
claude mcp add --transport http hass-mcp http://127.0.0.1:8089/mcp.
HA_URL and HA_TOKEN are read from the environment only. There is no authentication on the
HTTP endpoint, so keep it on loopback (the default) or behind a reverse proxy that authenticates;
anyone who can reach the port can control your Home Assistant.
Other MCP Clients
Cursor
- Go to Cursor Settings > MCP > Add New MCP Server
- 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 git.timstoop.nl/tim/hass-mcp - Replace
YOUR_LONG_LIVED_TOKENwith your actual Home Assistant token - Update the HA_URL to match your Home Assistant instance address
- Name:
- 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 git.timstoop.nl/tim/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 versionget_entity: Get the state of a specific entity with optional field filteringentity_action: Perform actions on entities (turn on, off, toggle)list_entities: Get a list of entities with optional domain filtering and searchsearch_entities: Search for entities matching a querydomain_summary: Get a summary of a domain's entitieslist_automations: Get a list of all automationscall_service: Call any Home Assistant service. Setreturn_response=trueto get the data of services that support responses (e.g.waze_travel_time.get_travel_times) underresponserestart_ha: Restart Home Assistantget_history: Get the state history of an entityget_logbook: Get Home Assistant logbook entries (state changes, automations, service calls)get_error_log: Get the Home Assistant error loglist_bluetooth_devices: Discover Bluetooth devices visible to Home Assistantget_entity_from_registry: Get entity registry details (name, icon, area, disabled/hidden state, platform)update_registry_entity: Update entity registry fields: rename friendly name, rename entity_id, assign area, set icon, disable/hide entityremove_registry_entity: Remove an orphaned entity (state unavailable + restored) from the entity registry; dry run by default, refuses live entitieslist_devices: List devices from the device registry (id, name, manufacturer, model, area, config entries) with optional searchrename_device: Set a user-defined device name; empty string reverts to the integration nameremove_device: Remove a device from the device registry like the UI Delete button (remove_config_entry); needsconfig_entry_idwhen the device has several config entries, and the integration may refuse
get_logbook
Get Home Assistant logbook entries (state changes, automations, service calls).
Parameters:
hours(int, default: 24): Hours of history to retrieveentity_id(str, optional): Filter to specific entity (server-side)domains(list[str], optional): Filter by domains (e.g., ['light', 'automation'])lean(bool, default: True): Return minimal fields for token efficiencyfields(list[str], optional): Specific fields to include (overrides lean)limit(int, default: 50): Max entries to return (pagination)offset(int, default: 0): Entries to skip for pagination
Returns: Dict with entries, total_count, has_more, and pagination metadata
Lean Mode Fields (default):
when,entity_id,domain,state,message
All Available Fields:
when,entity_id,domain,state,message,name,icon,context_id,context_user_id
Examples:
# Efficient broad search (lean mode + domain filter)
result = await get_logbook(domains=["light", "automation"], hours=24, limit=50)
# Get activity for specific entity
result = await get_logbook(entity_id="light.living_room", hours=12)
# Trace automation chains (include context_id)
result = await get_logbook(fields=["when", "entity_id", "message", "context_id"], hours=6)
# Full details for troubleshooting
result = await get_logbook(lean=False, entity_id="climate.bedroom", hours=48)
# Paginate through results
page1 = await get_logbook(domains=["sensor"], limit=50, offset=0)
page2 = await get_logbook(domains=["sensor"], limit=50, offset=50)
Prompts for Guided Conversations
Hass-MCP includes several prompts for guided conversations:
create_automation: Guide for creating Home Assistant automations based on trigger typedebug_automation: Troubleshooting help for automations that aren't workingtroubleshoot_entity: Diagnose issues with entitiesroutine_optimizer: Analyze usage patterns and suggest optimized routines based on actual behaviorautomation_health_check: Review all automations, find conflicts, redundancies, or improvement opportunitiesentity_naming_consistency: Audit entity names and suggest standardization improvementsdashboard_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 entityhass://entities/{entity_id}/detailed: Get detailed information about an entity with all attributeshass://entities: List all Home Assistant entities grouped by domainhass://entities/domain/{domain}: Get a list of entities for a specific domainhass://search/{query}/{limit}: Search for entities matching a query with custom result limit
Development
Running Tests
uv run pytest tests/