Skip to main content
Glama

query_range

Read-onlyIdempotent

Run a LogQL range query across a time window to search logs, tail a service, or graph metric expressions. Returns raw Loki JSON results without modifying data.

Instructions

Run a LogQL range query against Loki, returning results across a time window.

This is the tool to reach for when reading logs: searching for errors, tailing a service over the last hour, or graphing a metric expression over time. Use query instead when a single point-in-time value is enough. If the selector is unknown, call labels and label_values first.

Returns the raw Loki JSON response: {"status","data":{"resultType","result"}}, where resultType is "streams" for log selectors and "matrix" for metric expressions. Loki truncates at limit entries, so a full result set may mean logs were cut off; narrow start/end or tighten the selector rather than raising limit. Read-only: it never writes to or mutates Loki.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endNoEnd of the time range, RFC3339 or Unix nanoseconds. Defaults to now.
limitNoMaximum log entries to return. Applies to log selectors only; metric expressions ignore it. Defaults to 100, must not exceed 5000.
queryYesLogQL expression. Log example: {app="nginx"} |= "error" | json. Metric example: sum by (app) (rate({app="nginx"}[5m])).
startNoStart of the time range, RFC3339 (2026-03-25T10:00:00Z) or Unix nanoseconds. Defaults to 1 hour ago.
directionNoOrder of returned log entries: backward (newest first, the default) or forward (oldest first). With backward and a hit limit, you keep the newest entries.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv0.0.3
    • changedInput schema / properties / direction / description
      Previous value: -"Sort order: forward or backward. Defaults to backward"New value: +"Order of returned log entries: backward (newest first, the default) or forward (oldest first). With backward and a hit limit, you keep the newest entries."
    • addedInput schema / properties / direction / enum
      Added value: +[
      +  "forward",
      +  "backward"
      +]
    • changedInput schema / properties / end / description
      Previous value: -"End of time range (RFC3339 or Unix nanoseconds). Defaults to now"New value: +"End of the time range, RFC3339 or Unix nanoseconds. Defaults to now."
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum number of entries to return. Defaults to 100, max 5000"New value: +"Maximum log entries to return. Applies to log selectors only; metric expressions ignore it. Defaults to 100, must not exceed 5000."
    • changedInput schema / properties / query / description
      Previous value: -"LogQL query expression"New value: +"LogQL expression. Log example: {app=\"nginx\"} |= \"error\" | json. Metric example: sum by (app) (rate({app=\"nginx\"}[5m]))."
    • changedInput schema / properties / start / description
      Previous value: -"Start of time range (RFC3339 or Unix nanoseconds). Defaults to 1 hour ago"New value: +"Start of the time range, RFC3339 (2026-03-25T10:00:00Z) or Unix nanoseconds. Defaults to 1 hour ago."
  2. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations already cover readOnlyHint, destructiveHint, idempotentHint. Description adds valuable behavior beyond those: truncation at limit with advice to narrow range, direction effect ('With backward and a hit limit, you keep the newest entries'), and explicit read-only statement. No contradiction; it enriches transparency with operational details.

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?

Well-structured: purpose first, then usage guidance, then output format, then truncation caveat, then read-only note. Every sentence delivers distinct value—no filler. Front-loaded with the most important usage context. Appropriate length for a complex tool.

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 no output schema and complex behavior, the description explains the raw JSON response format, resultType meanings, truncation behavior, and parameter interactions. It also covers edge cases (metric expressions ignore limit, direction defaults). All necessary information for correct invocation is present.

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

Parameters4/5

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

Schema description coverage is 100%, so baseline is 3. Description adds nuance: clarifies that limit applies only to log selectors (not metric expressions), explains direction's effect on truncation, and advises narrowing start/end rather than raising limit. This goes beyond schema's per-parameter descriptions, adding operational semantics.

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 states a specific verb ('Run a LogQL range query'), resource ('Loki'), and scope ('across a time window'). It explicitly distinguishes from sibling 'query' (point-in-time) and mentions 'labels' and 'label_values' as alternate tools. An agent can immediately understand what this tool does and how it differs from siblings.

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?

Provides explicit guidance: 'This is the tool to reach for when reading logs' and gives concrete scenarios (searching errors, tailing over an hour, graphing metrics). It specifies when to use 'query' instead and instructs to call 'labels' and 'label_values' first if selector unknown. Clear when/when-not with named alternatives.

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