Skip to main content
Glama

Get the most recent automation trace

automations_get_last_automation_trace
Read-onlyIdempotent

Retrieve the current trace for a Home Assistant automation in one call to debug failed or missing runs. Returns the run's step-by-step execution details without manual trace listing.

Instructions

Fetch the most recent trace for an automation in one call.

Calls trace/list for automation_id, then picks a run_id (the most recent overall, or with failed_only=True the most recent whose script_execution isn't 'finished') and calls trace/get for it.

Use when: debugging "why didn't this fire?" without first listing traces and picking a run_id by hand. Returns: dict with the full step-by-step trace for the picked run. Errors: returns {"error": "no_traces"|"no_failed_traces", "automation_id": aid} when no matching run exists. Limits: blocks for two sequential WebSocket round trips.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
failed_onlyNoIf True, pick the most recent run that did not finish cleanly instead of the most recent run overall. Defaults to False.
automation_idYesAutomation config id to fetch the latest trace for, bare or prefixed ('automation.<id>').

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.25.1
    • addedInput schema / properties / automation_id / description
      Added value: +"Automation config id to fetch the latest trace for, bare or prefixed ('automation.<id>')."
    • addedInput schema / properties / failed_only / description
      Added value: +"If True, pick the most recent run that did not finish cleanly instead of the most recent run overall. Defaults to False."
  2. Addedv0.18.1

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly/idempotent/non-destructive), yet the description adds substantive behavior: the internal trace/list → trace/get sequence, exact error payloads ({"error": "no_traces"|"no_failed_traces"}), and the latency cost (two sequential WebSocket round trips). That is well beyond what annotations provide.

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 / Returns / Errors / Limits) keep it front-loaded and scannable, and every line carries information. It is slightly verbose in restating the internal call flow, but nothing is wasted padding.

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?

With an output schema present the description needn't explain the trace payload, and it uses that space for errors, latency, and run-selection logic instead. An agent has everything needed to call it correctly and interpret failures.

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 goes further by explaining the selection semantics of failed_only ('most recent whose script_execution isn't finished'), which sharpens an otherwise terse boolean flag.

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+resource ('fetch the most recent trace for an automation in one call') and immediately distinguishes itself from the sibling pair list_automation_traces/get_automation_trace by describing the two-step composition it collapses into one call.

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

Usage Guidelines4/5

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

Gives explicit when-to-use ('debugging "why didn't this fire?" without first listing traces and picking a run_id by hand'), which implicitly routes the agent away from the two-step workflow. It stops short of naming the sibling tools as alternatives, but the trigger condition is clear and specific.

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