MCP Home Assistant Server
Enables LLMs to control Home Assistant devices, including lights, switches, and climate devices, through natural language commands.
README
MCP Home Assistant Server
A Model Context Protocol (MCP) server that allows Large Language Models (LLMs) like Claude to control your Home Assistant devices and smart home setup.
Features
- Device Control: Control lights, switches, climate devices, and more
- Device Discovery: Get lists of all devices or filter by type
- State Monitoring: Check current device states
- Docker Containerized: Runs in isolated Docker containers with auto-cleanup
- Secure Configuration: All credentials stored in environment variables
- Clean Integration: Optimized logging prevents error messages in Claude Desktop
- On-Demand Architecture: Containers spawn only when needed, auto-remove when done
Prerequisites
- Docker and Docker Compose installed
- Home Assistant instance running (yours is at
192.168.200.111:8123) - Long-Lived Access Token from Home Assistant
Setup
1. Get Home Assistant Access Token
- Go to your Home Assistant instance:
http://192.168.200.111:8123 - Navigate to Profile (bottom left menu)
- Scroll down to Long-Lived Access Tokens
- Click Create Token
- Give it a name like "MCP Server"
- Copy the generated token
2. Configure Environment Variables
-
Copy the example environment file:
cp env_example.txt .env -
Edit the
.envfile and replaceyour_long_lived_access_token_herewith your actual token:HOME_ASSISTANT_TOKEN=your_actual_token_here -
Verify other settings:
HOME_ASSISTANT_URLshould already be set to your instanceVERIFY_SSLshould betrueunless you're using self-signed certificates
3. Build the Docker Image
# Build the Docker image
docker-compose build
# Test the image (optional)
echo '{"jsonrpc": "2.0", "method": "initialize", "id": 1}' | docker run --rm -i --env-file .env mcp-homeassistant-mcp-homeassistant
Note: You don't need to run containers manually - Claude Desktop will manage them automatically!
Available Tools
The MCP server provides the following tools that LLMs can use:
Device Discovery
get_all_devices: Get a list of all devices and their current statesget_devices_by_type: Get devices of a specific type (light, switch, climate, etc.)get_device_state: Get the current state of a specific device
Device Control
control_light: Control lights (turn on/off, adjust brightness, color temperature)control_switch: Control switches (turn on/off/toggle)control_climate: Control climate devices (temperature, mode)
Usage with Claude
To use this MCP server with Claude Desktop:
-
Install Claude Desktop from https://claude.ai/download
-
Configure MCP in Claude Desktop:
- Open Claude Desktop settings
- Go to the MCP section
- Add a new MCP server with these settings:
{ "mcpServers": { "home-assistant": { "command": "docker", "args": [ "run", "--rm", "-i", "--stop-timeout=5", "--env-file", "/path/to/your/MCP-HomeAssistant/.env", "mcp-homeassistant-mcp-homeassistant" ] } } } - Replace
/path/to/your/MCP-HomeAssistant/.envwith the full path to your.envfile
-
Restart Claude Desktop
-
Test the integration by asking Claude to control your devices:
- "Turn on the living room lights"
- "What's the current temperature in the bedroom?"
- "List all my smart switches"
Example Interactions
Here are some example conversations you can have with Claude:
User: Can you turn on the living room lights?
Claude: I'll help you turn on the living room lights. Let me check what lights are available first.
[Claude uses the get_devices_by_type tool to find lights]
[Claude uses the control_light tool to turn on the lights]
The living room lights have been turned on successfully!
User: What's the temperature in my house?
Claude: Let me check your climate devices to see the current temperatures.
[Claude uses the get_devices_by_type tool to find climate devices]
Based on your climate devices, here's the current status:
- Living Room: 72°F
- Bedroom: 70°F
- Kitchen: 74°F
Troubleshooting
Connection Issues
- Verify your Home Assistant URL is correct:
http://192.168.200.111:8123 - Check that your access token is valid and not expired
- Ensure your Docker container can reach your Home Assistant instance
SSL Issues
If you're using self-signed certificates, set VERIFY_SSL=false in your .env file.
Docker Issues
- Make sure Docker is running:
docker --version - Test the image manually:
docker run --rm -i --env-file .env mcp-homeassistant-mcp-homeassistant - Rebuild if needed:
docker-compose build --no-cache
MCP Integration Issues
- Verify the path to your
.envfile in the Claude Desktop configuration - Restart Claude Desktop after configuration changes
- Check Docker Desktop for running containers (multiple containers during use is normal)
Multiple Container Issue
If you see many containers running:
- This is normal behavior - Claude Desktop spawns containers on-demand
- Containers auto-remove when conversations end (thanks to
--rmflag) - Use the cleanup script if needed:
./cleanup-containers.sh
JSON-RPC Errors
If you see error messages in Claude Desktop:
- Make sure you're using the latest version of the Docker image
- The logging has been optimized to prevent stdout interference
- Restart Claude Desktop to clear any cached issues
Security Notes
- Your
.envfile contains sensitive credentials - keep it secure - The MCP server only has access to the Home Assistant API token you provide
- Consider restricting the token's permissions in Home Assistant if possible
- Never commit the
.envfile to version control
Container Management
Normal Operation
- Multiple containers during use is expected - Claude Desktop spawns containers on-demand
- Containers auto-cleanup when conversations end (via
--rmflag) - No manual management needed - the system handles container lifecycle
Manual Cleanup (if needed)
# Stop all MCP containers
./cleanup-containers.sh
# Or manually:
docker stop $(docker ps -q --filter "ancestor=mcp-homeassistant-mcp-homeassistant")
docker container prune -f
Viewing Logs
# View logs from running containers
docker logs <container-name>
# Or check the log file inside container
docker exec <container-name> cat /app/mcp_server.log
Development
To modify the MCP server:
- Edit
mcp_server.py - Rebuild the container:
docker-compose build - Test:
docker run --rm -i --env-file .env mcp-homeassistant-mcp-homeassistant - Restart Claude Desktop to use the new image
License
This project is open source. Feel free to modify and distribute.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.