Provides a comprehensive API for managing the entire Home Assistant ecosystem, including device control (lights, climate, covers, etc.), state monitoring, and automation management through natural language
Integrates with the Home Assistant Community Store (HACS) for package management, allowing listing, installing, and managing custom integrations, frontend themes, Python scripts, AppDaemon apps, and NetDaemon apps
Model Context Protocol Server for Home Assistant
The server uses the MCP protocol to share access to a local Home Assistant instance with an LLM application.
A powerful bridge between your Home Assistant instance and Language Learning Models (LLMs), enabling natural language control and monitoring of your smart home devices through the Model Context Protocol (MCP). This server provides a comprehensive API for managing your entire Home Assistant ecosystem, from device control to system administration.
Features
🎮 Device Control: Control any Home Assistant device through natural language
🔄 Real-time Updates: Get instant updates through Server-Sent Events (SSE)
🤖 Automation Management: Create, update, and manage automations
📊 State Monitoring: Track and query device states
🔐 Secure: Token-based authentication and rate limiting
📱 Mobile Ready: Works with any HTTP-capable client
Real-time Updates with SSE
The server includes a powerful Server-Sent Events (SSE) system that provides real-time updates from your Home Assistant instance. This allows you to:
🔄 Get instant state changes for any device
📡 Monitor automation triggers and executions
🎯 Subscribe to specific domains or entities
📊 Track service calls and script executions
Quick SSE Example
See SSE_API.md for complete documentation of the SSE system.
Table of Contents
Key Features
Core Functionality 🎮
Smart Device Control
💡 Lights: Brightness, color temperature, RGB color
🌡️ Climate: Temperature, HVAC modes, fan modes, humidity
🚪 Covers: Position and tilt control
🔌 Switches: On/off control
🚨 Sensors & Contacts: State monitoring
🎵 Media Players: Playback control, volume, source selection
🌪️ Fans: Speed, oscillation, direction
🔒 Locks: Lock/unlock control
🧹 Vacuums: Start, stop, return to base
📹 Cameras: Motion detection, snapshots
System Management 🛠️
Add-on Management
Browse available add-ons
Install/uninstall add-ons
Start/stop/restart add-ons
Version management
Configuration access
Package Management (HACS)
Integration with Home Assistant Community Store
Multiple package types support:
Custom integrations
Frontend themes
Python scripts
AppDaemon apps
NetDaemon apps
Version control and updates
Repository management
Automation Management
Create and edit automations
Advanced configuration options:
Multiple trigger types
Complex conditions
Action sequences
Execution modes
Duplicate and modify existing automations
Enable/disable automation rules
Trigger automation manually
Architecture Features 🏗️
Intelligent Organization
Area and floor-based device grouping
State monitoring and querying
Smart context awareness
Historical data access
Robust Architecture
Comprehensive error handling
State validation
Secure API integration
TypeScript type safety
Extensive test coverage
Prerequisites
Node.js 20.10.0 or higher
NPM package manager
Docker Compose for containerization
Running Home Assistant instance
Home Assistant long-lived access token (How to get token)
HACS installed for package management features
Supervisor access for add-on management
Installation
Basic Setup
Docker Setup (Recommended)
The project includes Docker support for easy deployment and consistent environments across different platforms.
Clone the repository:
git clone https://github.com/jango-blockchained/homeassistant-mcp.git cd homeassistant-mcpConfigure environment:
cp .env.example .envEdit the
.env
file with your Home Assistant configuration:# Home Assistant Configuration HASS_HOST=http://homeassistant.local:8123 HASS_TOKEN=your_home_assistant_token HASS_SOCKET_URL=ws://homeassistant.local:8123/api/websocket # Server Configuration PORT=3000 NODE_ENV=production DEBUG=falseBuild and run with Docker Compose:
# Build and start the containers docker compose up -d # View logs docker compose logs -f # Stop the service docker compose downVerify the installation: The server should now be running at
http://localhost:3000
. You can check the health endpoint athttp://localhost:3000/health
.Update the application:
# Pull the latest changes git pull # Rebuild and restart the containers docker compose up -d --build
Docker Configuration
The Docker setup includes:
Multi-stage build for optimal image size
Health checks for container monitoring
Volume mounting for environment configuration
Automatic container restart on failure
Exposed port 3000 for API access
Docker Compose Environment Variables
All environment variables can be configured in the .env
file. The following variables are supported:
HASS_HOST
: Your Home Assistant instance URLHASS_TOKEN
: Long-lived access token for Home AssistantHASS_SOCKET_URL
: WebSocket URL for Home AssistantPORT
: Server port (default: 3000)NODE_ENV
: Environment (production/development)DEBUG
: Enable debug mode (true/false)
Configuration
Environment Variables
Configuration Files
Development: Copy
.env.example
to.env.development
Production: Copy
.env.example
to.env.production
Testing: Copy
.env.example
to.env.test
Adding to Claude Desktop (or other clients)
To use your new Home Assistant MCP server, you can add Claude Desktop as a client. Add the following to the configuration. Note this will run the MCP within claude and does not work with the Docker method.
API Reference
Device Control
Common Entity Controls
Light Control
Add-on Management
List Available Add-ons
Install Add-on
Manage Add-on State
Package Management
List HACS Packages
Install Package
Automation Management
Create Automation
Duplicate Automation
Core Functions
State Management
Manages the current state of the system.
Example Request:
Context Updates
Updates the current context with new information.
Example Request:
Action Endpoints
Execute Action
Executes a specified action with given parameters.
Example Request:
Batch Actions
Executes multiple actions in sequence.
Example Request:
Query Functions
Get Available Actions
Returns a list of all available actions.
Example Response:
Context Query
Retrieves context information.
Example Response:
WebSocket Events
The server supports real-time updates via WebSocket connections.
Supported Events
state_change
: Emitted when system state changescontext_update
: Emitted when context is updatedaction_executed
: Emitted when an action is completederror
: Emitted when an error occurs
Example Event Data:
Error Handling
All endpoints return standard HTTP status codes:
200: Success
400: Bad Request
401: Unauthorized
403: Forbidden
404: Not Found
500: Internal Server Error
Error Response Format:
Rate Limiting
The API implements rate limiting to prevent abuse:
100 requests per minute per IP for regular endpoints
1000 requests per minute per IP for WebSocket connections
When rate limit is exceeded, the server returns:
Example Usage
Using curl
Using JavaScript
Development
Troubleshooting
Common Issues
Node.js Version (
Solution: Update to Node.js 20.10.0+
nvm install 20.10.0 nvm use 20.10.0Connection Issues
Verify Home Assistant is running
Check
HASS_HOST
accessibilityValidate token permissions
Ensure WebSocket connection for real-time updates
Add-on Management Issues
Verify Supervisor access
Check add-on compatibility
Validate system resources
HACS Integration Issues
Verify HACS installation
Check HACS integration status
Validate repository access
Automation Issues
Verify entity availability
Check trigger conditions
Validate service calls
Monitor execution logs
Project Status
✅ Complete
Entity, Floor, and Area access
Device control (Lights, Climate, Covers, Switches, Contacts)
Add-on management system
Package management through HACS
Advanced automation configuration
Basic state management
Error handling and validation
Docker containerization
Jest testing setup
TypeScript integration
Environment variable management
Home Assistant API integration
Project documentation
🚧 In Progress
WebSocket implementation for real-time updates
Enhanced security features
Tool organization optimization
Performance optimization
Resource context integration
API documentation generation
Multi-platform desktop integration
Advanced error recovery
Custom prompt testing
Enhanced macOS integration
Type safety improvements
Testing coverage expansion
Contributing
Fork the repository
Create a feature branch
Implement your changes
Add tests for new functionality
Ensure all tests pass
Submit a pull request
Resources
License
MIT License - See LICENSE file
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Access Home Assistant data and control devices (lights, switches, thermostats, etc).
Related MCP Servers
- -securityAlicense-qualitySmart Device Control 🎮 💡 Lights: Brightness, color, RGB 🌡️ Climate: Temperature, HVAC, humidity 🚪 Covers: Position and tilt 🔌 Switches: On/off 🚨 Sensors: State monitoring Intelligent Organization 🏠 Grouping with context awareness. Robust Architecture 🛠️ Error handling, state validation ...Last updated -630Apache 2.0
- -securityFlicense-qualityEnables users to control Google Home smart plugs using the Smart Home API with OAuth2 authentication, offering real-time device state management and control operations.
- AsecurityAlicenseAqualityEnables AI assistants to control SwitchBot devices, providing functionalities like device management, scene execution, and sensor information monitoring through the SwitchBot API.Last updated -3ISC License
- AsecurityAlicenseAqualityA server that enables interaction with Home Assistant devices and automations through the Model Context Protocol, allowing users to monitor device states, control devices, trigger automations, and list entities.Last updated -44MIT License
Appeared in Searches
- An MCP for managing lifestyle, coordinating daily routines, exercise, and study tasks
- Searching for information about license types or information starting with 'f'
- A server for finding information about guitars
- Software or solutions for managing a fleet of computers
- Information about Baselight color grading software