Skip to main content
Glama
mgcrea

@mgcrea/mcp-grafana

by mgcrea

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
GRAFANA_URLYesGrafana root URL, including any sub-path, e.g. https://grafana.example.com.
GRAFANA_DEBUGNo1 to log each request to stderr.
GRAFANA_ORG_IDNoThe org this server must read. Sent as X-Grafana-Org-Id; data tools refuse on a mismatch.
GRAFANA_API_KEYNoAlias for GRAFANA_SERVICE_ACCOUNT_TOKEN.
GRAFANA_HEADERSNoExtra headers as JSON, e.g. a Cloudflare Access service token.
GRAFANA_TIMEOUTNoSeconds per request. Defaults to 30.
GRAFANA_PASSWORDNoPassword for basic auth instead of a token.
GRAFANA_USERNAMENoUsername for basic auth instead of a token.
GRAFANA_MAX_RETRIESNoRetries on 429/502/503/504 for reads. Defaults to 2. Writes are never retried.
GRAFANA_ALLOW_WRITESNo1 to register the write tools.
GRAFANA_SERVICE_ACCOUNT_TOKENNoA service account token (glsa_…). GRAFANA_API_KEY is accepted as an alias.

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

This server publishes no instructions, or was last inspected before Glama recorded them.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": true
}

Tools

Functions exposed to the LLM to take actions

NameDescription
grafana_auth_statusA

Report which Grafana and which organization this server reads, as whom, and what that credential may do: the URL, Grafana version, org id and name, the login (a service account or a user), its effective role and permissions, and whether write tools are registered. When the server is not configured, says exactly what to set. Call this first when a tool you expected is missing, and before trusting data from an instance you have not checked: a service account token picks its org silently.

grafana_searchA

Find dashboards and folders by title substring, tag, folder or starred state. Returns uid, title, folder, tags and the URL of each; feed a uid to grafana_get_dashboard. With no arguments, lists every dashboard (up to limit).

grafana_get_dashboardA

Read a dashboard. view=summary (default) returns what is on it without the layout: variables, and every panel (rows flattened) with its id, type, unit and queries — the layout, styling and overrides left out, typically half the JSON. view=panel returns one panel's full JSON (needs panel_id). view=full returns the whole dashboard JSON with its version, which is what grafana_save_dashboard needs back; it can be tens of KB. To see the DATA a panel shows, use grafana_run_panel_query instead of reading its query and re-typing it.

grafana_run_panel_queryA

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).

grafana_query_prometheusA

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.

grafana_query_lokiA

Run LogQL through a Loki datasource. A log query ({namespace="api"} |= "error") returns lines newest first, each with its time, level and the labels that differ between lines (the shared ones once, as common_labels), cut at max_line_chars. A metric query (sum by (app) (count_over_time({namespace="api"} |= "error" [5m]))) returns series on a step grid with stats. Always put a label matcher in the selector and keep the range short: Loki scans every line in it. To count, prefer a metric query over fetching lines.

grafana_queryA

Run raw queries against any datasource through /api/ds/query — for datasources with no dedicated tool (SQL, Elasticsearch, Tempo, CloudWatch…), or for server-side expressions over other queries ({"datasource": "__expr__", "type": "math", "expression": "$A / $B"}). Each query is the target object as it appears in a panel's JSON (grafana_get_dashboard view=panel shows one). Prefer grafana_query_prometheus / grafana_query_loki for those two, and grafana_run_panel_query to reproduce a panel. Dashboard variables are NOT filled in here.

grafana_list_labelsA

Discover what to query, for a Prometheus or Loki datasource: with no label, the label names in use; with label, the values it takes (label=name lists Prometheus metric names). Restrict with selector to the series or streams that matter, e.g. the pods of one namespace. Looks at the last hour unless start is given — the datasource default is its whole retention, which returns everything that ever existed.

grafana_list_datasourcesA

List the datasources: uid, name, type (prometheus, loki, alertmanager, postgres…), and which one is the default. Every query tool takes a datasource by uid or name. Credentials and plugin settings are never returned.

grafana_list_alertsA

What is alerting right now: the alerts held by Grafana's Alertmanager and by every Alertmanager datasource, most severe first, with since when, summary and description. Silenced and inhibited alerts are left out unless state=suppressed or all. Labels shared by every alert come back once as common_labels; counts by severity and alertname cover the whole match even when the list is cut.

grafana_list_alert_rulesA

The alert rules and their evaluation state, from Grafana-managed alerting and from every Prometheus/Loki datasource that evaluates its own rules. Firing first, then pending. Each rule has its group, state, health (and lastError when it fails to evaluate), its for and labels; include_query adds the expression. Recording rules are left out unless type=record or all. Use grafana_list_alerts for the alert instances themselves.

grafana_list_silencesA

The silences in Grafana's Alertmanager and every Alertmanager datasource: id, state, matchers, start and end, who created it and why. Expired silences are left out unless state=expired or all.

grafana_list_annotationsA

Annotations in a time window, newest first: deploys, incidents and notes people or CI marked on dashboards, and alert state changes (type=alert). Each has its time (and end for a region), text, tags, dashboard and panel. The usual question — "what changed around the spike?" — is a window around the spike with no other filter.

grafana_requestA

Escape hatch: GET any Grafana HTTP API endpoint the other tools do not wrap — /api/v1/provisioning/alert-rules/, /api/v1/provisioning/contact-points, /api/v1/provisioning/policies, /api/folders, /api/library-elements, /api/teams/search, /api/org/users, /api/dashboards/uid//versions, /apis/dashboard.grafana.app/v2beta1/namespaces/default/dashboards/. The answer is the raw JSON, unshaped, cut at max_chars. Read-only: only GET is ever sent. Prefer the named tools, which shape their output.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A4.2/5.0

Scored across 14 tools

Disambiguation4/5

Most tools target a clearly distinct resource or action (list_labels vs list_annotations vs list_silences vs get_dashboard vs run_panel_query), and the descriptions explicitly disambiguate the risky pairs: grafana_query tells you to prefer grafana_query_prometheus/grafana_query_loki, and grafana_list_alert_rules points to grafana_list_alerts for instances. The residual overlaps are grafana_query (generic /api/ds/query) versus the two datasource-specific query tools, and grafana_request acting as a catch-all over nearly everything. Both are framed as escape hatches, which mitigates but does not eliminate the risk of misselection.

Naming Consistency4/5

There is a single grafana_ prefix and a clear verb_noun cadence: list_* (labels, datasources, alerts, alert_rules, silences, annotations), query_* (prometheus, loki, and bare query), get_dashboard, run_panel_query, search. The deviations are small but real: grafana_search omits its object (search_dashboards would fit the pattern), grafana_auth_status is noun-only with no verb, and grafana_query / grafana_request carry no target noun.

Tool Count5/5

Fourteen tools is squarely in the well-scoped band, and each one earns its place: datasource discovery, label discovery, three query paths (Prometheus, Loki, generic), dashboard read plus panel replay, four alerting-state readers, annotations, auth check, and one read-only HTTP escape hatch. Nothing looks padded, and the escape hatch keeps the surface from ballooning into a tool per API endpoint.

Completeness4/5

The read-side lifecycle for Grafana investigation is covered end to end: discover datasources and labels, query metrics/logs/arbitrary sources, find and read dashboards, re-run panel queries with variables filled, and inspect alerts, rules, silences and annotations. The gaps are real but workaroundable: the surface is read-only, and grafana_get_dashboard refers to a grafana_save_dashboard tool that is not registered, which is a dangling pointer an agent may chase.

Maintenance

ActivityMaintained
ResponsivenessNo issues