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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。