Skip to main content
Glama
homeassistant-ai

Home Assistant MCP Server

Official

Get Logs

ha_get_logs
Read-onlyIdempotent

Retrieve Home Assistant logs from multiple sources (logbook, system, error log, supervisor) to diagnose errors, warnings, and crashes.

Instructions

Get Home Assistant logs from various sources.

Sources:

  • "logbook" (default): Entity state change history with pagination

  • "system": Structured system log entries (errors, warnings) via system_log/list

  • "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 (requires slug = app slug)

  • "system_service": HA-Supervisor-managed system service logs (requires slug ∈ {supervisor, host, core, dns, audio, cli, multicast, observer})

  • "logger": Effective log level per integration via logger/log_info (confirms logger.set_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 (segfault, abort, Python fatal error), which never reaches journald or error_log. Empty on a healthy install (crash_recorded=False). Whole crash blocks are ordered (newest first by default) with each block's lines kept in place so the traceback reads correctly; search keeps every block that mentions the term; offset/limit page through the assembled text. Reads through the "HA-MCP File & YAML Tools" entry (component >= 2.2.0).

Prefer source='system' for triage. It returns HA's own deduplicated system_log entries with counts, first_occurred and full tracebacks; of those only the tracebacks are unrecoverable from the structured error_log summary — they are present in the raw text, so structured=False gets them back. Its counts also run since each error first occurred, while structured error_log counts only what is inside the fetched window (reported as window_start/window_end; every install now reads a capped window). Use error_log with structured=True for entries below system_log's WARNING+ ~50-entry cap, or for the per-component rollup.

Shared params: limit, search (keyword filter on entries/lines; matches integration domain for source='logger') Order: order='newest' (default) returns most-recent first; order='oldest' returns chronological-first. Applies to all time-ordered sources (logbook, system, error_log, supervisor, system_service, fault_log); ignored for source='logger' and for error_log with structured=True. For raw-text sources (error_log, supervisor, system_service) it sets the read direction of the most-recent window; fault_log orders whole crash blocks instead of lines. Logbook params: hours_back, entity_id, end_time, compact (default True — strips attribute dicts to save context) Pagination (logbook + error_log + fault_log): offset pages deeper; ignored for the other sources. fault_log always reads a fixed window from the end of the file, orders its crash blocks, and pages the assembled text from the start with has_more/next_offset. Logbook responses carry has_more plus a pagination_hint. On error_log, offset counts raw log lines back from the newest entry (journald entries on Supervisor-backed installs), both modes read a bounded window per call — so level/search filter and limit slice within that window only, and window_lines reports the size actually requested — and the response carries has_more with a next_offset to pass back while it stays true. System/error_log params: level (ERROR, WARNING, INFO, DEBUG, CRITICAL) error_log params: structured, top_n. In structured mode search matches the message and logger name only, whereas on the raw path it matches the whole line; limit/order do not apply, issues are ranked by count, then severity, then recency, and the summary covers a fixed deep window rather than the caller's limit. Supervisor params: slug = app slug, e.g. "core_mosquitto" (use ha_get_app() to list installed slugs) System-service params: slug = service name. The slug "supervisor" here means the Supervisor service's own logs, NOT an app with that name — the source param disambiguates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
slugNo
levelNo
limitNo
orderNoSort 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).newest
top_nNoMax distinct issues to return when structured=True (default 20, capped at 500). Bounds the response regardless of log size.
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.
searchNo
sourceNologbook
compactNo
end_timeNo
entity_idNo
hours_backNo
structuredNosource='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.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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"
      +]
  2. 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."
  3. 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."
      +}
  4. First observedv7.14.2

TDQS

A4.3/5.0
Behavior4/5

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

Annotations declare readOnlyHint=true and idempotentHint=true, and the description does not contradict these. Beyond annotations, the description discloses significant behavioral details: pagination behavior (has_more, next_offset), the bounded window for error_log, how fault_log orders crash blocks, and when parameters are ignored. These go beyond the schema and help the agent understand side effects and edge cases. The only minor gap is lack of explicit mention of rate limits or error conditions, but that's not critical for a read-only tool.

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?

The description is long (over 300 words) but densely packed with critical information. It is well-structured with bold section headings for sources, shared params, order, logbook params, pagination, and source-specific params. It front-loads the key advice to prefer system source. While verbose, every sentence adds value, though it could be slightly condensed without losing meaning, so a 4.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (13 parameters, 7 sources, pagination, different modes) and that an output schema exists (which may describe return format), the description is remarkably thorough. It covers behavior for each source, parameter applicability, pagination, and even edge cases like fault_log. However, it could be more complete by explicitly stating the return shape for each source or mentioning potential error conditions (e.g., invalid slug). The presence of an output schema mitigates some of this, so a 4.

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

Parameters3/5

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

Schema description coverage is 31%, so the description must compensate for undocumented parameters. It does so for many: it explains 'limit' and 'search' as shared params, details 'order' semantics for each source, explains 'offset' for pagination, and describes source-specific params like 'structured' and 'top_n'. However, some parameters like 'entity_id', 'end_time', and 'hours_back' are only mentioned implicitly under logbook params without detailed syntax or examples. The description adds significant value over the schema but leaves a few parameters thinly described, so a 3 is appropriate.

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 the tool's purpose: retrieving Home Assistant logs from various named sources (logbook, system, error_log, etc.), each with specific details. It clearly differentiates from siblings like ha_get_history or ha_search by focusing on logs with source-specific behaviors. The verb 'Get' and resource 'logs' are specific, and the enumeration of sources provides a clear scope.

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 description provides explicit guidance on when to use which source: for triage it says 'Prefer source='system'', and explains why (deduplicated entries, counts, tracebacks) and when to use error_log (for entries below WARNING cap, or per-component rollup). It also disambiguates similar sources, e.g., 'system_service' slug 'supervisor' means Supervisor service logs, not an app, clarifying potential confusion. This is exemplary usage 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