Skip to main content
Glama
Vortitron

home-assistant-mcp

by Vortitron

Edit part of a config file in place

ha_edit_config_file
Destructive

Edit part of a Home Assistant config file by replacing exact text snippets, avoiding full file rewrites. Validates edits and restores the file if configuration breaks.

Instructions

Change part of a text file under the config directory: each edit replaces one exact piece of text with another, and must match exactly once. Prefer this to ha_write_config_file for any change to an existing file: resending a 70 KB file to change three lines is slow and risks a slip anywhere in it. Nothing is written unless every edit applies. Afterwards the configuration is checked and the file put back if the edit broke it, as with ha_write_config_file. Requires the ha:files scope.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile relative to the config root, e.g. 'automations.yaml'.
editsYesApplied in order, each to the result of the one before.
verifyNoCheck the configuration afterwards and restore the file if it fails (default true).
instance_idYesThe instance this edit is meant for (as listed by vomehome_list_instances). Required, and checked against the one this session is targeting; refused if they differ.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.10.0

TDQS

A4.5/5.0
Behavior5/5

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

Goes well beyond the destructiveHint=true / openWorldHint=true annotations: it discloses atomicity ('Nothing is written unless every edit applies'), automatic post-edit verification with restore-on-failure, the exact-match-once constraint, ordering semantics, and the required ha:files scope. These are the operationally decisive facts an agent needs before mutating a config file.

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?

Front-loaded with the core mechanic, then the sibling comparison, then atomicity, then verification, then scope — a logical order with no filler. It runs slightly long, and the 70 KB example is a flourish, but every sentence carries real information.

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

Completeness4/5

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

For a destructive, no-output-schema mutation tool, the description covers safety profile, atomicity, verification/rollback, scope requirements, and the alternative — nearly everything an agent needs. Minor gaps remain (e.g. behavior when an old_text fails to match uniquely or what the response/error looks like), but the essentials are present.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline of 3 applies. The description reinforces edit semantics ('replaces one exact piece of text with another, and must match exactly once') but largely restates what the schema's old_text/new_text descriptions already say, adding little parameter-level detail beyond the schema.

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 ('change part of a text file under the config directory') and immediately narrows scope to surgical, single-occurrence text replacement. It explicitly distinguishes itself from the closest sibling ha_write_config_file, so an agent can tell them apart without opening either 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?

Explicitly routes: 'Prefer this to ha_write_config_file for any change to an existing file', and gives the condition (editing an existing file) plus the reason (resending a 70 KB file is slow and error-prone). This is when-to-use guidance with a named alternative, not just an implied context.

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