Skip to main content
Glama
homeassistant-ai

Home Assistant MCP Server

Official

Get Logs

ha_get_logs
Read-onlyIdempotent

Retrieve Home Assistant logs from system, error_log, supervisor, or logbook sources to troubleshoot errors, trace exceptions, and diagnose integration issues.

Instructions

Get Home Assistant logs from various sources.

Prefer source='system' for triage: it returns HA's own deduplicated system_log entries with counts, first_occurred and the full exception traceback, and its counts run since each error first occurred. error_log with structured=True counts only what is inside the fetched window (reported as window_start/window_end; every install reads a capped window) and drops tracebacks, which structured=False gets back; use it for entries below system_log's WARNING+ ~50-entry cap, or for the per-component rollup. In structured mode limit/order do not apply: issues are ranked by count, then severity, then recency, over a fixed deep window.

Raw-text sources (error_log, supervisor, system_service) read a bounded window per call, so level/search filter and limit slice within that window only; window_lines reports the size requested. Logbook responses carry has_more plus a pagination_hint; error_log and fault_log carry has_more with a next_offset to pass back while it stays true.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
slugNosource='supervisor': app slug, e.g. 'core_mosquitto' (use ha_get_app() to list installed slugs). source='system_service': service name, one of supervisor, host, core, dns, audio, cli, multicast, observer — here 'supervisor' is the Supervisor service's own logs, not an app with that name.
levelNosystem / error_log only: keep only entries at exactly this level (ERROR, WARNING, INFO, DEBUG, CRITICAL); it is not a threshold.
limitNoMax entries/lines to return. Does not apply to source='error_log' with structured=True.
orderNoSort order for time-ordered sources (logbook, system, error_log, supervisor, system_service, fault_log): 'newest' returns most-recent first; 'oldest' returns chronological-first. For raw-text sources it sets the read direction of the most-recent window; fault_log orders whole crash blocks. Ignored for source='logger', and for source='error_log' with structured=True.newest
top_nNoMax distinct issues to return when structured=True (default 20, capped at 500).
offsetNoPage deeper into source='logbook', 'error_log' and 'fault_log' (ignored for other sources). On error_log it counts raw log lines back from the newest entry; on fault_log it counts lines from the start of the assembled crash text. Pass the response's 'next_offset' to continue while 'has_more' is true.
searchNoKeyword filter on entries/lines; matches the integration domain for source='logger'. In structured error_log mode it matches the message and logger name only; on the raw path the whole line.
sourceNo'logbook': entity state-change history. 'system': HA's structured system_log entries (errors, warnings). 'error_log': raw log text (home-assistant.log on container/pip installs; HA Core's journald stream on Supervisor-backed installs). 'supervisor': app (add-on) container logs (needs slug). 'system_service': Supervisor-managed system service logs (needs slug). 'logger': effective log level per integration (confirms ha_set_integration(log_level=...) changes took effect). 'fault_log': HA Core's faulthandler crash dump (home-assistant.log.fault), written only when HA dies from a native fatal signal, which never reaches journald or error_log; empty on a healthy install (crash_recorded=False); whole crash blocks are ordered with each block's lines kept in place; reads through the 'HA-MCP File & YAML Tools' entry.logbook
compactNologbook / system only: save context. Logbook strips attribute dicts; system keeps the start and end of each message string within 2000 characters (counted in 'truncated_messages'). search still matches the full message; text inside the cut is not shown. To read one message whole, pass False with a narrow search and limit=1.
end_timeNoLogbook only: end of the window (ISO datetime).
entity_idNoLogbook only: restrict to this entity.
hours_backNoLogbook only: how many hours back to read.
structuredNosource='error_log' only. When True, return a deduplicated, component-grouped summary of the log (counted issues sorted by frequency) instead of raw text. Ignored for other sources.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv8.7.0
    • changedInput schema / properties / compact / description
      Previous value: -"Logbook only: strip attribute dicts to save context."New value: +"logbook / system only: save context. Logbook strips attribute dicts; system keeps the start and end of each message string within 2000 characters (counted in 'truncated_messages'). search still matches the full message; text inside the cut is not shown. To read one message whole, pass False with a narrow search and limit=1."
  2. Changed12 schema fields changedv8.6.0
    • addedInput schema / properties / compact / description
      Added value: +"Logbook only: strip attribute dicts to save context."
    • addedInput schema / properties / end_time / description
      Added value: +"Logbook only: end of the window (ISO datetime)."
    • addedInput schema / properties / entity_id / description
      Added value: +"Logbook only: restrict to this entity."
    • addedInput schema / properties / hours_back / description
      Added value: +"Logbook only: how many hours back to read."
    • addedInput schema / properties / level / description
      Added value: +"system / error_log only: keep only entries at exactly this level (ERROR, WARNING, INFO, DEBUG, CRITICAL); it is not a threshold."
    • addedInput schema / properties / limit / description
      Added value: +"Max entries/lines to return. Does not apply to source='error_log' with structured=True."
    • changedInput schema / properties / order / description
      Previous value: -"Sort order for time-ordered sources (logbook, system, error_log, supervisor, system_service, fault_log): 'newest' (default) returns most-recent first; 'oldest' returns chronological-first. Ignored for source='logger', and for source='error_log' with structured=True (that summary is ranked by occurrence count, not by time)."New value: +"Sort order for time-ordered sources (logbook, system, error_log, supervisor, system_service, fault_log): 'newest' returns most-recent first; 'oldest' returns chronological-first. For raw-text sources it sets the read direction of the most-recent window; fault_log orders whole crash blocks. Ignored for source='logger', and for source='error_log' with structured=True."
    • addedInput schema / properties / search / description
      Added value: +"Keyword filter on entries/lines; matches the integration domain for source='logger'. In structured error_log mode it matches the message and logger name only; on the raw path the whole line."
    • addedInput schema / properties / slug / description
      Added value: +"source='supervisor': app slug, e.g. 'core_mosquitto' (use ha_get_app() to list installed slugs). source='system_service': service name, one of supervisor, host, core, dns, audio, cli, multicast, observer — here 'supervisor' is the Supervisor service's own logs, not an app with that name."
    • addedInput schema / properties / source / description
      Added value: +"'logbook': entity state-change history. 'system': HA's structured system_log entries (errors, warnings). 'error_log': raw log text (home-assistant.log on container/pip installs; HA Core's journald stream on Supervisor-backed installs). 'supervisor': app (add-on) container logs (needs slug). 'system_service': Supervisor-managed system service logs (needs slug). 'logger': effective log level per integration (confirms ha_set_integration(log_level=...) changes took effect). 'fault_log': HA Core's faulthandler crash dump (home-assistant.log.fault), written only when HA dies from a native fatal signal, which never reaches journald or error_log; empty on a healthy install (crash_recorded=False); whole crash blocks are ordered with each block's lines kept in place; reads through the 'HA-MCP File & YAML Tools' entry."
    • changedInput schema / properties / structured / description
      Previous value: -"source='error_log' only. When True, return a deduplicated, component-grouped summary of the log (counted issues sorted by frequency) instead of raw text. Use this on busy instances where the raw log is large enough to exhaust context. Ignored for other sources."New value: +"source='error_log' only. When True, return a deduplicated, component-grouped summary of the log (counted issues sorted by frequency) instead of raw text. Ignored for other sources."
    • changedInput schema / properties / top_n / description
      Previous value: -"Max distinct issues to return when structured=True (default 20, capped at 500). Bounds the response regardless of log size."New value: +"Max distinct issues to return when structured=True (default 20, capped at 500)."
  3. Changed3 schema fields changedv8.5.0
    • changedInput schema / properties / offset / description
      Previous value: -"Page deeper into source='logbook' and source='error_log' (ignored for other sources). On error_log it counts raw log lines back from the newest entry; pass the response's 'next_offset' to continue while 'has_more' is true."New value: +"Page deeper into source='logbook', 'error_log' and 'fault_log' (ignored for other sources). On error_log it counts raw log lines back from the newest entry; on fault_log it counts lines from the start of the assembled crash text. Pass the response's 'next_offset' to continue while 'has_more' is true."
    • changedInput schema / properties / order / description
      Previous value: -"Sort order for time-ordered sources (logbook, system, error_log, supervisor, system_service): 'newest' (default) returns most-recent first; 'oldest' returns chronological-first. Ignored for source='logger', and for source='error_log' with structured=True (that summary is ranked by occurrence count, not by time)."New value: +"Sort order for time-ordered sources (logbook, system, error_log, supervisor, system_service, fault_log): 'newest' (default) returns most-recent first; 'oldest' returns chronological-first. Ignored for source='logger', and for source='error_log' with structured=True (that summary is ranked by occurrence count, not by time)."
    • changedInput schema / properties / source / enum
      Previous value: -[
      -  "logbook",
      -  "system",
      -  "error_log",
      -  "supervisor",
      -  "system_service",
      -  "logger"
      -]New value: +[
      +  "logbook",
      +  "system",
      +  "error_log",
      +  "supervisor",
      +  "system_service",
      +  "logger",
      +  "fault_log"
      +]
  4. Changed1 schema field changedv8.4.1
    • addedInput schema / properties / offset / description
      Added value: +"Page deeper into source='logbook' and source='error_log' (ignored for other sources). On error_log it counts raw log lines back from the newest entry; pass the response's 'next_offset' to continue while 'has_more' is true."
  5. Changed3 schema fields changedv8.3.0
    • changedInput schema / properties / order / description
      Previous value: -"Sort order for time-ordered sources (logbook, system, error_log, supervisor, system_service): 'newest' (default) returns most-recent first; 'oldest' returns chronological-first. Ignored for source='logger'."New value: +"Sort order for time-ordered sources (logbook, system, error_log, supervisor, system_service): 'newest' (default) returns most-recent first; 'oldest' returns chronological-first. Ignored for source='logger', and for source='error_log' with structured=True (that summary is ranked by occurrence count, not by time)."
    • addedInput schema / properties / structured
      Added value: +{
      +  "default": false,
      +  "description": "source='error_log' only. When True, return a deduplicated, component-grouped summary of the log (counted issues sorted by frequency) instead of raw text. Use this on busy instances where the raw log is large enough to exhaust context. Ignored for other sources.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / top_n
      Added value: +{
      +  "anyOf": [
      +    {
      +      "minimum": 1,
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Max distinct issues to return when structured=True (default 20, capped at 500). Bounds the response regardless of log size."
      +}
  6. First observedv7.14.2

TDQS

A4.5/5.0
Behavior5/5

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

Annotations already cover safety (readOnly, idempotent, non-destructive), yet the description adds substantial behavioral detail: system_log counts run since each error first occurred while error_log counts only the fetched window, structured mode drops tracebacks, counts are ranked by frequency then severity then recency over a fixed deep window, and raw sources read a bounded window. This is well beyond what the annotations convey.

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?

Dense but front-loaded: the triage recommendation and the system-vs-error_log tradeoff lead, and the pagination/raw-window caveats follow. Every sentence carries operational information, though the middle paragraph is packed enough that an agent must parse carefully; slightly heavy for the value delivered.

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?

An output schema exists, so return values need not be described, and the description still supplies the pagination contract (has_more plus next_offset/pagination_hint), the compact-mode truncation caveat, and per-source edge cases like the fault_log empty-on-healthy-install behavior. Nothing needed to call any of the seven sources correctly 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 already 100%, so the baseline is 3, but the description adds cross-parameter semantics the schema cannot express on its own — notably 'In structured mode limit/order do not apply' and how search matches differ (message+logger name in structured mode vs whole line on the raw path). It also clarifies that level is an exact match, not a threshold, and that window_lines reports requested size.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Get Home Assistant logs') and then enumerates the seven distinct sources with precise semantics for each, so an agent knows exactly what data flows back. It does not, however, differentiate itself from sibling tools that overlap conceptually (e.g. ha_get_history for logbook-style state history, or ha_get_system_health), so it stops short of full sibling differentiation.

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?

The opening directly prescribes the default: 'Prefer source="system" for triage', then gives explicit when-to-use and when-not guidance ('use it for entries below system_log's WARNING+ ~50-entry cap, or for the per-component rollup'). It also routes between structured=True/structured=False and explains what each source is for, which is effectively explicit alternative-selection guidance.

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