Skip to main content
Glama
igorolv

loki-mcp-server

queryLogs

queryLogs
Read-onlyIdempotent

Read a bounded, chronological page of Grafana Loki log lines matching a LogQL query in a time window. Supports newest or oldest order, raw previews, and pagination via footer values.

Instructions

Read a bounded page of log lines matching a LogQL query in a window. The response is chronological, with a compact level, service and message view. Example: {app="backend"} |= "ERROR". Use raw=true to preview the line returned by Loki with its stream labels; long lines are shortened. Use order="oldest" to read forward, repeat with the start or end value in the footer, and use exportLogs for complete files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endNoWindow end, default now. Use the end in a queryLogs footer to read older lines.
rawNoPreview the line returned by Loki with stream labels, default false
limitNoMaximum lines to show, default 50
orderNonewest (default) or oldest; oldest reads forward
queryYesLogQL log query, e.g. {app="backend"} |= "ERROR". Take label names and values from discoverLogs.
startNoWindow start, default now-1h. Examples: now-15m, now-2d, 2026-09-13T10:00:00+03:00.
connectionYesConnection name from listConnections

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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 readOnly, idempotent, and non-destructive, so the safety profile is covered. The description adds real behavioral context beyond that: response is chronological, uses a compact level/service/message view, and long lines are shortened. It stops short of describing pagination limits or line-count defaults.

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?

Three tight sentences, front-loaded with the core purpose before the example and the usage tips. Every clause carries actionable information with no filler.

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, yet the description compensates by describing the return shape (chronological, compact level/service/message view) and how to continue paging. Combined with the fully documented schema, an agent has everything needed to call it correctly.

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%, so the baseline is 3, but the description adds semantic value: it explains raw's preview purpose and the pagination idiom of reusing footer start/end values, plus the forward-reading meaning of order="oldest". That goes beyond the schema's terse parameter descriptions.

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?

States a specific verb and resource ('Read a bounded page of log lines matching a LogQL query in a window') and immediately contrasts itself with exportLogs for complete files. An agent can distinguish it from countLogs, discoverLogs, and exportLogs without opening any schema.

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?

Gives explicit branch conditions: raw=true to preview raw Loki lines, order="oldest" to read forward with start/end footer values for continuation, and exportLogs when complete files are needed. This is a genuine when/when-not/alternative routing.

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