hass-mcp-server
A Home Assistant Custom Component that provides an MCP (Model Context Protocol) server using HTTP transport, allowing AI assistants like Claude to interact with your Home Assistant instance over HTTP
MCP Server for Home Assistant (HTTP Transport)
A Home Assistant Custom Component that provides an MCP (Model Context Protocol) server using HTTP transport, allowing AI assistants like Claude to interact with your Home Assistant instance.
Note: Unlike other Home Assistant MCP servers that use SSE (Server-Sent Events), this implementation uses HTTP transport with OAuth 2.0 authentication, making it suitable for remote access and integration with services like Claude in browser.
Features
- 🌐 HTTP transport (not SSE) - works remotely, not just locally
- 🔐 OAuth 2.0 authentication with Dynamic Client Registration (via hass-oidc-server)
- 🏠 Full Home Assistant API access (entities, services, areas, devices, history)
- 🔧 Easy HACS installation
- 📝 CRUD management of automations, scenes, and scripts
- 📋 Lovelace dashboard management (list, get/save/delete config, create/update/delete dashboards)
- 📊 Resources, prompts, and completions for richer AI interactions
Prerequisites
This plugin requires hass-oidc-server to be installed and configured for OIDC authentication.
Installation
HACS (Recommended)
- Open HACS in Home Assistant
- Search for "MCP Server"
- Click "Download"
- Restart Home Assistant
- Configure the integration (see Configuration section below)
Manual Installation
- Copy the
custom_components/mcp_server_http_transportfolder to your Home Assistantcustom_componentsdirectory - Restart Home Assistant
- Configure the integration (see Configuration section below)
Configuration
- Go to Settings → Devices & Services
- Click "Add Integration"
- Search for "MCP Server"
- Follow the configuration steps
Usage with Claude in Browser
The MCP server uses OAuth 2.0 Dynamic Client Registration (DCR), which allows Claude to automatically register itself without manual client setup.
In Claude (claude.ai):
- Open Profile (bottom left corner)
- Click Settings (gear icon)
- Navigate to "Connectors"
- Click "Add custom connector"
- Enter your MCP server URL:
https://your-home-assistant.com/api/mcp - Click "Connect"
Claude will automatically:
- Discover your Home Assistant's OAuth endpoints
- Register itself as an OAuth client
- Redirect you to Home Assistant for authentication
- Request access to your Home Assistant data
In Home Assistant:
- Log in if not already authenticated
- Review the permissions requested by Claude
- Click "Authorize" to grant access
That's it! Claude will now be able to interact with your Home Assistant instance through the MCP server.
MCP Capabilities
Tools
| Tool | Description |
|---|---|
get_state |
Get the current state of any entity |
call_service |
Call any Home Assistant service |
list_entities |
List all entities, optionally filtered by domain |
get_config |
Get Home Assistant configuration (version, location, units, timezone) |
list_areas |
List all areas |
list_devices |
List devices, optionally filtered by area |
list_services |
List available services, optionally filtered by domain |
render_template |
Evaluate a Jinja2 template |
get_history |
Get state history of an entity over a time range |
create_automation |
Create a new automation |
update_automation |
Update an existing automation |
delete_automation |
Delete an automation |
create_scene |
Create a new scene |
update_scene |
Update an existing scene |
delete_scene |
Delete a scene |
create_script |
Create a new script |
update_script |
Update an existing script |
delete_script |
Delete a script |
list_dashboards |
List all Lovelace dashboards with metadata |
get_dashboard_config |
Get full dashboard configuration (views/cards) |
save_dashboard_config |
Save (replace) full dashboard configuration |
delete_dashboard_config |
Reset a dashboard configuration to empty |
create_dashboard |
Create a new Lovelace dashboard (experimental) |
update_dashboard |
Update dashboard metadata (experimental) |
delete_dashboard |
Delete a dashboard and its config (experimental) |
Resources
| URI | Description |
|---|---|
hass://config |
Home Assistant configuration |
hass://areas |
All areas |
hass://entity/{entity_id} |
State and attributes of a specific entity |
hass://dashboard/{url_path} |
Full configuration of a specific dashboard |
Prompts
| Prompt | Description |
|---|---|
troubleshoot_device |
Diagnose issues with a specific entity |
daily_summary |
Summarize recent activity across all entities |
Completions
Autocompletion is supported for entity_id, domain, service, area_id, and url_path arguments.
FAQ
How do I list all automations, scenes, or scripts?Use list_entities with the domain filter. This works for any entity type in Home Assistant.
list_entities(domain="automation") // all automations
list_entities(domain="scene") // all scenes
list_entities(domain="script") // all scripts
list_entities(domain="light") // all lights
To get the full state and attributes of a specific entity, use get_state:
get_state(entity_id="automation.morning_routine")
How do I create an automation?
Use create_automation with a standard HA automation config:
create_automation(config={
"alias": "Turn on lights at sunset",
"trigger": [{"platform": "sun", "event": "sunset"}],
"action": [{"service": "light.turn_on", "target": {"entity_id": "light.living_room"}}]
})
The same pattern applies to scenes and scripts. Scripts use a key parameter instead of an auto-generated ID:
create_script(key="morning_routine", config={
"alias": "Morning Routine",
"sequence": [{"service": "light.turn_on", "target": {"entity_id": "light.bedroom"}}]
})
How do I call a service like turning on a light?
Use call_service with the domain, service, and optionally an entity and extra data:
call_service(domain="light", service="turn_on", entity_id="light.living_room", data={"brightness": 200})
To discover what services are available:
list_services() // all services
list_services(domain="light") // just light services
How do I manage Lovelace dashboards?
Use list_dashboards to see all dashboards, then get_dashboard_config and save_dashboard_config to read and modify their content. Use url_path="default" for the main Overview dashboard:
get_dashboard_config(url_path="default")
save_dashboard_config(url_path="default", config={"views": [{"title": "Home", "cards": [...]}]})
To create or delete dashboards themselves, use the experimental create_dashboard and delete_dashboard tools. These use internal HA APIs and may break with future HA updates.
The create_dashboard, update_dashboard, and delete_dashboard tools use internal Home Assistant APIs (DashboardsCollection) that are not publicly exposed. They replicate side effects (panel registration, dashboards dict updates) that HA normally handles internally. These may break with HA updates that change internal behavior. The config-level tools (list_dashboards, get/save/delete_dashboard_config) use stable public APIs.
License
MIT
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi