Skip to main content
Glama
Home Assistant MCP Server

Home Assistant MCP Server

Official

Get Logs

ha_get_logs
Read-onlyIdempotent

Fetch and filter Home Assistant logs from multiple sources, including structured issue summaries and pagination, to diagnose errors and service problems.

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; structured=False returns the raw records instead, so it covers what falls outside system_log's WARNING+ in-memory buffer. Use structured=True 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.

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_logs"
  }
}

Input 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, multicast — 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. For source='error_log' it matches the record's header only, so matching text in a traceback frame does not satisfy it.
limitNoMax entries/lines to return. For source='error_log' with structured=False it bounds returned lines: whole records are selected within it, and a record longer than it is cut (header and last lines kept) with a warning naming how many lines were cut. 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; error_log orders whole records and keeps each record's lines in place. 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, or is the opaque token a previous page returned in 'next_offset' on Supervisor/journald installs, which keeps paging exact while new log lines arrive (`structured=True` accepts and returns that token too); 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. For source='system' it matches message, name and exception text; for the raw error_log path it matches any line of a record, so a traceback frame brings back its header and siblings. Structured error_log mode matches message and logger name only; source='logger' matches the integration domain.
sourceNo'logbook': entity state-change history. 'system': HA's structured system_log entries (errors, warnings) with full exception tracebacks; search also matches those exceptions. 'error_log': raw log text (home-assistant.log on container/pip installs; HA Core's journald stream on Supervisor-backed installs), grouped into records: a header line starts one and every following line that is not itself a header joins it — traceback frames, the blank lines around chained exceptions, and non-HA banners such as s6-overlay restart lines. '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).
device_idNoLogbook only: native Core device filter - events attributed to this device and the context chains they caused. State changes of the device's entities are not included; filter by entity_id for those. Requires the WebSocket path.
entity_idNoLogbook only: restrict to one entity, or a comma-separated list of entity IDs.
context_idNoLogbook only: only events sharing this context - 'what caused this'. Cannot be combined with entity_id or device_id; works on both transports when used alone.
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

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed13 schema fields changedv9.0.0
    • addedInput schema / properties / context_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Logbook only: only events sharing this context - 'what caused this'. Cannot be combined with entity_id or device_id; works on both transports when used alone."
      +}
    • addedInput schema / properties / device_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Logbook only: native Core device filter - events attributed to this device and the context chains they caused. State changes of the device's entities are not included; filter by entity_id for those. Requires the WebSocket path."
      +}
    • changedInput schema / properties / entity_id / description
      Previous value: -"Logbook only: restrict to this entity."New value: +"Logbook only: restrict to one entity, or a comma-separated list of entity IDs."
    • changedInput schema / properties / level / description
      Previous value: -"system / error_log only: keep only entries at exactly this level (ERROR, WARNING, INFO, DEBUG, CRITICAL); it is not a threshold."New value: +"system / error_log only: keep only entries at exactly this level (ERROR, WARNING, INFO, DEBUG, CRITICAL); it is not a threshold. For source='error_log' it matches the record's header only, so matching text in a traceback frame does not satisfy it."
    • changedInput schema / properties / limit / description
      Previous value: -"Max entries/lines to return. Does not apply to source='error_log' with structured=True."New value: +"Max entries/lines to return. For source='error_log' with structured=False it bounds returned lines: whole records are selected within it, and a record longer than it is cut (header and last lines kept) with a warning naming how many lines were cut. Does not apply to source='error_log' with structured=True."
    • addedInput schema / properties / offset / anyOf
      Added value: +[
      +  {
      +    "type": "integer"
      +  },
      +  {
      +    "type": "string"
      +  }
      +]
    • changedInput schema / properties / offset / description
      Previous 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."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, or is the opaque token a previous page returned in 'next_offset' on Supervisor/journald installs, which keeps paging exact while new log lines arrive (`structured=True` accepts and returns that token too); 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."
    • removedInput schema / properties / offset / minimum
      Removed value: -0
    • removedInput schema / properties / offset / type
      Removed value: -"integer"
    • changedInput schema / properties / order / description
      Previous 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."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; error_log orders whole records and keeps each record's lines in place. Ignored for source='logger', and for source='error_log' with structured=True."
    • changedInput schema / properties / search / description
      Previous 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."New value: +"Keyword filter on entries/lines. For source='system' it matches message, name and exception text; for the raw error_log path it matches any line of a record, so a traceback frame brings back its header and siblings. Structured error_log mode matches message and logger name only; source='logger' matches the integration domain."
    • changedInput schema / properties / slug / description
      Previous 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."New 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, multicast — here 'supervisor' is the Supervisor service's own logs, not an app with that name."
    • changedInput schema / properties / source / description
      Previous 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."New value: +"'logbook': entity state-change history. 'system': HA's structured system_log entries (errors, warnings) with full exception tracebacks; search also matches those exceptions. 'error_log': raw log text (home-assistant.log on container/pip installs; HA Core's journald stream on Supervisor-backed installs), grouped into records: a header line starts one and every following line that is not itself a header joins it — traceback frames, the blank lines around chained exceptions, and non-HA banners such as s6-overlay restart lines. '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."
  2. 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."
  3. 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)."
  4. 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"
      +]
  5. 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."
  6. 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."
      +}
  7. First observedv7.14.2

TDQS

A4.1/5.0
Behavior5/5

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

The description adds substantial behavioral context beyond the annotations: it explains bounded/capped windows, window_start/window_end reporting, has_more and next_offset pagination, where tracebacks are dropped, how counts are scoped, and that limit/order are ignored in structured mode. This is exactly the kind of operational detail an agent needs to use the tool correctly.

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 appropriately front-loaded with the purpose and then organized by source/behavior concerns. It is dense and long, but the complexity of 15 parameters and seven sources justifies much of the length; a few cross-parameter points are repeated rather than stated once.

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 annotations, output schema, and exhaustive parameter schema, the description supplies the remaining critical context: source selection, structured versus raw behavior, windowing, pagination, and traceback handling. An agent has enough information to choose a source and interpret the result without needing further external documentation.

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 100% and the input schema already documents each parameter in depth. The description synthesizes some cross-parameter behavior and introduces pagination-related concepts such as window_lines and next_offset, but most of its parameter-specific content repeats or summarizes what is already in the schema.

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?

The description opens with a specific verb and resource: 'Get Home Assistant logs from various sources.' It clearly signals log retrieval across multiple backends, but it does not explicitly distinguish this tool from nearby alternatives such as ha_get_history or ha_get_automation_traces, so it falls short of a full 5.

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?

It gives clear usage guidance among modes: prefer source='system' for triage, use structured=True for per-component rollup, and use structured=False or raw-text sources when broader raw coverage is needed. It stops short of naming sibling tools or describing when not to use this tool versus alternatives, so it is strong but not exhaustive.

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