Skip to main content
Glama
Vortitron

home-assistant-mcp

by Vortitron

Write a config file

ha_write_config_file
Destructive

Write a file in Home Assistant's config directory, replacing its contents, with automatic validation and rollback if the configuration check fails.

Instructions

Write a file under Home Assistant's config directory. Defaults to UTF-8 text; pass encoding='base64' to write a binary file (an icon, a data file a custom integration ships) — content is then the base64 of the bytes, not the bytes themselves.

This edit is checked and reversible. After the write, Home Assistant's own configuration check runs, and if it fails the previous contents are put straight back — a bad edit cannot leave Home Assistant unable to start. The result says whether it was verified and whether it was rolled back. Editing configuration.yaml this way is the normal, supported route for a home the user has authorised; it is how a hosted install is configured at all, since there is no SSH into one. (check_config only ever validates YAML, so it says nothing about a binary write; verify defaults to off for encoding='base64' for that reason.)

It replaces the entire file — read it first with ha_read_config_file and send back the full content with your change applied, or you will delete everything else in it.

Pass verify=false when writing several files that are only valid together, then call ha_check_config yourself at the end.

A successful write does not apply the change: restart Home Assistant, or reload the relevant domain, for it to take effect.

Requires the ha:files scope. Prefer a purpose-built tool where one exists: helpers via ha_set_helper and automations via ha_set_automation both apply immediately and cannot break startup.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile relative to the config root, e.g. 'configuration.yaml'.
verifyNoCheck the configuration afterwards and restore the file if it fails. Default true for utf8, false for base64 (check_config can't validate binary content).
contentYesThe complete new contents of the file (base64 if encoding='base64').
encodingNo'utf8' (default) for text; 'base64' for binary content.
instance_idYesThe instance this write is meant for (as listed by vomehome_list_instances). Required, and checked against the one this session is actually targeting: if they differ the write is refused rather than applied to the wrong home.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.10.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already flag destructive/openWorld, but the description adds the crucial behaviors: HA's config check runs after the write and restores prior contents on failure, the result reports verified/rolled-back status, the write replaces the entire file, changes require a restart or reload, and the ha:files scope is required. These are exactly the operational traits an agent needs for a destructive write and are not derivable from the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Multi-paragraph but front-loaded, with the highest-risk facts (checked-and-reversible, whole-file replacement) emphasized and bolded. Slightly redundant with the schema on the verify default, but that repetition is defensible for a destructive tool where a mistake is costly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, and the description compensates by stating what the result reports (verified vs rolled back). It also covers scope requirements, restart semantics, binary vs text handling, and preferred alternatives, so nothing an agent needs to call this correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description meaningfully augments it: it clarifies that with encoding='base64' the content is the base64 of the bytes rather than the bytes, and explains why verify defaults off for base64 (check_config only validates YAML). The instance_id cross-check against the session's target is also described in more operational terms than the schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource (write a file under Home Assistant's config directory) and immediately distinguishes itself from siblings by naming ha_read_config_file, ha_check_config, ha_set_helper, and ha_set_automation. An agent can tell it apart from ha_edit_config_file and ha_delete_config_file without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit when-to-use and when-not-to-use guidance: prefer purpose-built tools (ha_set_helper, ha_set_automation) where one exists, read first with ha_read_config_file before replacing the whole file, pass verify=false only when writing interdependent files and then call ha_check_config yourself. Alternatives and their reasons are named.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools