Skip to main content
Glama
mgcrea

@mgcrea/mcp-grafana

by mgcrea

Grafana: Query Prometheus

grafana_query_prometheus
Read-only

Evaluate PromQL expressions against a Prometheus datasource to retrieve instant values or range trends, with per-series min/max/avg/last stats for outlier detection and aggregation.

Instructions

Evaluate PromQL through a Prometheus datasource. mode=instant (default) gives the value at one time — the right mode for almost every question, with any window written into the expression (increase(x[24h])). mode=range gives the shape over time on a step grid with min/max/avg/last per series; use view=stats with sort=max to find outliers among many series. Labels shared by every series come back once as common_labels. Aggregate in the expression (sum by, topk) rather than fetching raw series.

Input Schema

NameRequiredDescriptionDefault
endNoRange end for mode=range: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds/ms. Defaults to now.
exprYesA PromQL expression, e.g. `sum by (namespace) (rate(container_cpu_usage_seconds_total[5m]))`. $__interval, $__rate_interval and $__range are filled in by Grafana.
modeNoinstant (default) or range.instant
sortNoOrder of time series, applied before `limit` cuts: labels keeps the datasource's order; max/avg/last rank highest first, so a cut keeps the biggest.labels
stepNoResolution, as a duration (30s, 5m, 1h). Defaults to a round step giving `points` points. Grafana never goes below the datasource's scrape interval.
timeNoEvaluation time for mode=instant: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds/ms. Defaults to now.
viewNoFor time series. values: stats (min/max/avg/last) plus one value per step on a shared grid given by start and step, null where there was no sample. stats: the stats only, about a tenth of the size — use it to survey many series before reading a few.values
limitNoMaximum series (1-2000). Defaults to 100. To see the largest, write topk() into the query.
startNoRange start for mode=range: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds/ms. Defaults to now-1h.
pointsNoTarget points per series (2-1000), from which the step is picked. Defaults to 60; a dashboard in a browser asks for ~1000, which is rarely worth the tokens.
precisionNoSignificant digits to round fractional values to (whole numbers are never rounded). Defaults to 4; 0 returns the exact value.
datasourceNoDatasource uid or name, e.g. "prometheus" or "Loki". Defaults to the default Prometheus datasource. grafana_list_datasources lists them.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations only declare readOnly/openWorld, and the description goes well beyond them: it discloses the return shape (min/max/avg/last per series, one value per step on a shared grid, null where no sample), the `common_labels` de-duplication, and relative payload cost ('about a tenth of the size'). That cost/shape guidance is exactly what an agent needs to avoid token blowups.

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?

Four sentences, front-loaded with the default mode and the 'almost every question' heuristic, then progressive detail on range/stats and aggregation. No filler and no restatement of the tool name or title.

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?

For a 12-parameter tool with no output schema and thin annotations, the description covers mode choice, output shape, payload size, and aggregation strategy — enough to call it correctly. It says nothing about failure modes (bad PromQL, missing datasource) or what an empty result looks like, which is the remaining gap.

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 baseline is 3; the description adds genuine meaning on top by explaining the mode tradeoff, the view+sort interaction for outlier hunting, and the step/scrape-interval floor. It reinforces rather than repeats parameter docs, though per-parameter edge cases (limit vs topk interplay, precision) are left mostly to 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?

Specific verb + resource: 'Evaluate PromQL through a Prometheus datasource', which cleanly separates it from the LogQL sibling grafana_query_loki and from panel/search tools. It also states the two operating modes up front, so an agent knows the shape of the call before opening the schema.

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 explicit decision rules: instant is 'the right mode for almost every question', range is for shape-over-time, and 'use view=stats with sort=max to find outliers among many series'. It also states an anti-pattern ('Aggregate in the expression ... rather than fetching raw series'). It stops short of naming tool-level alternatives (grafana_query_loki, grafana_run_panel_query), which keeps it from a 5.

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