HA-Synapse
Connects LLM coding agents to Home Assistant instances, enabling configuration file management, service calls, template testing, and automation diagnostics via MCP tools.
README
HA Synapse 🧠
HA Synapse is a Model Context Protocol (MCP) server designed to act as a bridge between LLM coding agents (such as Antigravity, Claude Code, Cursor, or Codex) and your Home Assistant instance(s).
Rather than executing ad-hoc API scripts, HA Synapse provides a standardized set of MCP tools and resources. This allows AI agents to read and modify configuration files safely, call services, dry-run templates, query history, and debug automation traces dynamically.
Note: This was largely developed with agentic coding.
Architecture: Where does HA Synapse live?
HA Synapse runs on the local machine where the coding agent executes (e.g., your laptop or development desktop).
graph TD
subgraph Local Developer Machine
Agent[LLM Coding Agent] <-->|MCP Protocol / stdio| Synapse[HA Synapse MCP Server]
end
subgraph Smart Home
Synapse <-->|HTTP REST & WebSockets| HAAPI[Home Assistant API]
Synapse <-->|SSH / SFTP Commands| HAFS[Home Assistant File System]
end
It communicates over the network with one or more Home Assistant instances:
- REST & WebSockets: Used for real-time state caching, service execution, template rendering, history, and automation traces.
- SSH Connection: Used to read/write configuration files (like
configuration.yamlor packages) directly inside the/configor/homeassistantfolders without requiring custom HACS components on the Home Assistant side.
Key Features
- Multi-Instance Support: Manage multiple Home Assistant installations (e.g.,
homeandoffice) from a single MCP server. - Real-time State Caching: Maintains an active WebSocket connection to keep an in-memory copy of all entity states, preventing context bloat and rate-limiting.
- Atomic Writes & Safety Guard:
- Checks YAML syntax locally.
- Backs up files in
.mcp_backups/before modifying them. - Runs Home Assistant's configuration validation check after writing.
- Automatically rolls back to the original file if validation fails, preventing your smart home from locking up.
- Jinja2 Template Testing: Exposes a template rendering tool, letting the AI verify calculation outcomes before deploying them in automations.
- Automation Tracing: Exposes execution traces to let the AI see exactly which condition failed in a broken automation.
Installation & Setup
We provide a Guided Setup Wizard to make installation as simple as possible for both technical and non-technical users.
1. Prerequisite
- Home Assistant Long-Lived Access Token:
- Open your Home Assistant UI, click on your profile name (bottom left), go to the Security tab, scroll to the bottom, and click Create Token. Save this token.
2. Run the Setup Wizard
Clone the repository, install dependencies, and run the interactive setup tool:
npm install
npm run build
npm run setup
The guided wizard will walk you through setting up your connection and offers to:
- Auto-Provision SSH/SFTP (HA OS & Supervised): Automatically generate a secure SSH key pair locally, install the official "Terminal & SSH" add-on on your Home Assistant OS, configure it with the public key, expose port 22, and start it.
- Auto-Install HACS: Automatically download and install the Home Assistant Community Store (HACS) over the new SSH link.
- Manual Fallback: Let you input manual SSH details or local folders if running a containerized/Core Home Assistant instance.
- Configure Backups: Toggle whether the server keeps persistent timestamped backups of edited files.
Once finished, the wizard will save your configuration to ~/.ha-synapse.json and output the exact configuration block ready to paste into your Claude Desktop, Cursor, or coding agent settings.
Manual Configuration (Optional)
If you prefer to configure the server manually, create a .ha-synapse.json file in your home directory (e.g. C:\Users\<username>\.ha-synapse.json or ~/.ha-synapse.json):
{
"defaultInstance": "home",
"instances": {
"home": {
"url": "http://10.0.2.52:8123",
"token": "YOUR_LONG_LIVED_ACCESS_TOKEN",
"mode": "ssh",
"backupEnabled": true,
"remoteConfigDir": "/homeassistant",
"ssh": {
"host": "10.0.2.52",
"port": 22,
"user": "root",
"keyPath": "C:\\Users\\<username>\\.ssh\\id_ed25519"
}
}
}
}
Commands
Install dependencies:
npm install
Compile TypeScript to Javascript:
npm run build
Run integration test suite:
npm run test-conn
Start the MCP server:
npm start
Integrating with Claude Desktop
To use HA Synapse with Claude Desktop, add it to your claude_desktop_config.json configuration (typically found at %APPDATA%\Claude\claude_desktop_config.json):
{
"mcpServers": {
"ha-synapse": {
"command": "node",
"args": ["/path/to/ha-synapse/build/index.js"],
"env": {
"HA_MCP_CONFIG_PATH": "/path/to/ha-synapse/ha-synapse.json"
}
}
}
}
Exposed MCP Tools
- Entity Exploration:
get_entity_list: Returnsfriendly_name,entity_id, andstate.get_entity_details: Returns full attributes of selected entity IDs.search_entities: Search by area, domain, or query matching.
- Control:
call_service: Execute any Home Assistant service (e.g.light.turn_on,tts.speak).
- Configuration & File Management:
read_ha_file: Sandbox-constrained file read.write_ha_file: Safety-wrapped file writing with config validation rollback.validate_ha_config: Triggers configuration check.reload_ha: Reloads core, templates, automations, scripts, and themes.restart_ha: Restarts the Home Assistant core.
- Orchestration & Diagnostics:
render_template: Evaluates Jinja2 template strings in the HA engine.get_history: Fetches historical state changes.get_automation_traces: Fetches run histories of automations.get_automation_trace_details: Fetches execution steps of a specific trace.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。