Skip to main content
Glama

Restore a config file from git history

git_rollback_file
DestructiveIdempotent

Restore a single file to its state at a specific commit to undo an accidental edit, with a confirmation step before overwriting uncommitted changes.

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_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.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "relative_path": "<relative_path>"
    },
    "name": "git_rollback_file"
  }
}

Input 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

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.1

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already disclose destructiveHint=true and idempotentHint=true, but the description goes well past them: it names the path-containment guard, the confirm=True gate that returns a safety prompt rather than acting, the exact underlying checkout call, the irreversible loss of uncommitted changes, and the specific error payloads including the RuntimeError from _repo(). This is unusually complete disclosure of what gets destroyed and what preconditions must hold.

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?

Labeled sections (Use when / Not for / Returns / Errors / Limits) make it skimmable and the core action is front-loaded in the first sentence. Minor redundancy: the confirm requirement and the loss of uncommitted changes each appear twice across the prose and the Limits line.

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, gated mutation that can raise rather than return, every decision point an agent needs is covered: preconditions, confirmation, side effects, success shape, and the full error surface. An output schema exists, yet the description still enumerates the meaningful error variants, which is the right call for branching behavior.

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; the description earns an extra point by explaining the consequence of the sha default ('HEAD' discards uncommitted changes) and the semantics of the confirm gate in behavior terms, not just type terms. It does not add new syntax detail, which the schema already carries.

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?

Opens with a precise verb+resource+scope: 'Restore one file to its state at a specific commit.' The single-file scope is stated explicitly, and the sibling that handles the broader case (git_rollback_to_commit) is named, so an agent can discriminate 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?

Contains an explicit 'Use when: undoing an accidental edit to a single file' and an explicit exclusion routing to git_rollback_to_commit for whole-tree resets. When-to-use, when-not-to-use, and the alternative are all present.

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