
robbrad/homeassistant-mcp 是从 https://github.com/robbrad/homeassistant-mcp. 导入的 MCP 服务器候选
概览
robbrad/homeassistant-mcp 是从 https://github.com/robbrad/homeassistant-mcp. 导入的 MCP 服务器候选
概述(AI 翻译)
一款模型上下文协议(MCP)服务器,允许AI助手控制Home Assistant。采用Python和FastMCP构建。
可支持Claude、GPT-4、Cursor、Kiro及任何兼容MCP的客户端。
它的作用
- 40个工具,涵盖灯具、气候、罩子、锁、媒体播放器、吸尘器、风扇、摄像头、报警器等
- BM25 工具搜索 — LLM按需发现工具,而非事先接收全部40个模式
- MCP 资源,用于只读实体、区域、设备和服务数据
- MCP 提示,用于引导工作流程(自动化创建、故障排除、能源优化)
- 工具注释 —
readOnlyHint允许用户跳过确认提示以实现安全操作 - 智能错误日志解析 — 去重并汇总HA错误日志,而不是直接倾倒原始文本
- 上下文感知响应 — 紧凑列表响应、域过滤查询、进度报告
- 全段采用异步,并采用基于TTL的缓存以降低API负载
安装
UVX(推荐)
无需安装。只需配置你的MCP客户端:
皮普
来自源头
配置
服务器需要两个环境变量:
| 变量 | 描述 |
|---|
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Home Assistant MCP Server
A Model Context Protocol (MCP) server that lets AI assistants control Home Assistant. Built with Python and FastMCP.
Works with Claude, GPT-4, Cursor, Kiro, and any MCP-compatible client.
What it does
- 40 tools covering lights, climate, covers, locks, media players, vacuums, fans, cameras, alarms, and more
- BM25 tool search — LLMs discover tools on demand instead of receiving all 40 schemas upfront
- MCP Resources for read-only entity, area, device, and service data
- MCP Prompts for guided workflows (automation creation, troubleshooting, energy optimization)
- Tool annotations —
readOnlyHintlets clients skip confirmation prompts for safe operations - Smart error log parsing — deduplicates and summarises HA error logs instead of dumping raw text
- Context-aware responses — compact list responses, domain-filtered queries, progress reporting
- Async throughout with TTL-based caching to reduce API load
Installation
uvx (recommended)
No install needed. Just configure your MCP client:
{
"mcpServers": {
"homeassistant": {
"command": "uvx",
"args": ["homeassistant-mcp"],
"env": {
"HASS_HOST": "http://homeassistant.local:8123",
"HASS_TOKEN": "your_long_lived_access_token_here"
}
}
}
}
pip
pip install homeassistant-mcp
homeassistant-mcp
From source
git clone https://github.com/robbrad/homeassistant-mcp.git
cd homeassistant-mcp
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -e ".[dev]"
homeassistant-mcp
Configuration
The server needs two environment variables:
| Variable | Description |
|---|---|
HASS_HOST |
Home Assistant URL, e.g. http://homeassistant.local:8123 |
HASS_TOKEN |
Long-lived access token (how to create one) |
Optional:
| Variable | Default | Description |
|---|---|---|
CACHE_TTL_STATES |
30 |
Cache TTL for bulk state queries (seconds) |
CACHE_TTL_ENTITY |
10 |
Cache TTL for individual entity queries (seconds) |
LOG_LEVEL |
INFO |
Logging level |
These can be set via environment variables (as shown in the MCP client configs above) or in a .env file. See .env.example.
MCP Client Setup
Claude Desktop
Add to your config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"homeassistant": {
"command": "uvx",
"args": ["homeassistant-mcp"],
"env": {
"HASS_HOST": "http://homeassistant.local:8123",
"HASS_TOKEN": "your_token_here"
}
}
}
}
Cursor / Kiro / Other MCP Clients
安装
uvx homeassistant-mcp配置
{
"mcpServers": {
"homeassistant": {
"command": "uvx",
"args": ["homeassistant-mcp"],
"env": {
"HASS_HOST": "http://homeassistant.local:8123",
"HASS_TOKEN": "your_long_lived_access_token_here"
}
}
}
}