Skip to main content
Glama

Overwrite a config file

files_write_config_file
DestructiveIdempotent

Write or overwrite a file under Home Assistant's /config, validating YAML and creating parent directories; no backup or reload.

Instructions

Overwrite or create one config file under /config with new content.

Resolves relative_path via _safe_path, YAML-checks content first unless validate_yaml=False or the extension isn't .yaml/.yml, then creates parent directories as needed and writes the file, replacing any previous content at that path.

Use when: no rollback point for the previous content is needed. Not for: keeping a rollback point — use git_safe_write_with_checkpoint, which commits the pre-write state first; ESPHome device YAML — use esphome_write_config. Returns: dict {"success": True, "path": ...} on success, or {"success": False, "error": ...} when validate_yaml catches invalid YAML before writing. Errors: raises PermissionError (from _safe_path) for a path outside the config directory, a disallowed extension, or secrets.yaml/.storage; returns {"success": False, "error": ...} instead of raising for invalid YAML. Limits: no backup is taken — the previous content is permanently lost. Does not reload Home Assistant.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesFull text to write as the file's new content, replacing whatever was there before.
relative_pathYesPath to the file relative to the HA config directory (HA_CONFIG_PATH), e.g. 'automations.yaml' or 'packages/lights.yaml'. Parent directories are created if missing. Must use an allowed extension (.yaml/.yml/.json/.txt) and not touch secrets.yaml or .storage/.
validate_yamlNoIf True (default) and the extension is .yaml/.yml, `content` is parsed with a HA-tolerant YAML loader before writing; a parse error aborts the write. Set False to skip that check for non-YAML or intentionally unusual content.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.25.1
    • addedInput schema / properties / content / description
      Added value: +"Full text to write as the file's new content, replacing whatever was there before."
    • addedInput schema / properties / relative_path / description
      Added value: +"Path to the file relative to the HA config directory (HA_CONFIG_PATH), e.g. 'automations.yaml' or 'packages/lights.yaml'. Parent directories are created if missing. Must use an allowed extension (.yaml/.yml/.json/.txt) and not touch secrets.yaml or .storage/."
    • addedInput schema / properties / validate_yaml / description
      Added value: +"If True (default) and the extension is .yaml/.yml, `content` is parsed with a HA-tolerant YAML loader before writing; a parse error aborts the write. Set False to skip that check for non-YAML or intentionally unusual content."
  2. First observedv0.3.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations declare destructive/idempotent/not-readOnly, and the description adds substantial context beyond them: no backup means previous content is permanently lost, parent dirs are created, YAML validation aborts the write, PermissionError is raised for out-of-scope paths/extensions/secrets.yaml/.storage, and HA is not reloaded. This is exactly the mutation-risk information an agent needs.

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 action, then organized into labeled sections (Resolves/Use when/Not for/Returns/Errors/Limits) that each carry distinct information. Slightly dense, but every line earns its place without wasteful repetition of the schema.

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?

For a destructive single-file write with a full output schema and rich annotations, the description covers the remaining gaps an agent needs: failure modes, exception vs. return-dict behavior, side effects (no reload, no backup), and alternative routing.

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 schema already fully documents relative_path, content, and validate_yaml. The description reinforces the validate_yaml extension-condition flow but adds no syntax or format detail beyond what the structured schema provides; baseline 3 applies.

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 (overwrite/create) and resource (one config file under /config), and explicitly names the siblings it must not be confused with (`git_safe_write_with_checkpoint`, `esphome_write_config`). An agent can select this over alternatives without opening the 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?

Provides explicit 'Use when' and 'Not for' sections, each routing to a named alternative with the selecting condition (no rollback needed vs. keeping a rollback point; ESPHome YAML handled elsewhere). Nothing is left to inference.

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