Skip to main content
Glama
@mgcrea/mcp-grafana

@mgcrea/mcp-grafana

by mgcrea

Grafana: Run Panel Query

grafana_run_panel_query
Read-only

Run a Grafana dashboard panel's queries with template variables resolved and datasource settings respected, returning query details plus time-series, log, or table data for checking and re-runs.

Instructions

Run a dashboard panel's queries the way the dashboard would, and return the data: template variables ($namespace, ${datasource}) are filled in — from vars, else the value saved with the dashboard, else the variable's first value (or All) as the browser would pick — and the panel's datasource, hidden queries and expressions are respected. Returns the variable values used and each query as sent, so the result can be checked and re-run with other values. Time series come back on a step grid with stats, logs as lines, anything else as a table. The time range defaults to the dashboard's own (often now-1h).

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": {
      "uid": "<uid>",
      "panel_id": "<panel_id>"
    },
    "name": "grafana_run_panel_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
toNoRange end: now, now-1h, -30m, now/d or now-1d/d (rounded in UTC: a start to the start of the day, an end to its end), an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds/ms. Defaults to the dashboard's time.to.
uidYesThe dashboard uid, e.g. "alertmanager-overview" (from grafana_search or a /d/<uid>/ URL).
fromNoRange start: now, now-1h, -30m, now/d or now-1d/d (rounded in UTC: a start to the start of the day, an end to its end), an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds/ms. Defaults to the dashboard's time.from.
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
varsNoVariable values by name, without the $, e.g. {"namespace": "monitoring", "pod": ["a", "b"]}. "All" or "$__all" selects All. A datasource variable takes a uid or name.
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, log lines or table rows per query (1-1000). Defaults to 30.
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.
panel_idYesThe panel id, from grafana_get_dashboard (or `viewPanel=` in a dashboard URL), e.g. 4.
precisionNoSignificant digits to round fractional values to (whole numbers are never rounded). Defaults to 4; 0 returns the exact value.
max_line_charsNoCut each log line at this many characters (50-20000). Defaults to 1000.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.2.0
    • changedInput schema / properties / from / description
      Previous value: -"Range start: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds/ms. Defaults to the dashboard's time.from."New value: +"Range start: now, now-1h, -30m, now/d or now-1d/d (rounded in UTC: a start to the start of the day, an end to its end), an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds/ms. Defaults to the dashboard's time.from."
    • changedInput schema / properties / to / description
      Previous value: -"Range end: now, now-1h, -30m, an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds/ms. Defaults to the dashboard's time.to."New value: +"Range end: now, now-1h, -30m, now/d or now-1d/d (rounded in UTC: a start to the start of the day, an end to its end), an RFC3339 timestamp (2026-01-31T12:00:00Z) or unix seconds/ms. Defaults to the dashboard's time.to."
  2. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

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

Annotations only say readOnly and openWorld; the description adds the substantive behavior: variable resolution precedence (from vars, else the saved dashboard value, else the variable's first value or All), that hidden queries and expressions are respected, the return shape per data type (step grid with stats, log lines, table), and that variable values and the queries as sent are echoed back for verification.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core action, then defaults and return shapes, with no filler sentences. The single dense paragraph packs a lot of clauses (variable fallbacks, output type list, time-range default) that could be split for faster scanning, but nothing is redundant.

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 an 11-parameter tool with no output schema, the description covers what the schema cannot: output shapes per data type and how variables and time ranges resolve. It doesn't address failure modes (unknown panel id, unresolvable variables) or auth, which would round it out.

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 per-parameter bar is already met; the description adds cross-parameter meaning the schema cannot — the precedence that decides which variable value wins and the fallback to the dashboard's saved time range. It doesn't restate sort/limit/points/precision interactions beyond what the schema says.

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: "Run a dashboard panel's queries the way the dashboard would, and return the data." The panel/dashboard scoping plus template-variable resolution clearly separates it from the direct datasource siblings (grafana_query_prometheus, grafana_query_loki) without either schema being opened.

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 clear usage context: it runs a panel as the dashboard would, and it explains that view=stats is for surveying many series before reading a few, and that time range defaults to the dashboard's own. It never states explicitly when to prefer this over the ad-hoc sibling query tools, so the alternative routing is left implicit.

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