Skip to main content
Glama
LoganInTX

hass-mcp-extensions

by LoganInTX

query_recorder_db

Run read-only SQL SELECT queries against the Home Assistant recorder database to inspect state history, events, and statistics.

Instructions

Run a read-only SQL SELECT against the Home Assistant recorder (MariaDB).

Use this for ad-hoc queries against the recorder database — e.g. fetching Zigbee action events, checking state history, or inspecting statistics.

Only SELECT statements are allowed. Key tables:

  • states — entity state changes (joined to states_meta for entity_id)

  • states_meta — maps metadata_id -> entity_id

  • events — HA events (joined to event_types for event name)

  • event_types — maps event_type_id -> event_type

  • event_data — JSON payload blobs (joined via data_id)

  • statistics — hourly aggregates

  • statistics_short_term — 5-minute aggregates

Timestamps are stored as DATETIME in UTC (last_updated_ts / time_fired_ts are FLOAT unix epoch seconds; the older last_updated / time_fired DATETIME columns may be NULL in recent HA versions — use the _ts columns instead).

Args: sql: A SELECT statement to execute.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior3/5

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

With no annotations provided, the description carries full burden. It correctly indicates read-only behavior and warns about potential NULL timestamp columns. However, it lacks information about error handling (e.g., invalid SQL), query timeouts, maximum query size, or impact on the system. While it covers the core behavioral trait, several aspects remain unspecified.

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 concise and well-structured: a brief summary sentence, followed by use cases, restrictions, key tables, and timestamp details. Every sentence adds value, and there is no redundant or vague language. It is easy to scan and front-loaded with the most critical information.

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 that an output schema exists (expected based on context), the description does not need to detail return values. It provides essential context about tables, restrictions, and a timestamp caveat, which covers the most important aspects for an agent to use the tool effectively. However, it omits details like result size limits or pagination, which could be relevant for large queries.

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?

The single parameter 'sql' has no schema description (0% coverage), so the description must compensate. It does so by explaining what a SELECT statement is and giving examples of valid queries and table structures. However, it does not explicitly describe the parameter format (e.g., that it expects a string) beyond its name. The added value is moderate but not comprehensive.

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 explicitly states 'Run a read-only SQL SELECT against the Home Assistant recorder (MariaDB).' It gives concrete use cases like fetching Zigbee action events and checking state history, making the purpose very clear. Although no title is provided, the verb+resource specificity is high and sufficiently distinguishes from sibling tools that are more focused on specific queries (e.g., get_history, get_logbook).

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 notes that only SELECT statements are allowed and provides examples of when to use the tool ('ad-hoc queries'). It also lists key tables and timestamp nuances. However, it does not explicitly state when not to use this tool (e.g., in favor of more specific tools like get_history for state history) or mention prerequisites like database permissions.

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/LoganInTX/home-assistant-mcp'

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