A comprehensive Model Context Protocol (MCP) server for integrating with Home Assistant. This server provides 60 tools and resources to interact with your Home Assistant instance via the REST API, enabling full smart home management and automation.
60 Total Tools across 9 Major Categories for comprehensive Home Assistant management:
- Entity State Management: Get, set, update, and delete entity states
- Service Calls: Execute Home Assistant services with full response support
- Entity Search: Advanced search with filtering by name, domain, or state
- Event Handling: Fire custom events with data payloads
- Template Rendering: Render Home Assistant templates with live data
- Area Management: Create, update, delete areas/zones with aliases
- Device Registry: List, configure, and manage all Home Assistant devices
- Entity Organization: Assign entities to areas, bulk area operations
- Device Assignment: Move devices between areas, enable/disable devices
- System Control: Restart/stop Home Assistant safely
- Health Monitoring: Check system health and component status
- Configuration Validation: Validate configs before applying changes
- Supervisor Integration: Get supervisor info (Home Assistant OS)
- Integration Lifecycle: List, enable, disable, delete integrations
- Integration Troubleshooting: Reload integrations, get detailed info
- Dynamic Management: Programmatically manage integration configurations
- Multi-Channel Notifications: Send via mobile apps, persistent notifications
- Service Discovery: List all available notification services
- Notification Management: Dismiss persistent notifications
- Entity Configuration: Update entity names, areas, enabled/disabled status
- Bulk Operations: Enable/disable multiple entities
- Registry Information: Get detailed entity registry data
- Automation Control: Create, update, delete, trigger automations
- Scene Management: Activate scenes, create new scenes from current states
- Automation Debugging: Get execution traces and troubleshooting data
- Lifecycle Management: Full CRUD operations for automations
- Historical Data: Advanced history queries with filtering options
- Logbook Access: Get event history and entity changes
- Error Logs: Retrieve Home Assistant error logs for debugging
- Calendar Integration: List calendars and get events with date ranges
- Camera Support: Get images from camera entities (base64 encoded)
- Intent Processing: Handle Home Assistant voice/text intents
- Real-time Events: Subscribe to live Home Assistant events via SSE
- Clone this repository:
git clone https://github.com/cronus42/homeassistant-mcp.git
cd homeassistant-mcp- Run the setup script:
./setup.sh-
Get your Home Assistant Long-Lived Access Token:
- Log into your Home Assistant web interface
- Go to Profile (click on your user name in bottom left)
- Scroll down to "Long-lived access tokens"
- Click "Create Token"
- Give it a name (e.g., "MCP Server")
- Copy the token
-
Configure your settings:
cp .env.example .env
# Edit .env with your Home Assistant URL and token- Test the connection:
python tests/test_connection.py- Run the setup script:
./setup.sh- Configure Warp to use the MCP server:
warp mcp add-server --config mcp_config.jsonOr manually start the server:
./start_server.shAdd to your Claude Desktop config file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"homeassistant": {
"command": "/path/to/homeassistant-mcp/start_server.sh",
"env": {},
"args": []
}
}
}Get the current state of a specific Home Assistant entity.
{
"entity_id": "light.living_room"
}Call a Home Assistant service to control devices.
{
"domain": "light",
"service": "turn_on",
"entity_id": "light.living_room",
"service_data": {
"brightness": 255,
"color_temp": 3000
}
}Search for entities by name, domain, or state.
{
"query": "temperature",
"domain": "sensor"
}Fire a custom event in Home Assistant.
{
"event_type": "custom_automation_trigger",
"event_data": {
"source": "mcp_server",
"action": "test"
}
}Get historical data for specific entities.
{
"entity_ids": ["sensor.temperature", "light.living_room"],
"start_time": "2024-01-01T00:00:00Z"
}{
"tool": "get_areas",
"arguments": {}
}{
"tool": "create_area",
"arguments": {
"name": "Home Office",
"aliases": ["office", "workspace"]
}
}{
"tool": "get_devices",
"arguments": {}
}{
"tool": "get_system_health",
"arguments": {}
}{
"tool": "send_notification",
"arguments": {
"message": "Security Alert: Front door opened",
"title": "Security System",
"target": "mobile_app_phone"
}
}{
"tool": "get_integrations",
"arguments": {}
}The server includes comprehensive test suites:
# Test tool definitions and schemas
python tests/test_mcp_tools.py
# Test tool handlers with mocking
python tests/test_tool_handlers.py
# Test with real Home Assistant (requires HA_TOKEN)
python tests/test_new_features.py
# Test basic connection
python tests/test_connection.py- ✅ 60/60 tools properly defined
- ✅ All schemas validated
- ✅ All tool handlers working correctly
- ✅ 100% test coverage for new features
homeassistant://states- Current state of all entitieshomeassistant://config- Home Assistant configurationhomeassistant://services- Available serviceshomeassistant://events- Available event types
{
"tool": "call_service",
"arguments": {
"domain": "light",
"service": "turn_on",
"entity_id": "light.living_room"
}
}{
"tool": "search_entities",
"arguments": {
"query": "temperature",
"domain": "sensor"
}
}{
"tool": "search_entities",
"arguments": {
"query": "light",
"domain": "light"
}
}- Store your Home Assistant token securely
- Use environment variables for configuration
- Consider network security between your MCP client and Home Assistant
- Limit token permissions if possible
- Verify Home Assistant URL is accessible
- Check if Home Assistant API is enabled
- Ensure token is valid and has proper permissions
- Regenerate long-lived access token
- Check token format (should be a long string)
- Verify token is set in environment variable
- Check entity IDs exist in Home Assistant
- Verify service names and parameters
- Check Home Assistant logs for errors
Feel free to submit issues and enhancement requests!