homeassistant-mcp
Provides tools for interacting with the Home Assistant REST API, enabling management and control of a Home Assistant instance: reading instance config, entity states, services, history, logbook, and error logs, rendering Jinja2 templates server-side, listing calendars and their events, and performing write actions such as calling services to control devices, firing events, setting entity states, deleting entities, and calling arbitrary API endpoints.
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., "@homeassistant-mcp turn on the living room lights"
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.
@reyhanfahlevi/homeassistant-mcp
MCP server for the Home Assistant REST API, authenticated with a long-lived access token.
Setup
In Home Assistant: open your profile (
http://<your-ha>:8123/profile) → Long-Lived Access Tokens → Create Token. Copy the whole string.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 |
| read | Instance config: location, units, version, components |
| read | Entity states, filtered by |
| read | One entity's state and attributes |
| read | Callable services; with |
| read | State history of entities over a period |
| read | Human-readable activity entries |
| read | Errors from the current session |
| read | Render a Jinja2 template server-side |
| read | Calendar entities |
| read | Events in a calendar between timestamps |
| write | Control devices, e.g. |
| write | Fire an event on the event bus |
| write | Overwrite an entity's state (representation only, no device I/O) |
| destructive | Remove a manually created entity |
| any | Any other path under |
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 smokeLicense
MIT
Available Tools
15 toolsha_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 stateADestructiveIdempotent
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 eventsCRead-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 configARead-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 logARead-onlyIdempotent
Errors logged during the current Home Assistant session, as plain text. Useful when something misbehaves.
Inputs: no named parameters.
ha_get_historyGet state historyARead-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 logbookARead-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 stateBRead-onlyIdempotent
Current state and attributes of a single entity. Args: entityId (e.g. sensor.kitchen_temperature).
Inputs: entityId (required).
ha_list_calendarsList calendarsBRead-onlyIdempotent
Calendar entities available in this instance. Args: none. Returns entity_id and name.
Inputs: no named parameters.
ha_list_servicesList available servicesARead-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 statesARead-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 templateARead-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
Scored across 15 tools
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.
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.
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.
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
Related MCP Connectors
Home energy for AI assistants: live Power flow, Energy history, solar forecast, and device control.
Tesla data for your AI: battery, range, charging, tires, alerts, history. Controls off by default.
Control your Tesla from your AI assistant - climate, charging, access, and security.
Lets AI agents analyze API metrics, request logs, and traces, and manage apps and alerts.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides tools for AI assistants to interact with smart home devices through Home Assistant, allowing operations like checking entity states and calling services.33MIT
- 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 gradedqualityDmaintenanceEnables interaction with Home Assistant through the REST API, allowing users to query states, call services, and manage entities via natural language.20 PyPIMIT
- FlicenseNot gradedqualityCmaintenanceEnables Claude to read and control a Home Assistant instance, including authoring schedules, scenes, and automations rather than just toggling devices.-