Skip to main content
Glama
mcp-loki

mcp-loki

by mgcrea

Loki: Get Volume

loki_get_volume
Read-only

Calculate log volume in bytes per service, namespace, or stream from the Loki index over a time range, ranked largest first, to identify noisy sources and compare selectors before querying.

Instructions

How many bytes of logs each service, namespace or stream produced over a range, largest first, from the index alone — no lines are read, so it is cheap over days. Use it to find the noisiest sources, to see what a selector covers before querying it, or to compare: {namespace=~".+"} by ["namespace"] ranks every namespace. Needs volume_enabled (see loki_auth_status).

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": {
      "selector": "<selector>"
    },
    "name": "loki_get_volume"
  }
}

Input Schema

NameRequiredDescriptionDefault
byNoLabels to group by, e.g. ["namespace"] or ["namespace", "app"]. Defaults to the labels named in the selector.
endNoRange end: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z, nanosecond fractions kept) or unix seconds/nanoseconds. Defaults to now.
limitNoMaximum rows to return (1-1000), largest first. Defaults to 20.
startNoRange start: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z, nanosecond fractions kept) or unix seconds/nanoseconds. Defaults to 1 hour before end.
selectorYesA stream selector, e.g. `{namespace="payments", app="api"}`. Label matchers only: no line filters or parsers. At least one matcher must not match the empty string: `{app=~".+"}` works, `{app=~".*"}` and `{}` are rejected.
aggregate_byNoseries: bytes per value of the `by` labels (the usual answer). labels: bytes per label NAME, i.e. how much of the volume carries each label at all.series

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond readOnlyHint/openWorldHint: it discloses the cost model ('from the index alone — no lines are read, so it is cheap over days') and a hard precondition ('Needs volume_enabled') with the sibling tool that reports that state. Those are exactly the facts an agent needs to avoid picking this tool for an expensive job or hitting a disabled-feature failure.

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 what the tool returns and its ranking order, then uses, then the prerequisite. No filler; every clause (cheap over days, largest first, the concrete example) carries information an agent would otherwise have to guess.

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

Completeness4/5

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

With no output schema, the description correctly carries the return shape (bytes per group, ranked, capped) and the key operational caveat. Minor omissions: nothing about what an empty result or a rejected selector looks like at the volume level, but that is covered adequately by the schema's selector constraints.

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; the description earns extra by showing a real invocation, `{namespace=~".+"}` by ["namespace"], which demonstrates how selector and by compose and clarifies the default grouping behavior. It adds little for start/end/limit, but those are already fully documented in the schema.

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: byte volume of logs per service/namespace/stream over a range, ranked largest first, computed from the index with no line reads. That distinguishes it cleanly from loki_query_logs (which reads lines) and from the list_labels/list_series family.

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?

Gives three concrete uses: find the noisiest sources, preview what a selector covers before querying, and compare groupings. It also names the prerequisite tool (loki_auth_status for volume_enabled). It stops short of explicitly saying when NOT to use it, e.g. 'use loki_query_logs instead when you need actual log lines', but the routing is strongly implied.

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