Skip to main content
Glama
homeassistant-ai

Home Assistant MCP Server

Official

Get Automation Traces

ha_get_automation_traces
Read-onlyIdempotent

Debug automations and scripts by retrieving their execution traces, including trigger info, condition results, action steps, and errors.

Instructions

Retrieve execution traces for automations and scripts to debug issues.

Traces show what happened during automation/script runs:

  • What triggered the automation

  • Which conditions passed or failed

  • What actions were executed

  • Any errors that occurred

  • Variable values during execution

USAGE MODES:

  1. List recent traces (omit run_id): ha_get_automation_traces("automation.motion_light") Returns a summary of recent execution runs with timestamps, triggers, and status. Use offset to page deeper when has_more is true, or order="oldest" to start from the earliest stored trace instead of the most recent.

  2. Get detailed trace (provide run_id): ha_get_automation_traces("automation.motion_light", run_id="1705312800.123456") Returns full execution details including trigger info, condition results, action trace with timing, and context variables.

  3. Get detailed trace with logbook (provide run_id and detailed=True): ha_get_automation_traces("automation.motion_light", run_id="1705312800.123456", detailed=True) Returns the formatted trace plus logbook entries and context metadata. Useful when the standard trace summary doesn't reveal enough for debugging. Note: script-style action paths (sequence/, numeric) are always matched regardless of this flag.

  4. Get full variables without deduplication (provide run_id and deduplicate=False): ha_get_automation_traces("automation.motion_light", run_id="1705312800.123456", deduplicate=False) Returns the formatted trace with full variables at every action step.

DEBUGGING EXAMPLES:

Automation not triggering:

  • Check if traces exist (automation may not be triggered)

  • Look at trigger info to see what event was received

Automation runs but conditions fail:

  • Get detailed trace to see condition_results

  • Each condition shows whether it passed (true) or failed (false)

Unexpected behavior in actions:

  • Get detailed trace to see action_trace

  • Shows each action step with result and any errors

  • For 'choose' actions, shows which branch was taken

Template debugging:

  • Detailed trace shows evaluated template values in context

  • Trigger variables available under trigger_variables

NOTES:

  • Traces are stored for a limited time by Home Assistant

  • Works for both automations and scripts (use full entity_id)

  • The 'state' field shows: 'stopped' (completed), 'running', or error state

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of traces to return when listing (default: 10, max: 50).
orderNoOrder traces are returned in. 'newest' (default) returns most-recent first; 'oldest' returns chronological-first.newest
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. Omit to list recent traces.
detailedNoInclude extra diagnostic data: logbook entries and context metadata (default: False). Use when standard trace lacks detail for debugging.
sectionsNoComma-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'.
deduplicateNoDeduplicate variables across action steps (default: True). Set to False to include full variables at every step.
automation_idYesAutomation or script entity_id (e.g., 'automation.motion_light' or 'script.morning_routine')

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

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

The description goes far beyond annotations (readOnlyHint, idempotentHint) by explaining trace storage limits, behavior of pagination, effect of parameters like detailed and deduplicate, and expected state field values. This fully discloses behavioral traits.

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

Conciseness5/5

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

The description is well-organized with clear headings (USAGE MODES, DEBUGGING EXAMPLES, NOTES), front-loaded purpose, and no redundant text. Every sentence adds value, making it easy to scan and understand quickly.

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?

Given the tool's complexity (8 parameters, automation debugging), the description covers all usage modes, parameter behavior, debugging scenarios, and limitations. An output schema exists, so return values are handled; the description is fully self-contained.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema by demonstrating parameter usage in concrete examples (e.g., omitting run_id for listing, providing it for details, using detailed=True for extra diagnostics). Schema coverage is 100%, but the description enriches each parameter's role.

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 description clearly states it retrieves execution traces for automations and scripts to debug issues, detailing what traces show (triggers, conditions, actions, errors, variables). It is unambiguous and distinct from sibling tools, which focus on logs, history, or other operations.

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?

The description provides extensive usage modes and debugging examples, guiding when to use each mode (list vs. detailed vs. logbook). However, it does not explicitly state when not to use this tool or mention alternatives, missing the full 'when-not' guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/homeassistant-ai/ha-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server