Skip to main content
Glama
home-assistant-agent-mcp

home-assistant-agent-mcp

by Hemanthkolli

home-assistant-agent-mcp

A small MCP server that lets an AI agent read and manage your Home Assistant: check states, control devices, write automations, build dashboards and tidy up names and rooms, all in plain language.

It is around 600 lines of TypeScript, built on the official MCP TypeScript SDK. It is meant to be easy to read, fork and change for your own home.

Looking for a no-code option? Home Assistant also has a built-in MCP Server integration. This project goes further with configuration tasks such as automations, dashboards and the entity, device and area registries.

What you can ask

  • "Which lights are still on?"

  • "Show me the bedroom temperature over the last 24 hours."

  • "Create an automation that turns off the hallway light at midnight."

  • "Rename these sensors so they make sense and put them in the right rooms."

Related MCP server: Home Assistant MCP Server

Tools

Tool

What it does

ha_get_states

List entity states, optionally filtered by domain

ha_get_entity

State and attributes of one entity

ha_get_history

State history of an entity over the last N hours

ha_render_template

Render a Jinja2 template (handy for testing)

ha_call_service

Call any service, e.g. light.turn_on, climate.set_temperature

ha_notify

Send a notification through a notifier

ha_list_automations

List automations with id, alias and state

ha_get_automation

Full config of one automation

ha_create_automation

Create an automation

ha_update_automation

Update an automation

ha_delete_automation

Permanently delete an automation

ha_toggle_automation

Enable or disable an automation

ha_list_dashboards

List Lovelace dashboards

ha_get_dashboard

Full config of a dashboard

ha_create_dashboard

Create a dashboard

ha_update_dashboard

Save a dashboard's views and cards

ha_rename_entity

Rename an entity (or clear its name)

ha_update_device

Rename a device and/or move it to an area

ha_list_areas

List areas (rooms) and floors

ha_update_area

Rename an area and/or assign it to a floor

It uses Home Assistant's REST API for states, services and history, and the WebSocket API for configuration such as registries and dashboards.

Requirements

  • Node.js 20 or newer

  • A Home Assistant instance you can reach from your machine

  • A Home Assistant long-lived access token: in Home Assistant, open your profile → Security → Long-lived access tokens → Create token

  • An MCP client, for example Claude Code, Claude Desktop, or any other MCP-capable agent

Setup

git clone https://github.com/<your-user>/home-assistant-agent-mcp.git
cd home-assistant-agent-mcp
npm install
npm run build
cp .env.example .env   # then set HA_URL and HA_TOKEN

The server reads two environment variables:

Variable

Example

Required

HA_URL

http://homeassistant.local:8123

No (this is the default)

HA_TOKEN

your long-lived access token

Yes

Connect it to Claude Code

The included scripts register the server for a limited time and remove it again automatically:

./ha-on.sh      # enable for 4 hours (default)
./ha-on.sh 1    # enable for 1 hour
./ha-off.sh     # disable now

Or register it yourself:

claude mcp add home-assistant -s user \
  -e HA_URL=http://homeassistant.local:8123 \
  -e HA_TOKEN=your-token \
  -- node /path/to/home-assistant-agent-mcp/dist/index.js

Other MCP clients

Any client that can start a local (stdio) MCP server works. Point it at node dist/index.js and pass HA_URL and HA_TOKEN as environment variables.

Test without an agent

npx @modelcontextprotocol/inspector -e HA_TOKEN=your-token node dist/index.js

The MCP Inspector lets you call each tool by hand.

Security

This server gives an agent real control over your home, so please be careful:

  • Treat the token like a password. Keep it in .env (which is git-ignored) and never paste it into a chat. Note that claude mcp add -e HA_TOKEN=… stores it in plain text in your local Claude config.

  • Prefer a dedicated Home Assistant user for the agent, so you can see what it does and revoke its token at any time.

  • Keep it off when you don't need it. ha-on.sh turns the server off again after a few hours.

  • Review changes before they run. Keep your client's tool-approval prompts on, especially for ha_call_service, ha_delete_automation and ha_update_dashboard.

  • Keep Home Assistant off the public internet, or put it behind proper authentication and TLS.

Make it your own

All tools are defined in src/index.ts: one list of tool definitions and one dispatch function. To add a tool, add a definition with a clear description and handle it in dispatch. Clear descriptions matter a lot: they are what the agent reads to choose the right tool.

npm run dev     # run from source with tsx
npm run build   # compile to dist/

License

MIT. Use it, change it, share it.

Not affiliated with or endorsed by Home Assistant or the Open Home Foundation.

Available Tools

20 tools
ha_call_serviceC

Call any Home Assistant service to control lights, climate, media players, switches, etc.

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

ha_create_automationB

Create a new automation. Provide the full config object.

Inputs: config (required).

ha_create_dashboardC

Create a new Lovelace dashboard.

Inputs: title (required), url_path (required), icon, show_in_sidebar.

ha_delete_automationB

Permanently delete an automation by its numeric ID.

Inputs: automation_id (required).

ha_get_automationB

Get the full config of a specific automation by its numeric ID.

Inputs: automation_id (required).

ha_get_dashboardA

Get the full card/view config of a Lovelace dashboard. Omit url_path for the default dashboard.

Inputs: url_path.

ha_get_entityB

Get state and all attributes of a specific entity.

Inputs: entity_id (required).

ha_get_historyC

Get the state history of an entity over the last N hours.

Inputs: entity_id (required), hours.

ha_get_statesA

Get all entity states. Optionally filter by domain (e.g. light, climate, sensor, switch).

Inputs: domain.

ha_list_areasA

List all areas (rooms) with their ids, names and floors, plus the list of floors.

Inputs: no named parameters.

ha_list_automationsA

List all automations with their IDs, aliases, and enabled state.

Inputs: no named parameters.

ha_list_dashboardsB

List all Lovelace dashboards.

Inputs: no named parameters.

ha_notifyC

Send a notification via Home Assistant.

Inputs: message (required), title, target.

ha_rename_entityA

Set or clear an entity's own name in the entity registry. Note: for device-based entities the displayed name is usually ' ', so to rename a room's thermostat, rename the device (ha_update_device) or the area (ha_update_area) instead, and clear the entity name. Pass null, "" or "null" to clear the name.

Inputs: name (required), entity_id (required).

ha_render_templateB

Render a Jinja2 template string. Useful for testing templates before using them in automations.

Inputs: template (required).

ha_toggle_automationC

Enable or disable an automation.

Inputs: enable (required), entity_id (required).

ha_update_areaB

Rename an area (room) and/or assign it to a floor. The area_id stays the same, so automations keep working.

Inputs: area_id (required), name, floor_id.

ha_update_automationC

Update an existing automation by its numeric ID.

Inputs: config (required), automation_id (required).

ha_update_dashboardA

Save the full config (views, cards) of a Lovelace dashboard. Omit url_path for the default dashboard.

Inputs: config (required), url_path.

ha_update_deviceA

Rename a device and/or move it to another area. Identify it by device_id or by one of its entity_ids. Moving a device moves all its entities that don't have an area of their own.

Inputs: name, area_id, device_id, entity_id.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 20 tools

    Disambiguation4/5

    Most tools target distinct resource+action pairs (states, entities, areas, automations, dashboards). There is some overlap between ha_rename_entity, ha_update_device, and ha_update_area since all can affect naming, but the descriptions explicitly clarify when to use each.

    Naming Consistency5/5

    Every tool follows a consistent ha_ prefix with a snake_case verb_noun pattern (e.g., ha_get_states, ha_create_automation, ha_update_dashboard). The convention is predictable throughout the entire set.

    Tool Count4/5

    Twenty tools is on the higher end, but the server spans several distinct Home Assistant domains: state reading, registry/area management, automations, dashboards, and utilities. Each tool earns its place, though a few utility tools could potentially be consolidated.

    Completeness3/5

    Core workflows are covered, but there are notable gaps: no device listing despite ha_update_device accepting device_id, no dashboard deletion, no area creation/deletion, and no script/scene management. Agents can work around some gaps (e.g., identifying devices via entity_ids) but not all.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to interact with Home Assistant smart home devices through natural language. Control devices, manage automations, query entity states, and retrieve historical data across your home automation system.
      1
      MIT
    • 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
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to read Home Assistant entity states, call any service, and optionally apply named scene presets from a catalog using plain-English descriptions.
      1
      MIT