Skip to main content
Glama
Home Assistant MCP Server

Home Assistant MCP Server

Official

Get Automation Traces

ha_get_automation_traces
Read-onlyIdempotent

Retrieves Home Assistant automation and script execution traces to debug triggers, condition failures, executed actions, errors, and variables; list recent runs or inspect a run by ID or context.

Instructions

Get execution traces for automations and scripts to debug issues.

Traces show what triggered a run, which conditions passed or failed, which actions executed, any errors, and variable values during execution. Home Assistant keeps only the most recent runs of each automation or script (its stored_traces setting), so older runs are not available.

Do not use this tool for general log history or recorder statistics; use ha_get_logs for logs and ha_get_history for history/statistics.

USAGE MODES:

  1. List recent traces (omit run_id and context_id). ha_get_automation_traces("automation.motion_light") ha_get_automation_traces(domain="automation")

  2. Get a detailed trace (provide run_id): returns Core's extended trace dict unchanged, including config, raw step trace, context, errors and variables. Pass sections to keep only named top-level keys (plus 'logbook' for the run's logbook); a requested name the run lacks is reported in warnings and the run's own keys are listed. An empty sections string means omitted. ha_get_automation_traces("automation.motion_light", run_id="1705312800.123456") ha_get_automation_traces(domain="automation", item_id="uid", run_id="...")

  3. Resolve a trace by context (provide context_id): the response selects Core's run for that context and reports context_match as trace or parent. With the ha_mcp_tools component, context_other_matches lists the other runs that matched the context id (own or triggering parent); Core's own trace/contexts keeps one run per context id. A context Core does not hold is reported as not found with a hint that the component resolves triggering (parent) contexts. ha_get_automation_traces(context_id="01J...")

RESPONSE FIELDS:

  • A detail response is Core's extended trace/get dict: config, trace, context, timestamp, state, error, script_execution, blueprint_inputs and any run-specific fields.

  • success, run_id, domain and item_id identify the run. entity_id is present when the caller supplied it; a context-only lookup returns Core's domain/item_id instead of inventing one.

  • context_match is trace or parent; context_scanned reports how many stored runs the ha_mcp_tools component inspected while resolving the context id, and is 0 when Core's own-context map answered.

  • logbook_entries, logbook_transport, logbook_total and logbook_truncated describe the run's logbook rows.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "ha_get_automation_traces"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum number of traces to return when listing (default: 10, max: 50).
orderNoOrder traces are returned in. 'newest' returns most-recent first; 'oldest' returns chronological-first.newest
domainNoList recent traces across every automation or script when entity_id is omitted. Required with item_id.
offsetNoNumber of traces to skip from the start of the requested order. Use with `limit` to page through stored traces when `total_available > limit`.
run_idNoSpecific trace run_id to retrieve detailed trace.
item_idNoCore's trace item id from a list row or context resolution. Use with domain and run_id when no entity_id is available.
detailedNoInclude the run's logbook entries in the detail response.
sectionsNoComma-separated top-level keys from Core's extended trace dict to return, plus 'logbook' for the run's logbook. Available keys depend on the run; examples: 'trace', 'config', 'context', 'error', 'logbook'. A requested name this run lacks is reported in 'warnings'. Omit, or pass an empty string, to return Core's full extended dict.
entity_idNoAutomation or script entity_id. Omit when resolving a context-only lookup.
context_idNoContext id to resolve to its trace. Accepts the trace run's own `context.id` or, with the ha_mcp_tools component, the context id of the event or service call that triggered it. Mutually exclusive with run_id.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed9 schema fields changedv9.2.0
    • removedInput schema / properties / automation_id
      Removed value: -{
      -  "description": "Automation or script entity_id (e.g., 'automation.motion_light' or 'script.morning_routine')",
      -  "type": "string"
      -}
    • addedInput schema / properties / context_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Context id to resolve to its trace. Accepts the trace run's own `context.id` or, with the ha_mcp_tools component, the context id of the event or service call that triggered it. Mutually exclusive with run_id."
      +}
    • removedInput schema / properties / deduplicate
      Removed value: -{
      -  "default": true,
      -  "description": "Deduplicate variables across action steps. Set to False to record the variables at every step; steps whose variables carry 'trigger', and null-valued entries, are omitted either way.",
      -  "type": "boolean"
      -}
    • changedInput schema / properties / detailed / description
      Previous value: -"Include extra diagnostic data: logbook entries and context metadata."New value: +"Include the run's logbook entries in the detail response."
    • addedInput schema / properties / domain
      Added value: +{
      +  "anyOf": [
      +    {
      +      "enum": [
      +        "automation",
      +        "script"
      +      ],
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "List recent traces across every automation or script when entity_id is omitted. Required with item_id."
      +}
    • addedInput schema / properties / entity_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Automation or script entity_id. Omit when resolving a context-only lookup."
      +}
    • addedInput schema / properties / item_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Core's trace item id from a list row or context resolution. Use with domain and run_id when no entity_id is available."
      +}
    • changedInput schema / properties / sections / description
      Previous value: -"Comma-separated list of trace sections to return. Valid values: trigger, conditions, actions, config, error, logbook, context. Omit to return all sections. Example: 'actions' or 'trigger,conditions'."New value: +"Comma-separated top-level keys from Core's extended trace dict to return, plus 'logbook' for the run's logbook. Available keys depend on the run; examples: 'trace', 'config', 'context', 'error', 'logbook'. A requested name this run lacks is reported in 'warnings'. Omit, or pass an empty string, to return Core's full extended dict."
    • removedInput schema / required
      Removed value: -[
      -  "automation_id"
      -]
  2. Changed4 schema fields changedv8.6.0
    • changedInput schema / properties / deduplicate / description
      Previous value: -"Deduplicate variables across action steps (default: True). Set to False to include full variables at every step."New value: +"Deduplicate variables across action steps. Set to False to record the variables at every step; steps whose variables carry 'trigger', and null-valued entries, are omitted either way."
    • changedInput schema / properties / detailed / description
      Previous value: -"Include extra diagnostic data: logbook entries and context metadata (default: False). Use when standard trace lacks detail for debugging."New value: +"Include extra diagnostic data: logbook entries and context metadata."
    • changedInput schema / properties / order / description
      Previous value: -"Order traces are returned in. 'newest' (default) returns most-recent first; 'oldest' returns chronological-first."New value: +"Order traces are returned in. 'newest' returns most-recent first; 'oldest' returns chronological-first."
    • changedInput schema / properties / run_id / description
      Previous value: -"Specific trace run_id to retrieve detailed trace. Omit to list recent traces."New value: +"Specific trace run_id to retrieve detailed trace."
  3. First observedv7.14.2

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare readOnly/idempotent/non-destructive, and the description still adds real behavioral context: retention is capped by Home Assistant's stored_traces so older runs do not exist, `sections` reports missing keys via `warnings`, and context resolution reports `context_match` as `trace` or `parent` or not-found with a hint. These are constraints an agent cannot infer from the annotations or schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Heading-based structure (usage modes, response fields) is front-loaded and scannable, but the RESPONSE FIELDS block is long and largely restates what the output schema already provides. Some behavioral notes (warnings, context_match, logbook fields) earn their place; the enumeration of `config`, `trace`, `context`, `timestamp`, `state` etc. is filler against an existing output 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 10-parameter tool spanning list, detail, and context-resolution behaviors, the description covers invocation paths, retention limits, and the meaning of non-obvious response signals. Nothing an agent needs in order to call it correctly or interpret the result is missing.

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 goes beyond it by showing how parameters combine in practice (domain-only listing, entity_id + run_id, domain + item_id + run_id, context_id alone). It does not restate the limit/order/offset paging semantics, which correctly remain in 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?

The opening sentence gives a specific verb and resource (execution traces for automations and scripts) plus the intent (debugging). It immediately distinguishes the tool from ha_get_logs and ha_get_history by name, so an agent can route 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?

Explicit negative guidance ('Do not use this tool for general log history or recorder statistics') names the two sibling alternatives for those cases. Three numbered usage modes with concrete call examples cover the list, detail, and context-resolution paths, which is as actionable as guidance gets for a 10-parameter tool.

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