HA Insights MCP
Provides analytics, diagnostics, and guarded actions for Home Assistant. Phase 1 supports read-only discovery: searching entities by text/domain/area, retrieving live entity state and area/device details, listing areas, and generating a home summary. Planned capabilities include history analytics, device health checks, automation audits, and guarded actions with allowlists, value bounds, dry-run, confirmation, and audit logging.
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., "@HA Insights MCP search for kitchen entities and show their current states"
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.
HA Insights MCP
An MCP server that gives LLM agents analytics, diagnostics and guarded actions for Home Assistant.
Status: all 4 phases done — discovery, history analytics, device health, automation audit and opt-in guarded actions, over stdio or authenticated Streamable HTTP (Docker). See Roadmap.

dev/demo.py is a real MCP client over stdio that plays the client app: it runs
diagnostics, gets a thermostat value refused (°C policy on a °F home) and unlocks a door
after the human answers the server's confirmation prompt. Regenerate the GIF with
VHS: vhs docs/demo.tape.
Positioning: why another Home Assistant MCP server?
Home Assistant already ships a built-in
MCP Server integration, and
community servers (e.g. ha-mcp) expose broad control of HA. This project deliberately
does not compete with them on "turn on the kitchen light".
Built-in HA MCP Server | HA Insights MCP (this project) | |
Purpose | Voice/Assist-style control of exposed entities | Understanding and auditing the home |
Data | Current state of exposed entities | States joined with area/device/entity registries, recorder history and statistics, automation configs and traces |
Analytics | — | Time in state, change counts, min/mean/max trends, most active entities |
Diagnostics | — | Offline devices, low batteries, stale and flapping sensors, HA repairs, automation audit (broken references, failing runs) |
Actions | Direct intents | Guarded and off by default: allowlist, value bounds, preview, human confirmation, verification, audit log |
Output | Assist API responses | Compact, typed, token-efficient structured output |
Use the built-in server to control your home. Use HA Insights to ask "what is going on in my home, what is broken, and is this change safe?". Both can run side by side.
Related MCP server: Home Assistant MCP Server (HA-mcp)
Features
By default every tool is read-only (readOnlyHint) and the server never changes Home
Assistant. Guarded actions are opt-in (ACTIONS_ENABLED=true), see below.
Discovery
Tool | Purpose |
| Find entities by text, domain, area → |
| Live state, unit, area, device, domain-relevant attributes |
| Areas with entity counts |
History analytics (aggregated on the server, never raw points)
Tool | Purpose |
| Numeric: min/mean/max + bucketed series (from HA statistics, raw history as fallback). Discrete: changes, % time in each state, latest changes |
| Entities with the most state changes ("what was used most") |
Device health
Tool | Purpose |
|
|
Automations
Tool | Purpose |
| State, mode, last triggered, result of the last run |
| Triggers/conditions/actions, referenced entities, recent runs with errors |
|
|
Findings and issues carry stable codes and a severity (error / warning / info).
Resource: ha://home/summary — markdown overview: areas with entity counts, entities
per domain, number of unavailable entities.
Prompts (user-selected, e.g. slash commands in Claude Code):
home_health_report(area?)— runs health check + audit, correlates findings, answers with "Fix now / Should fix / FYI" and next steps.investigate_entity(entity_id)— state, 24h history, health, and the automations that reference the entity (found server-side and embedded in the prompt).
Guarded actions (only with ACTIONS_ENABLED=true and a policy.toml)
Tool | Purpose |
| Read-only dry run: every policy check, risk, whether a human must confirm (and whether this client can ask), expected change per entity, allowed value ranges |
| Re-checks everything, asks the human for medium/high risk, calls HA, re-reads the state and reports |
| Audit log: every attempt with reason, risk, confirmation, outcome |
Resource ha://actions/policy shows the effective policy to the model up front.
Outputs are pydantic models (MCP structured content with an output schema). Raw HA JSON is
never returned: attributes are filtered per domain (no supported_features bitmasks, icons,
pictures or GPS coordinates).
Architecture
MCP client (Claude, Inspector)
│ JSON-RPC over stdio, or Streamable HTTP /mcp + Bearer token
┌───────▼──────────────────────────────────────────────┐
│ http.py, auth.py uvicorn app, SDK bearer auth, │ HTTP transport
│ Host/Origin allowlist, /healthz │ (MCP_TRANSPORT=http)
┌───────▼──────────────────────────────────────────────┐
│ server.py MCPServer, lifespan, instructions │ MCP layer
│ tools/ discovery, history, health, │
│ automations, actions → schemas.py │
│ resources.py ha://home/summary, ha://actions/policy │
│ prompts.py home_health_report, investigate_entity │
│ context.py AppContext, HAError → ToolError │
├──────────────────────────────────────────────────────┤
│ analytics/ history · health · audit │ pure functions
│ (no I/O, no MCP; plain-fixture tests) │
│ actions/ policy · effects (pure) │ guarded actions
│ guard (assess) → executor (the only │
│ writer) → audit_log (SQLite) │
│ snapshot.py states ⋈ registries, area resolution, │
│ TTL cache, single-flight refresh │
├──────────────────────────────────────────────────────┤
│ ha/client.py REST (httpx): states, config │ HA client
│ WebSocket: registries, history, │ (no MCP imports)
│ statistics, automation configs, │
│ traces, repairs, services, │
│ call_service (the only write) │
│ ha/errors.py HAAuthError, HAConnectionError, ... │
└───────┬──────────────────────────────────────────────┘
│ HTTP + WebSocket, Bearer token
Home AssistantKey decisions:
Separate HA client.
ha/knows nothing about MCP, so it is testable on its own and reusable for the HTTP transport (phase 4).REST + WebSocket. REST has no area/device/entity registries; without them you cannot answer "what is in the kitchen". Registries are fetched in one WebSocket session.
Area resolution like HA: the entity's own area wins, otherwise the device's area.
Snapshot cache (10 s default) shared by tools and the resource;
get_entity_statealways reads the state fresh.Aggregate on the server. A week of a sensor is thousands of points; the model gets ~200 tokens of conclusions. Numeric entities use HA's recorder statistics (5-minute for ≤24h windows, hourly beyond), with time-weighted raw history as fallback.
Pure analytics core. History, health and audit rules are pure functions with stable codes — easy to test and reusable for phase 3 dry-runs.
Honest about limits. HA keeps only the last 5 traces per automation, templated references cannot be checked statically, history is capped at 7 days — tool descriptions and outputs say so (
source,checks_skipped,templated_refs).Errors are part of the conversation. HA failures become MCP tool errors with actionable text ("Unknown area 'attic'. Known areas: …"), so the model can self-correct.
Security from day one. Token only from env/
.env, held asSecretStr, never logged or included in errors.entity_idis validated before it reaches a URL. Annotations are hints for clients, not enforcement — enforcement lives in the server (see below).stdio hygiene. stdout is the JSON-RPC channel; all logs go to stderr.
Guarded actions
Writes are off unless ACTIONS_ENABLED=true. Then the server needs a policy file
(cp policy.example.toml policy.toml); if it is missing or invalid the server refuses to
start. Layers, in the order a request meets them:
Two tools, two permissions.
preview_actionis read-only and can be auto-approved in the client;execute_actionisdestructiveHint, so the client asks separately.Allowlist (
policy.toml, which the model cannot change): domains, services and data fields. Everything else is denied;script,automation,scene,homeassistant,shell_command,updateand a few more can never be allowed — they would bypass the policy. Targets are explicitentity_idsonly (no areas, noall, ≤ 10).Value bounds = policy ∩ the entity's own limits (e.g.
min_temp) ∩ HA's service schema. HA's own selector forclimate.set_temperatureis 0–250, so it is not enough. Policy temperatures carry a unit and are converted to HA's unit system: 16–26 °C becomes 60.8–78.8 °F on an imperial installation.Risk comes from the policy, not from the model:
lowruns,medium/highneed a human. More thanbulk_thresholdtargets raise the risk one level.Human confirmation via MCP elicitation. The server builds the question from validated data; the assistant's reason is shown labelled as unverified. The form needs a ticked checkbox. There is no
confirmargument — the model cannot confirm for the user. Clients without elicitation getno_confirmation_channel: risky actions are refused, low-risk ones still work.Re-check before writing.
execute_actionassesses again with fresh states; a preview is never a permission. A rate limit (10/min) stops runaway loops.Verification. After the call the server re-reads the targets: devices can ignore a command or jam. A timeout is reported as "may or may not have been applied".
Audit log. SQLite, append-only (UPDATE/DELETE blocked by triggers): every attempt, including refusals, with the reason, risk, confirmation, before/after states and HA's
context_id(links the entry to HA's logbook).
The write path is one method (HAClient.call_service, over WebSocket because REST only
answers "400: Bad Request"), called from one module (actions/executor.py); an
architecture test fails the build otherwise.
Confirmation uses the SDK's Resolve + Elicit, which works on both protocol eras: a live
elicitation/create request on 2025-era connections and InputRequiredResult (the client
retries the call with the answer) on 2026-07-28.
Setup
Requirements: Python 3.12, uv, Docker (for the dev HA), Node.js (only for MCP Inspector).
make install # uv sync
cp .env.example .env # then set HA_URL and HA_TOKENDev Home Assistant
make dev-ha-up # HA with the demo integration on http://localhost:8123Onboard, create a long-lived access token, then make dev-seed (areas) and
make dev-simulate (automations, low battery, offline light, flapping sensor) — see
dev/README.md. Any real HA instance works too: set HA_URL and
HA_TOKEN (an admin user's token, required for the registries).
Configuration
Variable | Default | |
|
| Base URL of Home Assistant |
| — (required) | Long-lived access token |
|
| Per-request timeout |
|
| Snapshot cache TTL (0 disables) |
|
| Low-battery threshold (below half of it = error) |
|
| Measurement sensor with no report for this long = stale |
|
| State changes within one hour = flapping |
|
|
|
|
| HTTP listen address |
|
| URL clients use (behind a proxy: its |
|
| Bearer token hashes and scopes; required for HTTP |
|
| Extra browser origins (JSON list) |
|
| Register the guarded action tools |
|
| Action policy (see |
|
| SQLite audit log |
|
| Logs go to stderr |
Usage
MCP Inspector
make inspectOpens the Inspector in the browser, connected over stdio. Click Connect, then:
Tools → List Tools → list_areas → Run; Resources → ha://home/summary.
Check the output schema and the structured result of each tool.
Headless (CLI mode), handy for scripts and CI:
npx -y @modelcontextprotocol/inspector --cli uv run ha-insights-mcp --method tools/list
npx -y @modelcontextprotocol/inspector --cli uv run ha-insights-mcp \
--method tools/call --tool-name search_entities --tool-arg query=garageHTTP and Docker
Over HTTP every request needs a bearer token. Tokens are stored only as SHA-256 hashes:
uv run ha-insights-mcp token create --name laptop --scope ha:read # prints the token once
# append the printed [[tokens]] entry to tokens.toml (see tokens.example.toml)
MCP_TRANSPORT=http uv run ha-insights-mcp # http://127.0.0.1:8000/mcpDocker, next to the dev HA (the service is behind the mcp compose profile):
make mcp-up # builds the image, http://localhost:8000/mcp (MCP_HOST_PORT to change)
make mcp-logs / make mcp-downThe image (~165 MB) holds only the virtualenv and runs as an unprivileged user with a
read-only root filesystem. Runtime inputs: HA_URL/HA_TOKEN (env), /config/tokens.toml
and /config/policy.toml (read-only mounts), /data (audit log volume). tokens.toml holds
only hashes, so it may be world-readable for the container user.
Connect a client:
claude mcp add --transport http ha-insights http://localhost:8000/mcp \
--header "Authorization: Bearer hai_..."
npx -y @modelcontextprotocol/inspector --cli http://localhost:8000/mcp --transport http \
--header "Authorization: Bearer hai_..." --method tools/listSecurity model over HTTP.
Auth, session ownership and principal-bound
request_statecome from the SDK (token_verifier+AuthSettings): a session or a pending confirmation cannot be reused with another token. Unauthenticated requests get401with a pointer to/.well-known/oauth-protected-resource.Scopes:
ha:read(all analytics,preview_action) andha:actions(execute_action). A read-only token getsdenied_scope, logged, and the human is never asked to confirm it.A holder of an
ha:actionstoken can also answer the confirmation prompt. Over stdio the client is the user's own app; over HTTP the confirmation is only as trustworthy as the client that holds the token. Giveha:actionsonly to clients you trust.DNS rebinding protection is always on with an explicit
Host/Originallowlist (the SDK enables it by itself only for loopback binds, not for0.0.0.0in a container).The server has no TLS: terminate HTTPS at a reverse proxy and set
MCP_PUBLIC_URLto its URL. A warning is logged when listening beyond loopback over plain HTTP./healthzneeds no token and answers onlyok.The server refuses to start over HTTP without a valid token file (fail closed).
Claude Code
claude mcp add ha-insights -- uv run --directory /path/to/ha_mcp ha-insights-mcp
claude mcp list # should show ha-insights: connected--directory makes uv run in the repo, so .env is found. To allow guarded actions, add
-e ACTIONS_ENABLED=true before --. In a session, ask
"What is broken in my home?" or "How often did the backyard motion sensor trigger today?",
reference the resource with @ha-insights:ha://home/summary, or run a prompt:
/mcp__ha-insights__home_health_report.

The agent finds that the living room's lights are switch entities, reports their state and points out a low door sensor battery it noticed along the way.
Claude Desktop
~/.config/Claude/claude_desktop_config.json (Linux) or
~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"ha-insights": {
"command": "uv",
"args": ["run", "--directory", "/path/to/ha_mcp", "ha-insights-mcp"]
}
}
}Prefer keeping the token in the repo's .env (git-ignored) over an env block in this
file.
Development
make check # lint + tests; run before every commit
make test # pytest, no real HA calls (respx + fake WebSocket + in-memory MCP client)
make fmtTool tests run the whole stack: in-memory MCP Client → server → real HAClient →
mocked HA. HTTP tests drive the real Starlette app through an ASGI transport (auth, Host and
Origin checks, session ownership, scopes). CI (GitHub Actions) runs lint, tests, the image
build and a container smoke test. Conventions for contributors and AI agents:
CLAUDE.md.
Roadmap
Skeleton + read-only tools over stdio, dev HA in Docker ← done
History analytics, device health, automation audit, prompts ← done
Guarded actions: allowlist, value bounds, preview, human confirmation, verification, SQLite audit log ← done
Streamable HTTP with bearer auth and scopes, Docker image, CI, demo ← done
License
MIT
Available Tools
3 toolsget_entity_stateGet entity stateARead-only
Get the live state of one entity with its area, device and relevant attributes.
The state is read fresh from Home Assistant. Attributes are filtered to the ones meaningful for the entity's domain (e.g. temperatures and modes for climate).
Inputs: entity_id (required). Returns: area, name, unit, state, +5 more
list_areasList areasARead-only
List all areas (rooms/zones) of the home with how many entities each contains.
Use area_id or name from here to filter search_entities by area.
Inputs: no named parameters. Returns: areas, unassigned_entity_count
search_entitiesSearch entitiesARead-only
Find Home Assistant entities and their current states.
Use this first to discover entity_ids, then call get_entity_state for details.
Returns entity_id, name, state and area for each match, best matches first.
Inputs: query (required), area, limit, domain. Returns: total, entities, truncated
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct role: search_entities discovers entities, list_areas catalogs rooms/zones, and get_entity_state retrieves detail for a single entity. The descriptions explicitly guide sequencing from search to detail, leaving little room for misselection.
All tool names follow the same snake_case verb_noun pattern: search_entities, list_areas, get_entity_state. The convention is predictable and readable throughout.
Three tools is minimal but well-matched to this read-only Home Assistant insights server. Each tool serves a distinct discovery, area, or detail purpose, so none feels redundant or missing.
The surface covers the core read-only workflow: discover entities, understand areas, and inspect live entity state with relevant attributes. Minor gaps like a dedicated area-detail or history/statistics tool exist, but agents can work around them for the stated purpose.
Related MCP Connectors
Read-only discovery for AgentCheck, a visitor-side security review of AI chatbots and agents.
Read-only Google Search Console and Google Analytics for AI agents.
Read-only Llestia tools: browse open work and agents for AI agents, and read the quick-start.
Read-only AI access to HAVN properties, leads, tasks, files, media, and analytics.
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 gradedqualityBmaintenanceGives AI agents scoped, least-privilege access to Home Assistant, with per-token permissions, auditing, and 131 tools for managing smart home devices.1MIT
- AlicenseNot gradedqualityAmaintenanceProvides secure, read-only semantic access to Home Assistant entities, areas, floors, and domain summaries for MCP clients like ChatGPT and Codex.MIT