Skip to main content
Glama

Restore a config file from git history

git_git_rollback_file
DestructiveIdempotent

Restore a single file to its state at a specific commit to undo accidental edits. Requires confirmation; only affects that file, not the entire config tree.

Instructions

Restore one file to its state at a specific commit.

Refuses a relative_path that resolves outside /config (_resolve_within_config) before running anything, and without confirm=True returns a safety prompt instead of touching the file; with confirm=True it calls repo.git.checkout(sha, '--', relative_path), replacing the file's on-disk content with the version from sha and losing any uncommitted changes to that file.

Use when: undoing an accidental edit to a single file. Not for: resetting the whole config tree — use git_git_rollback_to_commit. Returns: dict {"status": "restored", "file", "to"} on success. Errors: returns {"error": "invalid_path"|"path_outside_config", ...} when relative_path escapes /config; returns {"error": "confirmation_required", ...} when confirm is not True; raises RuntimeError (from _repo()) when no git repo exists. Limits: requires confirm=True; uncommitted changes to the target file are permanently lost once it runs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
shaNoCommit SHA or ref to restore the file from. Defaults to 'HEAD', which discards uncommitted changes to this file.HEAD
confirmNoMust be True to actually restore the file. False (default) returns a safety prompt describing what would happen instead of touching anything.
relative_pathYesPath to the file relative to the HA config directory to restore, e.g. 'automations.yaml'. Must resolve inside /config after following symlinks.

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 / confirm / description
      Added value: +"Must be True to actually restore the file. False (default) returns a safety prompt describing what would happen instead of touching anything."
    • addedInput schema / properties / relative_path / description
      Added value: +"Path to the file relative to the HA config directory to restore, e.g. 'automations.yaml'. Must resolve inside /config after following symlinks."
    • addedInput schema / properties / sha / description
      Added value: +"Commit SHA or ref to restore the file from. Defaults to 'HEAD', which discards uncommitted changes to this file."
  2. Changed1 schema field changedv0.18.1
    • addedInput schema / properties / confirm
      Added value: +{
      +  "default": false,
      +  "type": "boolean"
      +}
  3. First observedv0.3.0

TDQS

A4.8/5.0
Behavior5/5

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

While annotations already declare destructive/idempotent/not-read-only, the description adds substantive context beyond them: the confirm=True gate and safety-prompt default, permanent loss of uncommitted changes, the path-escape refusal, the returned error dicts, and the RuntimeError when no repo exists. This is a genuinely informative disclosure of side effects and failure modes.

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 purpose, then cleanly sectioned into Use when / Not for / Returns / Errors / Limits. Slightly long due to internal implementation names (_resolve_within_config, repo.git.checkout), but each block earns its place and no sentence is pure filler.

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 3-param destructive mutation tool with an output schema, the definition covers scope, safety gating, error surface, and limits. Since the return shape is documented by the schema, no gaps remain that an agent would need to call it correctly.

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 baseline is 3, but the description adds meaning beyond the schema by spelling out that confirm=False returns a prompt rather than touching the file and that the default sha=HEAD discards uncommitted changes to that file. It reinforces rather than merely restates the parameter docs.

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?

The opening sentence gives a precise verb+resource+scope: 'Restore one file to its state at a specific commit.' It explicitly names the sibling it is not (git_git_rollback_to_commit) for whole-tree resets, so an agent can disambiguate 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?

Explicit 'Use when: undoing an accidental edit to a single file' and 'Not for: resetting the whole config tree — use git_git_rollback_to_commit.' Both the positive trigger and the excluded case with the named alternative are present, leaving nothing 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