# Grafana — MCP Server

> Query Prometheus and Loki, search dashboards, triage alerts in chat.

**Source:** https://mcpplaygroundonline.com/mcp-servers/grafana  
**Transport:** stdio  
**Requires auth:** Yes

---

## What it does

The Grafana MCP server connects through your Grafana instance rather than to each datasource separately, which means one credential and one endpoint covers everything Grafana already knows how to reach. On the metrics side an agent can list datasources, discover metric names and label values, and run instant or range PromQL queries. On the logs side it can query Loki with LogQL, list label names and values, and fetch log statistics. It can search dashboards by title, fetch a dashboard by UID to read its panels, and update or create dashboards. Incident response is covered too: list and create incidents, read alert rules and their current state, and run Sift investigations that look for error patterns or slow requests automatically. A generate_deeplink tool returns a real Grafana URL so a human can pick up where the agent left off. Tools are grouped into categories you can disable individually, which keeps the tool list manageable.

## Tools exposed

- query_prometheus — run instant or range PromQL queries against a datasource
- list_prometheus_metric_names / label values — discover what is actually being recorded
- query_loki_logs / query_loki_stats — LogQL queries and log volume statistics
- search_dashboards / get_dashboard_by_uid / update_dashboard — read and edit dashboards
- list_datasources / get_datasource_by_uid — enumerate what the instance can query
- list_alert_rules / get_alert_rule_by_uid — alert definitions and current state
- list_incidents / create_incident — Grafana Incident workflows
- find_error_pattern_logs / find_slow_requests — Sift investigations
- generate_deeplink — hand a human a real Grafana URL for the view being discussed

## Example queries you can run

- "What was p99 latency on the checkout service over the last six hours?"
- "Find the error pattern in the payments logs since the deploy at 14:00."
- "Which alert rules are currently firing, and which dashboards cover those services?"
- "Show me request rate by pod for the last hour and flag anything anomalous."

## Details

- **Recommended model:** anthropic/claude-sonnet-4.5 — PromQL and LogQL are easy to write and easy to write wrong. Sonnet 4.5 constructs correct queries and interprets the returned series rather than restating them.
- **Transport:** stdio
- **Authentication:** Required — A Grafana service account token with only the permissions you want the agent to have. Viewer is enough unless you intend it to edit dashboards.
- **Official source:** [Grafana MCP server — official documentation](https://grafana.com/docs/grafana/latest/developer-resources/mcp/)

## Connecting to Grafana

### Environment variables

- `GRAFANA_URL` (required) — Base URL of your Grafana instance, for example https://myorg.grafana.net.
- `GRAFANA_SERVICE_ACCOUNT_TOKEN` (required) — Service account token. Create a dedicated account with the Viewer role for read-only agent access.

### Client configuration

**uvx (recommended)**

Runs the published server without a separate install step.

```
{
  "mcpServers": {
    "grafana": {
      "command": "uvx",
      "args": ["mcp-grafana"],
      "env": {
        "GRAFANA_URL": "https://myorg.grafana.net",
        "GRAFANA_SERVICE_ACCOUNT_TOKEN": "glsa_YOUR_TOKEN"
      }
    }
  }
}
```

**Docker in stdio mode**

The image defaults to SSE, so pass -t stdio explicitly for desktop clients.

```
{
  "mcpServers": {
    "grafana": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "GRAFANA_URL", "-e", "GRAFANA_SERVICE_ACCOUNT_TOKEN",
        "mcp/grafana", "-t", "stdio"
      ],
      "env": {
        "GRAFANA_URL": "https://myorg.grafana.net",
        "GRAFANA_SERVICE_ACCOUNT_TOKEN": "glsa_YOUR_TOKEN"
      }
    }
  }
}
```

## Frequently asked questions

### What is the Grafana MCP server?

It is the official MCP server from Grafana Labs, published as grafana/mcp-grafana. It gives an AI assistant access to your Grafana instance — Prometheus and Loki queries, dashboards, datasources, alert rules, incidents and Sift investigations.

### Do I need to connect Prometheus separately?

No. The server queries through Grafana, so any datasource Grafana can already reach is available with the same single token. That is the main practical advantage over pointing an agent at Prometheus directly.

### What permissions should the service account have?

Viewer covers metrics, logs, dashboards and alert reads, which is what most people want. Grant Editor only if you genuinely intend the agent to create or update dashboards, and consider a separate account for that.

### Which Grafana versions are supported?

Grafana 9.0 or later for full functionality. Sift investigations, Incident and OnCall tools additionally require those features to be enabled on the instance, and are absent on a plain OSS install.

### Can I limit which tools the agent sees?

Yes. Tools are grouped into categories — dashboards, datasources, Prometheus, Loki, alerting, incident, Sift, OnCall, admin — and each group can be disabled at startup. Trimming to the groups you need keeps the tool list short, which measurably improves tool selection.

---

_Test this server across 40+ models on MCP Playground: https://mcpplaygroundonline.com/mcp-servers/grafana — free, no install._
