home-assistant-agent-mcp
Enables AI agents to read and manage a Home Assistant instance, including checking entity states and history, calling services, sending notifications, creating and managing automations and dashboards, and renaming entities, devices, and areas.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@home-assistant-agent-mcp turn off all the lights downstairs and lock the front door"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 |
| List entity states, optionally filtered by domain |
| State and attributes of one entity |
| State history of an entity over the last N hours |
| Render a Jinja2 template (handy for testing) |
| Call any service, e.g. |
| Send a notification through a notifier |
| List automations with id, alias and state |
| Full config of one automation |
| Create an automation |
| Update an automation |
| Permanently delete an automation |
| Enable or disable an automation |
| List Lovelace dashboards |
| Full config of a dashboard |
| Create a dashboard |
| Save a dashboard's views and cards |
| Rename an entity (or clear its name) |
| Rename a device and/or move it to an area |
| List areas (rooms) and floors |
| 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_TOKENThe server reads two environment variables:
Variable | Example | Required |
|
| No (this is the default) |
| 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 nowOr 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.jsOther 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.jsThe 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 thatclaude 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.shturns 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_automationandha_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 toolsha_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
Scored across 20 tools
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.
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.
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.
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
Related MCP Connectors
Home energy for AI assistants: live Power flow, Energy history, solar forecast, and device control.
Build and run agents and automations across hundreds of apps using natural language.
Control your Tesla from your AI assistant - climate, charging, access, and security.
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to control and monitor Home Assistant smart home devices through natural language interactions. Supports device control, entity state monitoring, history access, and automation generation with both MCP protocol and standalone HTTP REST API modes.1MIT
- AlicenseNot gradedqualityDmaintenanceEnables 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.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables 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
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to read Home Assistant entity states, call any service, and optionally apply named scene presets from a catalog using plain-English descriptions.1MIT