# mcp-grafana

Gives your agent access to Grafana: search dashboards, read panels, run PromQL and LogQL. Useful when you are chasing an incident or editing a graph from the chat.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed · ★ 3598
- Author: grafana
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/grafana/mcp-grafana
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/mcp/mcp-grafana

## What it does

The server connects to your Grafana instance and hands the agent tools for dashboards: search by title, folder, tag or starred status, fetch panels and their queries, list saved versions. `get_dashboard_summary` and `get_dashboard_property` with JSONPath pull only the piece you need, because the full JSON of a large dashboard eats context. Edits work too: update, create, and a targeted patch that skips loading the whole file.

Then come the data queries. Prometheus answers PromQL, instant and range, plus metric metadata and histogram percentiles via histogram_quantile. Loki takes LogQL, along with metadata and detected log patterns. Datasource listing covers Prometheus, Loki, ClickHouse, CloudWatch, Elasticsearch, OpenSearch, Snowflake and Athena. Some tools ship disabled: `runpanelquery`, `examples`, `influxdb` and `sql` need the `--enabled-tools` flag. SQL tools go through Grafana's datasource plugins, so the MCP server never sees your database credentials.

Grafana 9.0 or later is required — on older versions datasource operations break because the API endpoints are missing. The `uvx` route needs uv installed; the Docker route needs Docker. Config takes `GRAFANA_URL` and `GRAFANA_SERVICE_ACCOUNT_TOKEN`; on Grafana Cloud you point `GRAFANA_URL` at your instance address.

## Requirements
- Needs: Docker
- Remote server: `https://mcp.grafana.com/mcp`
- Environment variables: `GRAFANA_URL`, `GRAFANA_SERVICE_ACCOUNT_TOKEN`, `GRAFANA_USERNAME`, `GRAFANA_PASSWORD`, `GRAFANA_ORG_ID`, `GRAFANA_EXTRA_HEADERS`, `GRAFANA_FORWARD_HEADERS` — keys and tokens: ask the human for the values, never commit them or put them in shared files.
- Works with: Grafana

## Install

### Claude Code (native platform)

1. **Platform CLI: remote server**
```bash
claude mcp add --transport http mcp-grafana https://mcp.grafana.com/mcp
```

2. **Platform CLI**
```bash
claude mcp add --env GRAFANA_URL=<GRAFANA_URL> --env GRAFANA_SERVICE_ACCOUNT_TOKEN=<GRAFANA_SERVICE_ACCOUNT_TOKEN> --env GRAFANA_USERNAME=<GRAFANA_USERNAME> --env GRAFANA_PASSWORD=<GRAFANA_PASSWORD> --env GRAFANA_ORG_ID=<GRAFANA_ORG_ID> --transport stdio mcp-grafana -- docker run -i --rm -e GRAFANA_URL -e GRAFANA_SERVICE_ACCOUNT_TOKEN -e GRAFANA_USERNAME -e GRAFANA_PASSWORD -e GRAFANA_ORG_ID docker.io/grafana/mcp-grafana:2.1.1
```
Replace <…> with your own values. 2 more environment variables are in the server README

### Codex

1. **Platform CLI: remote server**
```bash
codex mcp add mcp-grafana --url https://mcp.grafana.com/mcp
```

2. **Platform CLI**
```bash
codex mcp add mcp-grafana --env GRAFANA_URL=<GRAFANA_URL> --env GRAFANA_SERVICE_ACCOUNT_TOKEN=<GRAFANA_SERVICE_ACCOUNT_TOKEN> --env GRAFANA_USERNAME=<GRAFANA_USERNAME> --env GRAFANA_PASSWORD=<GRAFANA_PASSWORD> --env GRAFANA_ORG_ID=<GRAFANA_ORG_ID> -- docker run -i --rm -e GRAFANA_URL -e GRAFANA_SERVICE_ACCOUNT_TOKEN -e GRAFANA_USERNAME -e GRAFANA_PASSWORD -e GRAFANA_ORG_ID docker.io/grafana/mcp-grafana:2.1.1
```
Replace <…> with your own values. 2 more environment variables are in the server README

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "mcp-grafana": {
            "url": "https://mcp.grafana.com/mcp"
        }
    }
}
```
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "mcp-grafana": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-e",
                "GRAFANA_URL",
                "-e",
                "GRAFANA_SERVICE_ACCOUNT_TOKEN",
                "-e",
                "GRAFANA_USERNAME",
                "-e",
                "GRAFANA_PASSWORD",
                "-e",
                "GRAFANA_ORG_ID",
                "docker.io/grafana/mcp-grafana:2.1.1"
            ],
            "env": {
                "GRAFANA_URL": "<GRAFANA_URL>",
                "GRAFANA_SERVICE_ACCOUNT_TOKEN": "<GRAFANA_SERVICE_ACCOUNT_TOKEN>",
                "GRAFANA_USERNAME": "<GRAFANA_USERNAME>",
                "GRAFANA_PASSWORD": "<GRAFANA_PASSWORD>",
                "GRAFANA_ORG_ID": "<GRAFANA_ORG_ID>"
            }
        }
    }
}
```
Replace <…> with your own values. 2 more environment variables are in the server README

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "mcp-grafana": {
            "type": "http",
            "url": "https://mcp.grafana.com/mcp"
        }
    }
}
```
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "mcp-grafana": {
            "type": "stdio",
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-e",
                "GRAFANA_URL",
                "-e",
                "GRAFANA_SERVICE_ACCOUNT_TOKEN",
                "-e",
                "GRAFANA_USERNAME",
                "-e",
                "GRAFANA_PASSWORD",
                "-e",
                "GRAFANA_ORG_ID",
                "docker.io/grafana/mcp-grafana:2.1.1"
            ],
            "env": {
                "GRAFANA_URL": "<GRAFANA_URL>",
                "GRAFANA_SERVICE_ACCOUNT_TOKEN": "<GRAFANA_SERVICE_ACCOUNT_TOKEN>",
                "GRAFANA_USERNAME": "<GRAFANA_USERNAME>",
                "GRAFANA_PASSWORD": "<GRAFANA_PASSWORD>",
                "GRAFANA_ORG_ID": "<GRAFANA_ORG_ID>"
            }
        }
    }
}
```
Replace <…> with your own values. 2 more environment variables are in the server README

### Gemini CLI

1. **Platform CLI: remote server**
```bash
gemini mcp add -t http mcp-grafana https://mcp.grafana.com/mcp
```

2. **Platform CLI**
```bash
gemini mcp add -e GRAFANA_URL=<GRAFANA_URL> -e GRAFANA_SERVICE_ACCOUNT_TOKEN=<GRAFANA_SERVICE_ACCOUNT_TOKEN> -e GRAFANA_USERNAME=<GRAFANA_USERNAME> -e GRAFANA_PASSWORD=<GRAFANA_PASSWORD> -e GRAFANA_ORG_ID=<GRAFANA_ORG_ID> mcp-grafana docker run -i --rm -e GRAFANA_URL -e GRAFANA_SERVICE_ACCOUNT_TOKEN -e GRAFANA_USERNAME -e GRAFANA_PASSWORD -e GRAFANA_ORG_ID docker.io/grafana/mcp-grafana:2.1.1
```
Replace <…> with your own values. 2 more environment variables are in the server README

## When to use it
- find a dashboard by tag or folder without opening a browser
- pull every panel and its query out of a dashboard
- run a PromQL query and read the metric values
- inspect Loki log patterns over a time range
- patch one dashboard setting without loading the full JSON

## Example prompts
- Find dashboards tagged `payments` and show a summary of each
- Run a PromQL range query for `http_requests_total` over the last hour
- Show Loki log patterns for the `checkout` service

## Similar
- [grafana-oss](https://affpapa.org/en/nevibecode/skills/grafana-oss.md) — skill · 5600 installs
- [grafana-dashboard](https://affpapa.org/en/nevibecode/skills/grafana-dashboard.md) — skill · 494 installs
- [grafana](https://affpapa.org/en/nevibecode/rules/grafana.md) — rule · ★ 3579

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
