Home Assistant MCP Server
Connects to a Home Assistant instance's REST API to read entity states and attributes, search and list entities by domain, retrieve state history and logbook events, fetch the error log, and read Lovelace dashboard configuration. In optional read-write mode it calls Home Assistant services (filtered by a service allowlist) to control devices such as lights, switches, and climate, and it can optionally pull full logs from the Home Assistant host over SSH.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Home Assistant MCP Server
A Model Context Protocol (MCP) server that enables Claude to interact with your Home Assistant instance. Run it locally on your laptop to control smart home devices, query sensor data, view dashboards, and more.
Features
Read-only by default: Safe exploration of your Home Assistant data
Read-write mode: Control devices with configurable service allowlists
Comprehensive API coverage:
Entity states and attributes
History and logbook
Error logs
Lovelace dashboard configuration
Service calls (in read-write mode)
SSH log access: Optional full log retrieval via SSH
Security-focused: Token-based auth, service allowlists, no hardcoded secrets
Robust: Retry logic, timeouts, structured logging
Related MCP server: Home Assistant MCP Server
Quick Start
1. Install
# Clone and install
cd ~/src/home_assistant_mcp
pip install -e .
# Or install dependencies directly
pip install mcp httpx websockets asyncssh pydantic tenacity2. Create a Home Assistant Token
Open Home Assistant web UI
Go to your Profile (click your name in the sidebar)
Scroll to Long-lived access tokens
Click Create Token
Give it a name (e.g., "Claude MCP")
Copy the token (you won't see it again!)
3. Configure Environment
# Required
export HA_URL="http://homeassistant.local:8123" # or IP: http://192.168.1.100:8123
export HA_TOKEN="your_long_lived_access_token_here"
# Optional: Enable read-write mode for device control
export HA_MCP_MODE="readwrite"
export HA_ALLOWED_SERVICES="light.*,switch.*,climate.set_temperature"4. Run the Server
# Run directly
python -m home_assistant_mcp
# Or use the console script
home-assistant-mcp
# With debug logging
python -m home_assistant_mcp --debug5. Configure Claude Code
Add to your Claude Code MCP configuration (~/.claude/claude_desktop_config.json or similar):
{
"mcpServers": {
"home-assistant": {
"command": "python",
"args": ["-m", "home_assistant_mcp"],
"env": {
"HA_URL": "http://homeassistant.local:8123",
"HA_TOKEN": "your_token_here",
"HA_MCP_MODE": "readonly"
}
}
}
}For read-write mode with controlled services:
{
"mcpServers": {
"home-assistant": {
"command": "python",
"args": ["-m", "home_assistant_mcp"],
"env": {
"HA_URL": "http://homeassistant.local:8123",
"HA_TOKEN": "your_token_here",
"HA_MCP_MODE": "readwrite",
"HA_ALLOWED_SERVICES": "light.*,switch.*,climate.set_temperature,scene.turn_on"
}
}
}
}Environment Variables
Variable | Required | Default | Description |
| Yes | - | Home Assistant base URL |
| Yes | - | Long-lived access token |
| No |
|
|
| No | (empty) | Comma-separated service patterns |
| No |
| Set |
| No |
| Request timeout in seconds |
| No |
| Enable SSH log access |
| No | (from URL) | SSH hostname |
| No | - | SSH username |
| No |
| SSH port |
| No | - | Path to SSH private key |
| No | - | SSH password (if not using key) |
Available Tools
Read-Only Tools (Always Available)
ha_ping
Check connectivity and get Home Assistant version.
// Response
{
"status": "ok",
"message": "API running.",
"version": "2024.1.0"
}ha_list_entities
List all entities, optionally filtered by domain.
// Arguments
{ "domain": "light" } // optional
// Response
{
"total": 42,
"returned": 42,
"domain_filter": "light",
"entities": [
{
"entity_id": "light.living_room",
"state": "on",
"friendly_name": "Living Room Light",
"device_class": null
}
]
}ha_get_entity
Get detailed state for a specific entity.
// Arguments
{ "entity_id": "light.living_room" }
// Response
{
"entity_id": "light.living_room",
"state": "on",
"attributes": {
"friendly_name": "Living Room Light",
"brightness": 255,
"color_mode": "brightness"
},
"last_changed": "2024-01-15T10:30:00+00:00",
"last_updated": "2024-01-15T10:30:00+00:00"
}ha_search_entities
Search entities by ID, name, or attributes.
// Arguments
{ "query": "temperature" }
// Response
{
"query": "temperature",
"total_matches": 5,
"entities": [...]
}ha_get_history
Get state history for an entity.
// Arguments
{ "entity_id": "sensor.temperature", "hours": 24 }
// Response
{
"entity_id": "sensor.temperature",
"hours": 24,
"history": [[...state changes...]]
}ha_get_logbook
Get logbook events.
// Arguments
{ "entity_id": "light.living_room", "hours": 12 }
// Response
{
"entries": [
{
"when": "2024-01-15T10:30:00+00:00",
"name": "Living Room Light",
"message": "turned on"
}
]
}ha_get_error_log
Get the Home Assistant error log.
// Response
{
"truncated": false,
"total_bytes": 12345,
"log": "2024-01-15 10:30:00 ERROR (MainThread) ..."
}ha_get_lovelace_config
Get Lovelace dashboard configuration.
// Arguments
{ "force": false }
// Response
{
"truncated": false,
"config": {
"title": "Home",
"views": [...]
}
}Read-Write Tools (Requires HA_MCP_MODE=readwrite)
ha_call_service
Call a Home Assistant service.
// Arguments
{
"domain": "light",
"service": "turn_on",
"data": { "brightness": 200 },
"target": { "entity_id": "light.living_room" }
}
// Response
{
"success": true,
"domain": "light",
"service": "turn_on",
"result": [...]
}SSH Tools (Requires HA_SSH_ENABLE=true)
ha_get_full_logs
Get full logs via SSH.
// Arguments
{ "kind": "core", "lines": 500 }
// Response
{
"source": "ha core logs",
"truncated": false,
"log": "..."
}Service Allowlist Patterns
The HA_ALLOWED_SERVICES variable accepts comma-separated patterns:
Pattern | Matches |
| Exact service |
| All light services |
| All services (dangerous!) |
Examples:
# Allow all light and switch services
export HA_ALLOWED_SERVICES="light.*,switch.*"
# Allow specific services only
export HA_ALLOWED_SERVICES="light.turn_on,light.turn_off,climate.set_temperature"
# Allow everything (use with caution!)
export HA_ALLOWED_SERVICES="*"Security Best Practices
Start with read-only mode until you're comfortable
Use specific allowlist patterns instead of wildcards
Never commit tokens to version control
Use environment variables or a secrets manager
Restrict token scope in Home Assistant if possible
Disable TLS verification only for local networks with self-signed certs
Troubleshooting
"Authentication failed"
Verify your token is correct and not expired
Check that the token has the required permissions
Ensure
HA_URLdoesn't have a trailing slash
"Connection refused"
Verify Home Assistant is running and accessible
Check the URL is correct (try opening it in a browser)
Ensure you're on the same network
"Service call denied"
Check
HA_MCP_MODEis set toreadwriteVerify the service is in
HA_ALLOWED_SERVICESCheck pattern matching (use
domain.*for all services in a domain)
"TLS certificate verify failed"
For self-signed certificates, set
HA_VERIFY_TLS=falseThis is safe for local network access
SSH logs not working
Ensure
HA_SSH_ENABLE=trueVerify SSH credentials are correct
Check that
haCLI is available on the HA host (HA OS/Supervised only)
Architecture
┌─────────────────┐ ┌──────────────────────────────────────┐
│ Claude Code │────▶│ home-assistant-mcp │
│ (MCP Client) │◀────│ (MCP Server) │
└─────────────────┘ │ │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ REST Client │ │ WS Client │ │
│ └──────┬───────┘ └──────┬───────┘ │
│ │ │ │
│ ┌──────▼─────────────────▼───────┐ │
│ │ Home Assistant │ │
│ │ (Raspberry Pi / LAN) │ │
│ └────────────────────────────────┘ │
│ │
│ ┌──────────────┐ (optional) │
│ │ SSH Client │─────▶ HA Host │
│ └──────────────┘ │
└──────────────────────────────────────┘Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Type checking
mypy src/
# Linting
ruff check src/License
MIT License - see LICENSE file for details.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Control your existing Philips lights, Sonos speakers, Roborock vacuums and other supported devices through Port OS cloud. Give ChatGPT, Claude and other MCP-compatible assistants access to the devices you connect. Turn off the living room lights, play music on your speakers, adjust the thermostat, run a vacuum in a room, check a camera snapshot or find a connected tracker. Available actions depend on your linked provider accounts and each device’s supported capabilities. Port OS runs in the cloud; no local server is required. You choose the account, device and capability permissions each assistant receives. Device operations require user OAuth; public tool discovery does not grant device access. Port OS is in alpha. Setup: https://portoperatingsystem.com/docs/getting-started/ Support: https://portoperatingsystem.com/contact/
WHOOP recovery, strain, sleep and workouts in Claude via official WHOOP OAuth. Free, open source.
Lets Claude, ChatGPT, and Muse read and update your beckett tasks, notes, calendar, and lists.
Connect Claude to your Platform7n workspaces: chat, links, work and decks. One-click OAuth.
Related MCP Servers
- 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 gradedqualityDmaintenanceEnables Claude Desktop to read and control Home Assistant devices via natural language, with configurable safety restrictions on sensitive actions.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables ChatGPT to read selected Home Assistant data and perform limited home-control actions like turning on/off lights and running scenes, with a strict allowlist for security.MIT
- FlicenseNot gradedqualityCmaintenanceEnables Claude to read and control a Home Assistant instance, including authoring schedules, scenes, and automations rather than just toggling devices.-