hass-mcp
# hass-mcp
An open-source **MCP server** for controlling and querying **Home Assistant**.
- Transport: stdio
- Auth: Home Assistant long-lived token
- API: Home Assistant REST API
## Features
Tools exposed:
- `ha_get_state` — get state for an entity
- `ha_list_states` — list all states (can be large)
- `ha_call_service` — call any service
## Install
```bash
pnpm install
pnpm build
```
## Run
```bash
export HASS_URL="http://homeassistant.local:8123"
export HASS_TOKEN="<your long-lived access token>"
pnpm start
```
## Configure in an MCP client
Example (conceptual):
```json
{
"mcpServers": {
"homeassistant": {
"command": "npx",
"args": ["-y", "hass-mcp"],
"env": {
"HASS_URL": "http://homeassistant.local:8123",
"HASS_TOKEN": "..."
}
}
}
}
```
## Security
- Treat tokens as secrets.
- Prefer running this server on the same LAN as Home Assistant.
- If your HA is behind Cloudflare Access, run this MCP server on the LAN side.
## License
MIT
TDQS
Scored across 13 tools
Most tools have distinct purposes (get vs list vs control), but ha_call_service can duplicate any service-specific tool like ha_light_turn_on. Descriptions clearly delineate scope, so selection is unambiguous in practice.
All tools share the 'ha_' prefix and snake_case, but the order varies: 'ha_light_turn_on' (noun_verb) vs 'ha_get_state' (verb_noun). This is a minor deviation from a fully consistent pattern.
13 tools is well within the ideal range and matches the server's clear purpose for Home Assistant integration. Each tool covers a meaningful operation without redundancy.
Covers state reads, lists, registries, light control (individual and area), logbook, history, and a generic service caller, so most workflows are possible. Specific controls are limited to lights, but ha_call_service fills the gap for other domains.