/ Directory / Playground / Grafana MCP
● Official grafana 🔑 Needs your key

Grafana MCP

by grafana · grafana/mcp-grafana

The official Grafana MCP — query Prometheus/Loki/Tempo, list dashboards, fetch alerts, run incident timelines, all behind one stdio server.

Grafana's first-party MCP server connects to your Grafana stack (OSS, Cloud, or Enterprise) and exposes its data sources + management API as MCP tools. You get Prometheus/Loki/Tempo queries, dashboard discovery, alert state, OnCall, and Sift investigations — anything Grafana can do, Claude can ask.

Why use it

Key features

Live Demo

What it looks like in practice

mcp-grafana.replay ▶ ready
0/0

Install

Pick your client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "mcp-grafana": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GRAFANA_URL",
        "-e",
        "GRAFANA_API_KEY",
        "mcp/grafana",
        "-t",
        "stdio"
      ],
      "env": {
        "GRAFANA_URL": "https://your-grafana.example.com",
        "GRAFANA_API_KEY": "${GRAFANA_API_KEY}"
      }
    }
  }
}

Open Claude Desktop → Settings → Developer → Edit Config. Restart after saving.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "mcp-grafana": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GRAFANA_URL",
        "-e",
        "GRAFANA_API_KEY",
        "mcp/grafana",
        "-t",
        "stdio"
      ],
      "env": {
        "GRAFANA_URL": "https://your-grafana.example.com",
        "GRAFANA_API_KEY": "${GRAFANA_API_KEY}"
      }
    }
  }
}

Cursor uses the same mcpServers schema as Claude Desktop. Project config wins over global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "mcp-grafana": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GRAFANA_URL",
        "-e",
        "GRAFANA_API_KEY",
        "mcp/grafana",
        "-t",
        "stdio"
      ],
      "env": {
        "GRAFANA_URL": "https://your-grafana.example.com",
        "GRAFANA_API_KEY": "${GRAFANA_API_KEY}"
      }
    }
  }
}

Click the MCP Servers icon in the Cline sidebar, then "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "mcp-grafana": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GRAFANA_URL",
        "-e",
        "GRAFANA_API_KEY",
        "mcp/grafana",
        "-t",
        "stdio"
      ],
      "env": {
        "GRAFANA_URL": "https://your-grafana.example.com",
        "GRAFANA_API_KEY": "${GRAFANA_API_KEY}"
      }
    }
  }
}

Same shape as Claude Desktop. Restart Windsurf to pick up changes.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "mcp-grafana",
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GRAFANA_URL",
        "-e",
        "GRAFANA_API_KEY",
        "mcp/grafana",
        "-t",
        "stdio"
      ]
    }
  ]
}

Continue uses an array of server objects rather than a map.

~/.config/zed/settings.json
{
  "context_servers": {
    "mcp-grafana": {
      "command": {
        "path": "docker",
        "args": [
          "run",
          "-i",
          "--rm",
          "-e",
          "GRAFANA_URL",
          "-e",
          "GRAFANA_API_KEY",
          "mcp/grafana",
          "-t",
          "stdio"
        ]
      }
    }
  }
}

Add to context_servers. Zed hot-reloads on save.

claude mcp add mcp-grafana -- docker run -i --rm -e GRAFANA_URL -e GRAFANA_API_KEY mcp/grafana -t stdio

One-liner. Verify with claude mcp list. Remove with claude mcp remove.

Use Cases

Real-world ways to use Grafana MCP

Build an incident timeline from Grafana data

👤 SREs / on-call ⏱ ~10 min intermediate

When to use: Pager just fired; you want a coherent timeline before joining the call.

Prerequisites
  • Grafana service-account token — Grafana → Administration → Service accounts; Editor role is enough for queries
Flow
  1. What's firing
    Grafana: list firing alerts in the last 30 minutes for service=checkout.✓ Copied
    → list_alerts returns 1+ alerts with timestamps
  2. Pull the metric
    For each alert, run a Prometheus range query for the underlying metric over the last 1h. Note the breach time.✓ Copied
    → query_prometheus_range returns time series
  3. Pull logs at breach
    Loki: logs for service=checkout, level=error, [breach_time-2m, breach_time+2m]. Top patterns.✓ Copied
    → Log lines clustered by signature
  4. Compose timeline
    Build a concise timeline: alert fired → metric breach → top 3 error log patterns. Markdown for Slack.✓ Copied
    → Timeline ready to paste

Outcome: Coherent incident timeline assembled before you join the call.

Pitfalls
  • Loki query too broad → blows token budget — Always include service= label; limit time window aggressively
  • Prometheus query has step too fine — Use step=15s or 30s for 1h windows
Combine with: sentry

Explain what a Grafana dashboard actually shows

👤 New team member onboarding ⏱ ~15 min beginner

When to use: You inherited a dashboard and want to understand it without clicking each panel.

Flow
  1. Find it
    Grafana: search dashboards titled 'Checkout SLO'.✓ Copied
    → Dashboard UID returned
  2. Inspect panels
    Get the dashboard. For each panel, summarize: title, datasource, what query it runs, what threshold (if any).✓ Copied
    → Per-panel explanation; query strings included

Outcome: Documented understanding of the dashboard ready for onboarding wiki.

Pitfalls
  • Variables substituted weirdly — Mention $service/$env interpolation is dashboard-time, not MCP-time

Audit alert rules for noise

👤 SRE leads ⏱ ~30 min intermediate

When to use: Quarterly hygiene — find rules that fire constantly or never.

Flow
  1. Pull rules
    Grafana: list all alert rules in folder Production.✓ Copied
    → Rule list with UID + expression
  2. Get fire history
    For each, count alert instances in last 30 days. Flag rules with >100 (noisy) or 0 (dormant).✓ Copied
    → Per-rule counts + flagged set
  3. Recommend
    For each flagged rule, propose a fix: tighten threshold, add for: 5m, or delete dormant.✓ Copied
    → Concrete YAML changes per rule

Outcome: Concrete cleanup plan with PR-ready YAML.

Pitfalls
  • Counting instances ≠ counting unique alerts — Group by labels; count distinct firing periods
Combine with: github

Combinations

Pair with other MCPs for X10 leverage

mcp-grafana + sentry

Cross-correlate Sentry errors with metric/log breaches

Sentry: get the spike in errors for OrderService. Grafana: pull Prometheus + Loki around the same window.✓ Copied
mcp-grafana + github

Open PR with alert-rule cleanups

Grafana: audit alert rules. GitHub: open a PR replacing the noisy rules with tightened thresholds.✓ Copied
mcp-grafana + filesystem

Save incident timeline to a Markdown post-mortem

Build a timeline from Grafana, save to /pm/2026-05-incident.md.✓ Copied

Tools

What this MCP exposes

ToolInputsWhen to callCost
list_datasources (none) First call, learn what's available 1 API call
query_prometheus datasource_uid, query, time? Instant metric value 1 call
query_prometheus_range datasource_uid, query, start, end, step Time-series investigation 1 call
query_loki_logs datasource_uid, expr, start, end, limit? Pull logs 1 call
search_dashboards query: str Find a dashboard 1 call
get_dashboard uid: str Inspect panels 1 call
list_alert_rules folder? Audit / discover 1 call
list_alert_instances state? What's firing now 1 call
list_oncall_schedules (none) Who's on call 1 call

Cost & Limits

What this costs to run

API quota
Bound by your Grafana instance limits; Cloud has org-level QPS caps
Tokens per call
300–8000 (range queries can be large)
Monetary
Free OSS; Grafana Cloud bills normally
Tip
Always pass step= on range queries; use Loki limit=100 unless you know the volume

Security

Permissions, secrets, blast radius

Minimum scopes: service-account with Viewer or Editor
Credential storage: Service account token in env var
Data egress: Only your Grafana URL
Never grant: Admin role unless you need rule mutation

Troubleshooting

Common errors and fixes

401 Unauthorized

Token wrong or service account disabled

Verify: curl -H 'Authorization: Bearer $TOKEN' $URL/api/health
Prometheus query timeout

Reduce time range or step

Loki 'parse error'

LogQL needs label filter on left of pipeline; e.g. {service="x"} |= "err"

Dashboard not found

UID changed after import; search by title first

Alternatives

Grafana MCP vs others

AlternativeWhen to use it insteadTradeoff
Direct Prometheus MCPPrometheus only, no GrafanaNo dashboards, no alerts UI integration
Datadog MCPYou're on DatadogDifferent observability stack
Loki MCP standaloneLogs onlyLess surface

More

Resources

📖 Read the official README on GitHub

🐙 Browse open issues

🔍 Browse all 400+ MCP servers and Skills