Skip to main content
Glama
homeassistant-ai

Home Assistant MCP Server

Official

Get Logs

ha_get_logs
Read-onlyIdempotent

Fetch Home Assistant logs from system, logbook, supervisor, or raw error files to diagnose errors, monitor entity changes, and triage issues with search, level filters, and pagination.

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)

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); 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. Logbook params: hours_back, entity_id, end_time, compact (default True — strips attribute dicts to save context) Pagination (logbook + error_log): offset pages deeper; ignored for the other sources. 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): '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' 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.
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. Dates show when Glama detected each change.

  1. 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."
  2. 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."
      +}
  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 readOnlyHint=true, openWorldHint=false, and idempotentHint=true, and the description adds substantial behavioral context beyond those: pagination semantics, bounded windows, per-source ordering behavior, structured-mode ranking, and what response fields like has_more and next_offset mean. It also exposes nuanced caveats like system_log counts running since first occurrence versus error_log's windowed counts. No contradiction with annotations.

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, but the structure is excellent: bold source headers, bulleted groups, and shared-parameter sections make it scannable. Some sentences are dense and could be trimmed, but for a 13-parameter, six-source tool the length is largely justified.

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, the description covers all essential operational concerns: source selection, default source, pagination, ordering, structured versus raw modes, slug requirements, and filtering. An output schema exists, so the description does not need to re-document return values. Nothing an agent needs to call or route this tool correctly appears missing.

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?

Schema description coverage is only 31%, so the description carries the burden, and it does so thoroughly. It explains shared params (limit, search), source-specific params (level, structured, top_n, slug), when order is ignored, how offset paginates for logbook versus error_log, and what compact strips. Every parameter is given semantic meaning beyond its bare schema type.

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 states a specific verb and resource: 'Get Home Assistant logs from various sources,' then enumerates six distinct log sources with clear semantics. This differentiates ha_get_logs from sibling tools like ha_get_history and ha_get_system_health without ambiguity.

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 explicit routing guidance, such as 'Prefer source="system" for triage' and when to use error_log with structured=True. It also names ha_get_app as the way to list installed slugs. It does not explicitly contrast this tool with ha_get_history, so it stops short of full alternative-exclusion 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