Skip to main content
Glama

logs_query

Query Loki logs using LogQL to retrieve matching log lines for troubleshooting and observability investigations.

Instructions

Query logs from Loki using LogQL. Returns log lines matching the query.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>"
    },
    "name": "logs_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
endNoEnd time. Defaults to now.
limitNoMaximum log lines to return
queryYesLogQL query (e.g. {app="my-api"} |= "error")
startNoStart time (ISO 8601 or Unix nanoseconds). Defaults to 1h ago.
targetNoNamed backend instance to query (configured: default). Defaults to the primary.
directionNoSort orderbackward

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.8.0

TDQS

B3.1/5.0
Behavior2/5

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

With no annotations, the description carries the full burden, and it discloses very little beyond that results are log lines matching the query. It does not state that this is a read-only operation, how the limit truncates results, whether results can be huge or slow for wide time ranges, or anything about the named target backend selection.

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?

Two sentences, front-loaded with the action and backend, zero filler. Nothing is redundant with the schema and nothing is wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 6-parameter, read-only query tool with a fully documented schema and no output schema, the description is minimally viable: it explains what is queried and what comes back. It is missing routing guidance relative to the many sibling tools and any behavioral caveats, which is a meaningful gap for an agent choosing among ~25 tools.

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?

Schema description coverage is 100%, including defaults and formats for start/end/limit/direction/target, so the schema already supplies parameter meaning. The description adds only a brief LogQL hint and no extra semantics (e.g. how start/end interact or what happens if the target is unknown), so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb ("Query"), resource ("logs"), and backend/query language (Loki, LogQL), which cleanly separates it from metrics_query/traces_search siblings. It stops short of naming which sibling to use for adjacent log operations such as label discovery or tailing, so it is clear but not fully differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no when-to-use guidance at all: nothing tells the agent when to pick logs_query versus logs_labels, logs_label_values, or logs_tail_context, nor any prerequisite (e.g. needing a known label or LogQL syntax first). The only implied guidance is that you must already have a LogQL query in mind.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.