Skip to content

Commit dda6031

Browse files
ekobresgemini-code-assist[bot]Copilot
authored
Added feature flags for gated features to App config. (#1030)
* Added feature flags for HAMCP_ENABLE_FILESYSTEM_TOOLS and HAMCP_ENABLE_CUSTOM_COMPONENT_INTEGRATION to the App configuration. * docs: document enable_filesystem_tools and enable_custom_component_integration addon options * Update homeassistant-addon/DOCS.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update homeassistant-addon/DOCS.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Moved feature flags to "unused" section for safety. * Added descriptions for feature flag options. * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Moved file tools to beta status. * Added beta tag to ha_config_set_yaml in docs. * Tagged ha_install_mcp_tools as beta and updated docs. * Update homeassistant-addon-dev/translations/en.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update homeassistant-addon-dev/translations/en.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 03816d3 commit dda6031

10 files changed

Lines changed: 73 additions & 21 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Spend less time configuring, more time enjoying your smart home.
164164
| **Dashboards** | `ha_config_delete_dashboard_resource`, `ha_config_delete_dashboard`, `ha_config_get_dashboard`, `ha_config_list_dashboard_resources`, `ha_config_set_dashboard_resource`, `ha_config_set_dashboard` |
165165
| **Device Registry** | `ha_get_device`, `ha_remove_device`, `ha_update_device` |
166166
| **Entity Registry** | `ha_get_entity_exposure`, `ha_get_entity`, `ha_remove_entity`, `ha_set_entity` |
167-
| **Files** | `ha_delete_file`, `ha_list_files`, `ha_read_file`, `ha_write_file` |
167+
| **Files** | `ha_delete_file` *(beta)*, `ha_list_files` *(beta)*, `ha_read_file` *(beta)*, `ha_write_file` *(beta)* |
168168
| **Groups** | `ha_config_list_groups`, `ha_config_remove_group`, `ha_config_set_group` |
169169
| **HACS** | `ha_hacs_add_repository`, `ha_hacs_download`, `ha_hacs_repository_info`, `ha_hacs_search` |
170170
| **Helper Entities** | `ha_config_list_helpers`, `ha_config_remove_helper`, `ha_config_set_helper`, `ha_get_helper_schema` |
@@ -184,19 +184,19 @@ Spend less time configuring, more time enjoying your smart home.
184184

185185
---
186186

187-
## 🔌 Custom Component (ha_mcp_tools)
187+
## 🔌 Custom Component (ha_mcp_tools) *(beta)*
188188

189189
Some tools require a companion custom component installed in Home Assistant. Standard HA APIs do not expose file system access or YAML config editing. This component provides both.
190190

191191
**Tools that require the component:**
192192

193193
| Tool | Description |
194194
|------|-------------|
195-
| `ha_config_set_yaml` | Safely add, replace, or remove top-level YAML keys in `configuration.yaml` and package files (automatic backup, validation, and config check) |
196-
| `ha_list_files` | List files in allowed directories (www/, themes/, custom_templates/) |
197-
| `ha_read_file` | Read files from allowed paths (config YAML, logs, www/, themes/, custom_templates/, custom_components/) |
198-
| `ha_write_file` | Write files to allowed directories |
199-
| `ha_delete_file` | Delete files from allowed directories |
195+
| `ha_config_set_yaml` *(beta)* | Safely add, replace, or remove top-level YAML keys in `configuration.yaml` and package files (automatic backup, validation, and config check) |
196+
| `ha_list_files` *(beta)* | List files in allowed directories (www/, themes/, custom_templates/) |
197+
| `ha_read_file` *(beta)* | Read files from allowed paths (config YAML, logs, www/, themes/, custom_templates/, custom_components/) |
198+
| `ha_write_file` *(beta)* | Write files to allowed directories |
199+
| `ha_delete_file` *(beta)* | Delete files from allowed directories |
200200

201201
All other tools work without the component. These five return an error with installation instructions if the component is missing.
202202

docs/beta.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@ Some ha-mcp tools are gated behind feature flags and available only in the **dev
77
| Tool | Toggle / env var | Description |
88
|---|---|---|
99
| `ha_config_set_yaml` | `enable_yaml_config_editing` (dev add-on) / `ENABLE_YAML_CONFIG_EDITING=true` (env var) | Raw YAML editing of `configuration.yaml` and packages/*.yaml for YAML-only integrations. |
10+
| `ha_list_files` | `enable_filesystem_tools` (dev add-on) / `HAMCP_ENABLE_FILESYSTEM_TOOLS=true` (env var) | List files in allowed directories (www/, themes/, custom_templates/). Requires `ha_mcp_tools` custom component. |
11+
| `ha_read_file` | `enable_filesystem_tools` (dev add-on) / `HAMCP_ENABLE_FILESYSTEM_TOOLS=true` (env var) | Read files from allowed paths. Requires `ha_mcp_tools` custom component. |
12+
| `ha_write_file` | `enable_filesystem_tools` (dev add-on) / `HAMCP_ENABLE_FILESYSTEM_TOOLS=true` (env var) | Write files to allowed directories. Requires `ha_mcp_tools` custom component. |
13+
| `ha_delete_file` | `enable_filesystem_tools` (dev add-on) / `HAMCP_ENABLE_FILESYSTEM_TOOLS=true` (env var) | Delete files from allowed directories. Requires `ha_mcp_tools` custom component. |
14+
| `ha_install_mcp_tools` | `enable_custom_component_integration` (dev add-on) / `HAMCP_ENABLE_CUSTOM_COMPONENT_INTEGRATION=true` (env var) | Installs the `ha_mcp_tools` custom component via HACS. |
1015

1116
## How to enable
1217

1318
### Option 1: Dev channel add-on (Home Assistant users)
1419

1520
1. Install the **Home Assistant MCP Server (Dev)** add-on. See [docs/dev-channel.md](dev-channel.md) for details.
1621
2. Open the add-on's **Configuration** tab.
17-
3. Enable the toggle (e.g., `enable_yaml_config_editing`).
18-
4. Restart the add-on.
22+
3. Enable "Show unused optional configuration options" to reveal beta toggles.
23+
4. Enable the desired toggle (e.g., `enable_yaml_config_editing`, `enable_filesystem_tools`).
24+
5. Restart the add-on.
1925

20-
The stable add-on does not expose beta toggles.
26+
`enable_yaml_config_editing`, `enable_filesystem_tools`, and `enable_custom_component_integration` are only available in the dev channel add-on. The stable add-on does not expose these beta toggles.
2127

2228
### Option 2: Environment variable (non-add-on installs)
2329

@@ -49,3 +55,15 @@ This tool edits `configuration.yaml` and package files directly, bypassing Home
4955
**Recommended prerequisites:**
5056
- Comfort with editing `configuration.yaml` via SSH or File Editor when things go wrong
5157
- Understanding that dedicated tools (`ha_config_set_helper`, `ha_config_set_automation`, `ha_config_set_script`, `ha_config_set_scene`, etc.) should be preferred for anything they support
58+
59+
### `ha_list_files`, `ha_read_file`, `ha_write_file`, `ha_delete_file`
60+
61+
These tools provide direct file access to your Home Assistant filesystem and require `HAMCP_ENABLE_FILESYSTEM_TOOLS=true` and the `ha_mcp_tools` custom component installed and active.
62+
63+
`HAMCP_ENABLE_CUSTOM_COMPONENT_INTEGRATION=true` is only needed if you want to allow the `ha_install_mcp_tools` installer tool; it is not required for the filesystem tools themselves.
64+
65+
**Access is restricted but sensitive.** Only `www/`, `themes/`, and `custom_templates/` are writable. `ha_read_file` additionally allows reading config YAML files, logs, and `custom_components/`. An AI assistant with these tools enabled has meaningful read access to your HA configuration.
66+
67+
**No undo.** `ha_delete_file` and `ha_write_file` (with `overwrite=True`) are irreversible. There is no recycle bin or automatic backup for file operations.
68+
69+
**Requires the custom component.** If `ha_mcp_tools` is not installed and active, all file tools will return an error with installation instructions.

homeassistant-addon-dev/DOCS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ The dev add-on uses the same configuration as the stable version. See the main a
1414
|--------|-------------|---------|
1515
| `backup_hint` | Backup strength preference | `normal` |
1616
| `secret_path` | Custom secret path (optional) | auto-generated |
17+
| `enable_yaml_config_editing` *(beta)* | Enables `ha_config_set_yaml` for editing `configuration.yaml` directly. Requires `ha_mcp_tools` custom component. | `false` |
18+
| `enable_filesystem_tools` *(beta)* | Enables file read/write tools (`ha_list_files`, `ha_read_file`, `ha_write_file`, `ha_delete_file`). Requires `ha_mcp_tools` custom component. | `false` |
19+
| `enable_custom_component_integration` *(beta)* | Enables `ha_install_mcp_tools` installer tool for the `ha_mcp_tools` custom component. | `false` |
20+
21+
Beta options are hidden under "Show unused optional configuration options" in the add-on Configuration tab. See [beta.md](https://github.com/homeassistant-ai/ha-mcp/blob/master/docs/beta.md) for details.
1722

1823
## Updates
1924

homeassistant-addon-dev/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ schema:
2828
enable_skills_as_tools: bool?
2929
enable_tool_search: bool?
3030
enable_yaml_config_editing: bool?
31+
enable_filesystem_tools: bool?
32+
enable_custom_component_integration: bool?
3133
ports:
3234
9583/tcp: 9583

homeassistant-addon-dev/translations/en.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,21 @@ configuration:
3838
require a full HA restart to take effect. See docs/beta.md for known
3939
limitations. Dedicated tools (automations, scripts, scenes, helpers,
4040
template sensors) should be preferred when available.
41+
enable_filesystem_tools:
42+
name: Enable filesystem tools (beta)
43+
description: >-
44+
Sets HAMCP_ENABLE_FILESYSTEM_TOOLS=true. Enables direct file read/write
45+
access to your Home Assistant filesystem. WARNING: This gives the MCP
46+
server sensitive direct file access to your system. Only enable if you
47+
trust the AI assistant with file operations. Requires restart to take
48+
effect.
49+
enable_custom_component_integration:
50+
name: Enable custom component integration (beta)
51+
description: >-
52+
Sets HAMCP_ENABLE_CUSTOM_COMPONENT_INTEGRATION=true. Enables the
53+
ha_install_mcp_tools installer tool, which can help install the
54+
ha_mcp_tools custom component. This setting does not control whether the
55+
MCP server loads or interacts with the custom component, and it is not
56+
required for filesystem tools to function. Only enable if you want to
57+
allow the AI assistant to use the installer tool. Requires restart to
58+
take effect.

homeassistant-addon/DOCS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,10 @@ The add-on provides 86+ MCP tools for controlling Home Assistant:
383383
- `ha_set_entity` — Update entity properties in the entity registry.
384384

385385
### Files
386-
- `ha_delete_file` — Delete a file from allowed directories in the Home Assistant config.
387-
- `ha_list_files` — List files in a directory within the Home Assistant config directory.
388-
- `ha_read_file` — Read a file from the Home Assistant config directory.
389-
- `ha_write_file` — Write a file to allowed directories in the Home Assistant config.
386+
- `ha_delete_file` **(beta)** — Delete a file from allowed directories in the Home Assistant config.
387+
- `ha_list_files` **(beta)** — List files in a directory within the Home Assistant config directory.
388+
- `ha_read_file` **(beta)** — Read a file from the Home Assistant config directory.
389+
- `ha_write_file` **(beta)** — Write a file to allowed directories in the Home Assistant config.
390390

391391
### Groups
392392
- `ha_config_list_groups` — List all Home Assistant entity groups with their member entities.

homeassistant-addon/config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ host_network: true
2121
# Use pre-built Docker images
2222
image: "ghcr.io/homeassistant-ai/ha-mcp-addon-{arch}"
2323
# Options for user configuration
24-
# NOTE: enable_yaml_config_editing is intentionally NOT exposed here.
25-
# It is a dev-channel-only beta feature — see docs/beta.md. Do not re-mirror
24+
# NOTE: enable_yaml_config_editing, enable_filesystem_tools, and
25+
# enable_custom_component_integration are intentionally NOT exposed here.
26+
# They are dev-channel-only beta features — see docs/beta.md. Do not re-mirror
2627
# from homeassistant-addon-dev/config.yaml without reading that doc first.
2728
options:
2829
backup_hint: "normal"

homeassistant-addon/start.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ def main() -> int:
190190
enable_skills_as_tools = True # default
191191
enable_tool_search = False # default
192192
enable_yaml_config_editing = False # default
193+
enable_filesystem_tools = False # default
194+
enable_custom_component_integration = False # default
193195
config_read_ok = True
194196

195197
if config_file.exists():
@@ -206,6 +208,10 @@ def main() -> int:
206208
enable_tool_search = raw_tool_search if isinstance(raw_tool_search, bool) else False
207209
raw_yaml_config = config.get("enable_yaml_config_editing", False)
208210
enable_yaml_config_editing = raw_yaml_config if isinstance(raw_yaml_config, bool) else False
211+
raw_filesystem_tools = config.get("enable_filesystem_tools", False)
212+
enable_filesystem_tools = raw_filesystem_tools if isinstance(raw_filesystem_tools, bool) else False
213+
raw_custom_component = config.get("enable_custom_component_integration", False)
214+
enable_custom_component_integration = raw_custom_component if isinstance(raw_custom_component, bool) else False
209215
except Exception as e:
210216
log_error(f"Failed to read config: {e}, using defaults")
211217
config_read_ok = False
@@ -231,6 +237,8 @@ def main() -> int:
231237
os.environ["ENABLE_SKILLS_AS_TOOLS"] = str(enable_skills_as_tools).lower()
232238
os.environ["ENABLE_TOOL_SEARCH"] = str(enable_tool_search).lower()
233239
os.environ["ENABLE_YAML_CONFIG_EDITING"] = str(enable_yaml_config_editing).lower()
240+
os.environ["HAMCP_ENABLE_FILESYSTEM_TOOLS"] = str(enable_filesystem_tools).lower()
241+
os.environ["HAMCP_ENABLE_CUSTOM_COMPONENT_INTEGRATION"] = str(enable_custom_component_integration).lower()
234242

235243
# Validate Supervisor token
236244
supervisor_token = os.environ.get("SUPERVISOR_TOKEN")

src/ha_mcp/tools/tools_filesystem.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(self, client: Any) -> None:
101101

102102
@tool(
103103
name="ha_list_files",
104-
tags={"Files"},
104+
tags={"Files", "beta"},
105105
annotations={
106106
"readOnlyHint": True,
107107
"title": "List Files",
@@ -195,7 +195,7 @@ async def ha_list_files(
195195

196196
@tool(
197197
name="ha_read_file",
198-
tags={"Files"},
198+
tags={"Files", "beta"},
199199
annotations={
200200
"readOnlyHint": True,
201201
"title": "Read File",
@@ -308,7 +308,7 @@ async def ha_read_file(
308308

309309
@tool(
310310
name="ha_write_file",
311-
tags={"Files"},
311+
tags={"Files", "beta"},
312312
annotations={
313313
"destructiveHint": True,
314314
"title": "Write File",
@@ -439,7 +439,7 @@ async def ha_write_file(
439439

440440
@tool(
441441
name="ha_delete_file",
442-
tags={"Files"},
442+
tags={"Files", "beta"},
443443
annotations={
444444
"destructiveHint": True,
445445
"title": "Delete File",

src/ha_mcp/tools/tools_mcp_component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def _handle_restart(result: dict[str, Any], restart_error: Exception) -> None:
163163

164164
@tool(
165165
name="ha_install_mcp_tools",
166-
tags={"Utilities"},
166+
tags={"Utilities", "beta"},
167167
annotations={
168168
"destructiveHint": True,
169169
"title": "Install MCP Tools Component"

0 commit comments

Comments
 (0)