Async client for the Home Assistant Supervisor and ESPHome dashboard / Device Builder API
Project description
ESPHome MCP Bridge
Drive a full ESPHome development cycle from an AI agent (e.g. Claude Code via Home Assistant's MCP server). This repo ships a Home Assistant custom integration that registers a custom LLM API exposing ESPHome tools, backed by a small reusable PyPI client library.
AI agent ── MCP ──► Home Assistant ──► ESPHome Builder LLM API
│
┌───────────────┴───────────────┐
▼ ▼
/config/esphome (files) ESPHome dashboard add-on
(stable / beta / dev) via
Supervisor internal network
Why this works without sidecars
The integration runs inside Home Assistant Core, so it has:
- Native filesystem access to
/config/esphomefor reading, creating, and writing YAML — reliable and independent of which add-on is installed. - Internal network access to the ESPHome dashboard add-on through the Supervisor, reaching the dashboard's container directly (no ingress auth, no exposed ports) for validate / compile / upload / run / logs.
No changes to the ESPHome add-on and no external containers required.
The development-cycle tools
The ESPHome Builder LLM API exposes these tools:
| Tool | Purpose |
|---|---|
esphome_list_addons |
Discover installed ESPHome channels (stable/beta/dev), versions, state |
esphome_list_devices |
Inventory devices: name, version, platform, integrations, online status |
esphome_read_yaml |
Read a config from /config/esphome |
esphome_create_config |
Create a new config (fails if it exists) |
esphome_write_yaml |
Overwrite an existing config |
esphome_validate |
Validate a config without building |
esphome_compile |
Compile firmware (runs to completion, returns log + exit code) |
esphome_upload |
Flash firmware to a device (port defaults to OTA) |
esphome_run |
Compile and flash in one step (dashboard "Install") |
esphome_logs |
Capture a bounded window of live device logs for debugging |
esphome_clean |
Remove cached build artifacts |
A typical agent flow: list devices → read/create config → write → validate → compile → run → check logs.
Each build tool accepts an optional addon_slug to target a specific channel;
omit it to use the default (stable preferred over beta over dev).
Multi-channel discovery
esphome_list_addons queries the Supervisor for every installed add-on whose
slug or name matches esphome (5c53de3b_esphome, …_esphome-beta,
…_esphome-dev). The bridge resolves each add-on's internal hostname and port
from the Supervisor, so it adapts automatically rather than hard-coding a URL.
Requirements
- Home Assistant with the Supervisor (HA OS or Supervised install)
- An ESPHome dashboard add-on installed (classic dashboard or the new Device Builder — both speak the protocol this bridge uses)
- Home Assistant 2024.4.0+ (LLM API helpers)
Installation
HACS (integration)
- Add this repository as a custom HACS repository (type: Integration).
- Install ESPHome MCP Bridge and restart Home Assistant.
- Add to
configuration.yaml:esphome_mcp_bridge:
- Restart. The
ESPHome BuilderAPI appears in the LLM/Assist API selector and to MCP clients.
Manual
Copy custom_components/esphome_mcp_bridge/ into your HA
config/custom_components/, add esphome_mcp_bridge: to configuration.yaml,
and restart.
Home Assistant installs the
esphome-mcp-clientPyPI dependency automatically (declared in the integration manifest).
Security
- File tools are confined to
/config/esphome; directory traversal (..,/,\) is rejected outright. secrets.yaml/secrets.ymlare blocked from read, write, create, and build.- Writes/creates accept only
.yaml/.yml. - Supervisor requests use the
SUPERVISOR_TOKENinjected at runtime — no credentials are stored.
Repository layout
esphome_mcp_client/— reusable async transport library → published to PyPI asesphome-mcp-client(see PYPI_SETUP.md).custom_components/esphome_mcp_bridge/— the Home Assistant integration (LLM tool definitions + API registration).tests/— unit tests for the client library.
Development
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
ruff check esphome_mcp_client tests
pytest
License
MIT © Justin Rigling
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file esphome_mcp_client-0.1.0.tar.gz.
File metadata
- Download URL: esphome_mcp_client-0.1.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdf987123b50b64fb35f4378834ce300baec50f56de4cb06d98c96c5a824ec8e
|
|
| MD5 |
cae2e0ff5cc99e99b4e3b2f4a48f68b2
|
|
| BLAKE2b-256 |
9da0057d07dfe22570625bd566bb72aeffd2f84a1d4329390f8934bef0bb9e5d
|
File details
Details for the file esphome_mcp_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: esphome_mcp_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
009ce0422f5fb7e969a5a23b34ca49d11ace5661f70f15acd5bf8418b2fb34af
|
|
| MD5 |
422e17cf3c7d5241c9914ee734eeeb4e
|
|
| BLAKE2b-256 |
8da9277ff0b6fdd843e895cb852d460f33275f9c4b2821377e81c9727e42eff5
|