Skip to main content
Glama

@reyhanfahlevi/homeassistant-mcp

MCP server for the Home Assistant REST API, authenticated with a long-lived access token.

Setup

  1. In Home Assistant: open your profile (http://<your-ha>:8123/profile) → Long-Lived Access Tokens → Create Token. Copy the whole string.

  2. Add the server to your MCP client:

{
  "mcpServers": {
    "homeassistant": {
      "command": "npx",
      "args": ["-y", "@reyhanfahlevi/homeassistant-mcp"],
      "env": {
        "HOMEASSISTANT_URL": "http://homeassistant.local:8123",
        "HOMEASSISTANT_TOKEN": "eyJhbGciOiJIUzI1NiIs..."
      }
    }
  }
}

HA_URL / HA_TOKEN are accepted as aliases. Use http:// and the port the instance runs on (8123 unless changed; 80 on Home Assistant OS). No trailing slash needed.

From a local checkout

Not on npm yet — clone, build, and point the client at the folder:

git clone https://github.com/reyhanfahlevi/homeassistant-mcp && cd homeassistant-mcp
npm install && npm run build
"command": "npx",
"args": ["-y", "/absolute/path/to/homeassistant-mcp"]

node /absolute/path/to/homeassistant-mcp/dist/index.js works too.

Related MCP server: Home Assistant MCP Server (HA-mcp)

Tools

Tool

Type

Purpose

ha_get_config

read

Instance config: location, units, version, components

ha_list_states

read

Entity states, filtered by domain and paged

ha_get_state

read

One entity's state and attributes

ha_list_services

read

Callable services; with domain, their fields

ha_get_history

read

State history of entities over a period

ha_get_logbook

read

Human-readable activity entries

ha_get_error_log

read

Errors from the current session

ha_render_template

read

Render a Jinja2 template server-side

ha_list_calendars

read

Calendar entities

ha_get_calendar_events

read

Events in a calendar between timestamps

ha_call_service

write

Control devices, e.g. light / turn_on

ha_fire_event

write

Fire an event on the event bus

ha_set_state

write

Overwrite an entity's state (representation only, no device I/O)

ha_delete_state

destructive

Remove a manually created entity

ha_call_api

any

Any other path under /api

Endpoints not covered directly (/api/components, /api/events, /api/config/core/check_config, …) go through ha_call_api, e.g. {"method": "GET", "path": "/api/components"}.

Not covered by the REST API at all: the device/area/entity registries and long-term statistics. Those only exist over the WebSocket API — a separate server would be needed.

Development

npm install
npm run build              # tsc -> dist/
npm test                   # unit checks on the path/format helpers
npm run smoke              # boots dist/ over stdio and lists tools (+ live calls if env is set)
HOMEASSISTANT_URL=http://homeassistant.local:8123 HOMEASSISTANT_TOKEN=... npm run smoke

License

MIT

Available Tools

15 tools
ha_call_apiCall any Home Assistant REST pathA

Call any REST endpoint under /api for cases without a dedicated tool, e.g. GET /api/components, GET /api/events, POST /api/config/core/check_config, GET /api/calendars/... . Args: method (GET|POST|DELETE), path (must start with /api and may include a query string), body (optional JSON). Prefer the dedicated tools when one exists; this one cannot bypass their guards.

Inputs: path (required), body, method.

ha_call_serviceCall a service (control a device)A

Control Home Assistant: run a service in a domain. POST /api/services/{domain}/{service}. Args: domain (e.g. "light"), service (e.g. "turn_on"), data (service payload — usually {"entity_id": "..."}); extra keys go in data, e.g. {"entity_id":"light.study","brightness_pct":40}. Common: light.turn_on/turn_off/toggle, switch.toggle, cover.open_cover/close_cover/set_cover_position, climate.set_temperature/set_hvac_mode, media_player.media_play_pause/volume_set, fan.turn_on, lock.lock/unlock, vacuum.start, script.turn_on, automation.trigger, scene.turn_on, notify.send_message, homeassistant.turn_off (whole domain or entity). Returns: the states that changed while the service ran, plus the service response when the service supports it.

Inputs: domain (required), service (required), data, returnResponse.

ha_delete_stateDelete an entity stateA
DestructiveIdempotent

Remove an entity created through ha_set_state. Irreversible: the entity and its attributes are gone. Args: entityId. Only works on entities that are not backed by an integration.

Inputs: entityId (required).

ha_fire_eventFire an eventB

Fire a custom event on the event bus (automations can listen for it). Args: eventType, eventData. Args: eventType (e.g. "my_custom_event"), eventData (optional JSON object).

Inputs: eventType (required), eventData.

ha_get_calendar_eventsGet calendar eventsC
Read-onlyIdempotent

Events of one calendar between two timestamps. Args: entityId (required), start, end (both required).

Inputs: end (required), start (required), entityId (required).

ha_get_configGet Home Assistant configA
Read-onlyIdempotent

Instance configuration: location, time zone, unit system, version, loaded components. Best first call to confirm the connection works.

Inputs: no named parameters.

ha_get_error_logGet error logA
Read-onlyIdempotent

Errors logged during the current Home Assistant session, as plain text. Useful when something misbehaves.

Inputs: no named parameters.

ha_get_historyGet state historyA
Read-onlyIdempotent

State changes for one or more entities. Args: entityIds (required), start (default: 1 day ago), end, minimalResponse (default true — only state + last_changed, much smaller), noAttributes. Returns: one array per entity. Requires the recorder integration.

Inputs: entityIds (required), end, start, noAttributes, +1 more.

ha_get_logbookGet logbookA
Read-onlyIdempotent

Human-readable history entries ("Light turned on by automation"). Args: start (default: 1 day ago), entity (optional), end. Returns entries with when, name, message, entity_id.

Inputs: end, start, entity.

ha_get_stateGet one entity stateB
Read-onlyIdempotent

Current state and attributes of a single entity. Args: entityId (e.g. sensor.kitchen_temperature).

Inputs: entityId (required).

ha_list_calendarsList calendarsB
Read-onlyIdempotent

Calendar entities available in this instance. Args: none. Returns entity_id and name.

Inputs: no named parameters.

ha_list_servicesList available servicesA
Read-onlyIdempotent

Services that can be called. Without domain: domain -> [service names] map (small). With domain: full definitions for that domain, including the fields each service accepts. Use this before ha_call_service when unsure about a service name or its data fields.

Inputs: domain.

ha_list_statesList entity statesA
Read-onlyIdempotent

All entity states (entity_id, state, attributes). Args: domain (optional, e.g. "light"), limit (default 50), offset. Always pass a domain on a real install — the full list is huge.

Inputs: limit, domain, offset.

ha_render_templateRender a Jinja templateA
Read-onlyIdempotent

Render a Home Assistant Jinja2 template server-side. Args: template, variables (optional). The cheapest way to read or compute many values at once, e.g. "{{ states('sensor.kitchen_temperature') }}" or "{% for s in states.light %}{{ s.entity_id }}: {{ s.state }}\n{% endfor %}". Returns: the rendered string.

Inputs: template (required), variables.

ha_set_stateSet an entity stateA

Overwrite an entity's state and attributes. This only changes the representation inside Home Assistant — it does NOT talk to the physical device. To control a device, use ha_call_service instead. Args: entityId (required), state (required), attributes (optional). Creates the entity when it does not exist yet.

Inputs: state (required), entityId (required), attributes.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 15 tools

    Disambiguation5/5

    Each tool targets a clearly distinct resource or action, and the descriptions explicitly distinguish similar tools such as ha_set_state vs ha_call_service and ha_get_history vs ha_get_logbook. ha_call_api is also clearly positioned as a fallback rather than an overlapping alternative.

    Naming Consistency5/5

    All tools use a consistent ha_ prefix followed by snake_case verb_noun naming (e.g. ha_get_state, ha_list_services, ha_call_service, ha_delete_state). The naming convention is predictable throughout the set.

    Tool Count5/5

    Fifteen tools is well scoped for a Home Assistant API client, covering core read, control, and fallback operations without excessive fragmentation. Each tool has a clear purpose and earns its place.

    Completeness4/5

    The set covers essential Home Assistant workflows: configuration, states, services, history, logbook, templates, calendars, events, and direct state manipulation. Some dedicated management operations (e.g. automations, scripts, deeper config flows) are not surfaced directly, though ha_call_api provides a workaround.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants to interact with Home Assistant to control smart home devices, query entity states, and manage automations using natural language. It provides over 90 tools for comprehensive system management, including dashboard configuration, service execution, and automation debugging.
      MIT