Skip to main content
Glama
industrial-aiops

OT-AIops Energy

historian_query

Read-only

Fetch historical tag samples from SQLite, TDengine, or IoTDB to inspect pre-incident windows for root cause analysis. Read-only, bounded rows with truncation flag.

Instructions

[READ][risk=low] Query a tag's historical samples from a historian.

Reads history back OUT of the store the sinks write — the local SQLite
store (~/.iaiops/data.db), TDengine, or IoTDB — so the RCA copilot / an
agent can see real pre-incident windows instead of only short live samples.
Read-only over the operator's OWN historian; no device I/O. Bounded: rows
are capped and a truncation flag is set when more history exists.

Args:
    tag: Tag/metric name as stored by historian_push (e.g. 'line1.temp').
    since/until: Optional ISO-8601 time bounds (inclusive).
    endpoint: Only samples from this endpoint label (sqlite reader only —
        the TSDB layout stores no endpoint label).
    reader: 'sqlite' | 'tdengine' | 'iotdb'. Omit to use the per-site
        'historian:' block in ~/.iaiops/config.yaml, else the local sqlite
        store. TSDB readers need their extra: pip install iaiops[tdengine|iotdb].
    limit: Max rows returned (1..10000; default 1000).

Returns dict: {reader, source, tag, since, until, rows,
    samples:[{ts, endpoint, protocol, tag, value, quality, unit}], truncated}
    plus the standard return envelope (items_returned, items_total,
    items_total_is_exact, is_truncated, truncation_note). Trust
    `is_truncated`: an empty `samples` with is_truncated=false means the
    history really is empty, NOT that the result was cut short.

Example: historian_query(tag="line1.temp", since="2026-07-02T06:00:00Z",
    until="2026-07-02T08:00:00Z").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tagYes
limitNo
sinceNo
untilNo
readerNo
endpointNo
Behavior5/5

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

Annotations already mark readOnlyHint=true and destructiveHint=false, but the description adds bounded rows ('rows are capped and a truncation flag is set when more history exists') and a crucial semantic: 'an empty samples with is_truncated=false means the history really is empty, NOT that the result was cut short.' Also discloses no device I/O.

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?

Description is structured with a summary line, context, args, return dict, and example. Each sentence adds necessary behavioral or parameter detail; no fluff.

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?

No output schema exists, so the description specifies the return dict fields and the `is_truncated` trust semantics. It also covers the reader fallback path and example invocation, making it self-contained for invocation.

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 coverage is 0% and the Args section fully compensates: each parameter is explained with types, defaults, constraints (e.g., limit 1..10000 default 1000), and reader-specific behavior ('endpoint ... sqlite reader only — the TSDB layout stores no endpoint label').

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?

Description opens with '[READ][risk=low] Query a tag's historical samples from a historian.' The verb 'Query' and resource 'tag's historical samples' are specific, and it contrasts with sibling historian_push and live-sample tools.

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?

Description says 'so the RCA copilot / an agent can see real pre-incident windows instead of only short live samples,' giving clear context for historical analysis. It does not explicitly name an alternative tool for exclusion, so a 4 rather than 5.

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/industrial-aiops/industrial-aiops-energy'

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