This MCP server acts as a bridge between your Home Assistant instance and Language Learning Models (LLMs), allowing natural language control and monitoring of your smart home through the Model Context Protocol. It provides a comprehensive API for managing your entire Home Assistant ecosystem, from controlling devices to managing automations.
# Clone the repository
git clone https://github.com/jango-blockchained/homeassistant-mcp.git
cd homeassistant-mcp
# Install dependencies
npm install
# Build the project
npm run build
Clone the repository:
git clone https://github.com/jango-blockchained/homeassistant-mcp.git
cd homeassistant-mcp
Configure environment:
cp .env.example .env
Edit 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=false
Build 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 down
Verify the installation:
The server should now be running at http://localhost:3000
. You can check the health endpoint at http://localhost:3000/health
.
Update the application:
# Pull the latest changes
git pull
# Rebuild and restart the containers
docker compose up -d --build
# Home Assistant Configuration
HASS_HOST=http://homeassistant.local:8123 # Your Home Assistant instance URL
HASS_TOKEN=your_home_assistant_token # Long-lived access token
HASS_SOCKET_URL=ws://homeassistant.local:8123/api/websocket # WebSocket URL
# Server Configuration
PORT=3000 # Server port (default: 3000)
NODE_ENV=production # Environment (production/development)
DEBUG=false # Enable debug mode
To use your new Home Assistant MCP server with Claude Desktop:
{
"homeassistant": {
"command": "node",
"args": [<path/to/your/dist/folder>]
"env": {
"NODE_ENV": "development",
"HASS_HOST": "http://homeassistant.local:8123",
"HASS_TOKEN": "your_home_assistant_token",
"PORT": "3000",
"HASS_SOCKET_URL": "ws://homeassistant.local:8123/api/websocket",
"LOG_LEVEL": "debug"
}
}
}
The server includes a powerful Server-Sent Events (SSE) system for real-time updates:
const eventSource = new EventSource(
'http://localhost:3000/subscribe_events?token=YOUR_TOKEN&domain=light'
);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Update received:', data);
};
{
"tool": "control",
"command": "turn_on", // or "turn_off", "toggle"
"entity_id": "light.living_room"
}
{
"tool": "control",
"command": "turn_on",
"entity_id": "light.living_room",
"brightness": 128,
"color_temp": 4000,
"rgb_color": [255, 0, 0]
}
{
"tool": "addon",
"action": "list"
}
{
"tool": "addon",
"action": "install",
"slug": "core_configurator",
"version": "5.6.0"
}
{
"tool": "addon",
"action": "start", // or "stop", "restart"
"slug": "core_configurator"
}
{
"tool": "package",
"action": "list",
"category": "integration" // or "plugin", "theme", "python_script", "appdaemon", "netdaemon"
}
{
"tool": "package",
"action": "install",
"category": "integration",
"repository": "hacs/integration",
"version": "1.32.0"
}
{
"tool": "automation_config",
"action": "create",
"config": {
"alias": "Motion Light",
"description": "Turn on light when motion detected",
"mode": "single",
"trigger": [
{
"platform": "state",
"entity_id": "binary_sensor.motion",
"to": "on"
}
],
"action": [
{
"service": "light.turn_on",
"target": {
"entity_id": "light.living_room"
}
}
]
}
}
{
"tool": "automation_config",
"action": "duplicate",
"automation_id": "automation.motion_light"
}
Node.js Version (toSorted is not a function
)
nvm install 20.10.0
nvm use 20.10.0
Connection Issues
HASS_HOST
accessibilityAdd-on Management Issues
HACS Integration Issues
Automation Issues
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.