Skip to main content
Glama
mcp-loki

mcp-loki

by mgcrea

Loki: List Labels

loki_list_labels
Read-only

List indexed Loki stream labels with their distinct value counts, optionally filtered by a stream selector, to choose low-cardinality labels before building LogQL queries.

Instructions

List the indexed stream labels with how many distinct values each has, optionally only for streams matching a selector. The starting point for writing any query: low-cardinality labels (namespace, app, service_name, container) make good selectors; high-cardinality ones (pod, filename) are better left to line filters or by. Then loki_list_label_values for the values of one label.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "loki_list_labels"
  }
}

Input Schema

NameRequiredDescriptionDefault
endNoRange end: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z, nanosecond fractions kept) or unix seconds/nanoseconds. Defaults to now.
startNoRange start: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z, nanosecond fractions kept) or unix seconds/nanoseconds. Defaults to 6 hours before end.
selectorNoA 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.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=true, so the safety profile is covered; the description adds real context by noting the response includes per-label distinct-value counts and that selectors accept label matchers only. It does not explain how start/end interact with label indexing, which is the one behavioral gap.

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?

Front-loaded with what the tool returns, then usage rationale, then the handoff to the sibling tool. Every sentence carries operative information for an agent writing a query; nothing is filler.

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 three optional parameters, no output schema, and full schema descriptions, the description covers enough: it partially describes the return shape and the selector constraint. It leaves the time-range semantics to the schema, which is an acceptable division of labor but not a complete picture.

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 start/end formatting is already fully documented and the baseline is 3. The description goes beyond the schema for the selector by explaining what kinds of labels to put in it and how cardinality affects that choice, which is genuine added meaning.

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 ("List the indexed stream labels") plus the shape of the result ("how many distinct values each has"), and scopes it with the optional selector. This is clearly distinguishable from loki_list_label_values, which is named as the follow-up for per-label values.

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 frames the tool as "The starting point for writing any query" and gives concrete selection advice: low-cardinality labels make good selectors while high-cardinality ones belong in line filters or `by`. It also names the next tool to call (loki_list_label_values), so the agent has both a when and an after.

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