A Model Context Protocol (MCP) server focused on Grafana. It enables an agent to explore and operate Grafana by searching dashboards, reading the dashboard JSON model, listing datasources, querying those datasources using PromQL/LogQL/SQL, and inspecting alerts.
๐ ๏ธ Key Features
Search Grafana dashboards
Read the dashboard JSON model
List datasources
Query datasources via PromQL, LogQL, and SQL
Inspect alerts
๐ Use Cases
Finding relevant Grafana dashboards during investigation
Retrieving dashboard configuration via its JSON model
Running datasource queries for metrics, logs, or SQL-backed data
Checking alert definitions or related alert information
โก Developer Benefits
Uses MCP to connect an agent to Grafana operations
Supports multiple query languages (PromQL/LogQL/SQL) for datasource access
Provides structured access to dashboard JSON and alerts
โ ๏ธ Limitations
Server scope is Grafana-specific; it does not describe support for non-Grafana systems
A safe-by-defaultModel Context Protocol server for Grafana. It lets an agent explore and operate Grafana โ search dashboards, read the dashboard JSON model, list and query datasources (Prometheus / Loki / SQL), inspect alert rules and annotations, and (in higher modes) create/update dashboards and folders, write annotations, and delete.
You need a Grafana service account token (Administration โ Service accounts โ Add service account โ Add token). Give it the least role that works โ Viewer for read-only use, Editor to create/update, Admin only if you must delete.
See docs/CLIENTS.md for Claude Code / Cursor / Codex / VS Code / Windsurf snippets, and .env.example for every supported variable.
Safe by default
The access model is enforced by src/security.ts โ defence in depth on top of the service-account token's own role:
GRAFANA_MODE โ read-only (default) โ read-write โ admin. A tool is registered only if the mode allows its capability. Read-only exposes the 11 read tools; edits need read-write; deletes need admin.
GRAFANA_ALLOW_DELETE โ deletes are irreversible, so on top of admin mode they also require this flag.
GRAFANA_FOLDER_ALLOWLIST / GRAFANA_PROTECTED_FOLDERS โ confine which folders can be written to; mark folders (e.g. production) that may be read but never modified or deleted.
GRAFANA_DATASOURCE_ALLOWLIST โ restrict which datasources query_datasource may hit.
GRAFANA_DRY_RUN โ validate and log writes without executing them.
GRAFANA_AUDIT_LOG โ a JSON audit line per guarded operation, on stderr (default on).
Interactive confirmation โ when the client supports MCP elicitation, deleting a dashboard/folder/annotation prompts the human to approve before it runs; clients that can't elicit fall back to the GRAFANA_ALLOW_DELETE gate.
Secrets are never returned โ datasource secureJsonData, passwords and tokens are stripped from every response.
Conventions for the dashboard JSON model, panel/target shapes, PromQL/LogQL/SQL query patterns, folder organisation and safe editing live in the bundled skill: .claude/skills/grafana-dashboards-and-queries/SKILL.md. Agents that load it can build and edit dashboards to a consistent standard without being re-taught each time.
Developing
bash
npm install
npm run build
GRAFANA_URL=http://localhost:3000 GRAFANA_TOKEN=glsa_โฆ node dist/index.js
# introspect without a live Grafana:echo'{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | GRAFANA_TOKEN=x node dist/index.js
Licence
MIT
Install
Configuration
Environment variables
GRAFANA_URL
Base URL of the Grafana instance (e.g. http://localhost:3000).
GRAFANA_TOKENrequiredsecret
Grafana service-account token (Bearer). Use a Viewer-role account for read-only use.