Skip to main content
Glama

query

Read-onlyIdempotent

Run LogQL instant queries against Loki to evaluate metric expressions or log selectors at one point in time. Get a single value per series or a quick snapshot of current logs in raw JSON.

Instructions

Run a LogQL instant query against Loki, evaluating the expression at a single point in time.

Use this for metric expressions (rate, count_over_time, sum by) when one value per series is enough, or for a quick "what is happening right now" check. To read log lines across a time window, use query_range instead. To discover which labels exist before writing a selector, use labels and label_values.

Returns the raw Loki JSON response: {"status","data":{"resultType","result"}}, where resultType is "vector" for metric expressions and "streams" for log selectors. Read-only: it never writes to or mutates Loki.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeNoEvaluation timestamp, RFC3339 (2026-03-25T10:00:00Z) 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. Metric example: sum(rate({app="nginx"} |= "error" [5m])). Log example: {app="nginx"} |= "error".
directionNoOrder of returned log entries: backward (newest first, the default) or forward (oldest first).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 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)."
    • addedInput schema / properties / direction / enum
      Added value: +[
      +  "forward",
      +  "backward"
      +]
    • 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. Metric example: sum(rate({app=\"nginx\"} |= \"error\" [5m])). Log example: {app=\"nginx\"} |= \"error\"."
    • changedInput schema / properties / time / description
      Previous value: -"Evaluation timestamp (RFC3339 or Unix nanoseconds). Defaults to now"New value: +"Evaluation timestamp, RFC3339 (2026-03-25T10:00:00Z) or Unix nanoseconds. Defaults to now."
  2. First observedv0.1.0

TDQS

A4.7/5.0
Behavior4/5

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

Annotations already declare read-only and idempotent, but the description adds the exact return format (raw Loki JSON with resultType 'vector' or 'streams') and explicitly states 'never writes to or mutates Loki'. This goes beyond annotations by specifying output structure and result semantics.

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?

Compact and well-structured: core action first, then usage guidance, then return format, and finally safety. No filler; every sentence earns its place.

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?

Without an output schema, the description fully explains the return JSON and resultType. It also covers usage context, parameter guidance, and safety. For a read-only query tool, nothing essential is missing.

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 coverage is 100%, meeting the baseline, but the description adds value by explaining how the query parameter should be shaped (metric examples like rate, count_over_time) and clarifying that limit applies only to log selectors (though this is also in schema). The description reinforces parameter behavior without redundancy.

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?

Clearly states the tool runs a LogQL instant query against Loki, evaluates at a single point in time, and differentiates from query_range (time window) and labels/label_values (label discovery). The verb 'run' and resource 'Loki' are specific and unambiguous.

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?

Explicitly states when to use (metric expressions needing one value per series, quick 'what is happening right now' checks) and when not (query_range for time ranges, labels/label_values for label discovery). Names alternatives and conditions clearly.

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