SuperAPIAI Directory

mcp-grafana

github.com · AI coding

Safe-by-default MCP server for Grafana: search & read dashboards and the dashboard JSON model, query datasources (Prometheus/Loki/SQL via the unified query API), and inspect alert rules & annotations; in

Open website Alternatives
PricingOpen source开源项目(可免费自部署)

About this tool

mcp-grafana is a Model Context Protocol (MCP) server for Grafana that focuses on being "secure by default". It enables AI agents to explore and operate Grafana instances and is part of the dockndevai MCP server suite, which uses a unified governance model.

Purpose

Help agents access Grafana under controlled conditions: search dashboards, read dashboard JSON models, list and query data sources (Prometheus / Loki / SQL), and view alert rules and annotations; in higher-privilege modes, it can also create/update dashboards and folders, write annotations, and perform deletions.

Main capabilities

  • Dashboards: search dashboards, read dashboard JSON models, and create or update dashboards in higher modes.
  • Data source queries: list and query data sources, supporting Prometheus, Loki, and SQL through a unified query API.
  • Alerts and annotations: view alert rules and annotations, and write annotations in higher modes.
  • Folder management: create/update folders in higher modes.
  • Delete operations: available only in admin mode and after delete permission is explicitly enabled.

Usage

  1. A Grafana service account token is required (Administration → Service accounts → Add service account → Add token). Roles should be assigned according to the principle of least privilege: Viewer for read-only, Editor for create/update, and Admin only when deletion is necessary.
  2. The server starts in read-only mode by default and registers only read-only tools (11 read tools in total). Editing tools require read-write mode, and delete tools require admin mode.
  3. For client configuration examples, see docs/CLIENTS.md (covering Claude Code / Cursor / Codex / VS Code / Windsurf); for all supported environment variables, see .env.example.

Security model (Safe by default)

The access model is enforced by src/security.ts, providing multiple layers of defense on top of the service account token's own role:

  • GRAFANA_MODE: read-only (default) → read-write → admin. Only tools allowed by the current mode are registered.
  • GRAFANA_ALLOW_DELETE: Deletion is irreversible, so this flag is additionally required on top of admin mode.
  • GRAFANA_FOLDER_ALLOWLIST / GRAFANA_PROTECTED_FOLDERS: Restrict which folders can be written to; certain folders (such as production) can be marked as readable but not modifiable or deletable.
  • GRAFANA_DATASOURCE_ALLOWLIST: Restrict which data sources query_datasource can access.
  • GRAFANA_DRY_RUN: Validate and log write operations without actually executing them.
  • GRAFANA_AUDIT_LOG: Output a one-line JSON audit log to stderr for each protected operation (enabled by default).
  • Interactive confirmation: When the client supports MCP elicitation, deleting dashboards/folders/annotations first prompts for human approval; clients that do not support elicitation fall back to the GRAFANA_ALLOW_DELETE gate.
  • Secrets are never returned: A data source's secureJsonData, passwords, and tokens are stripped from every response.

Dashboard and Query Conventions

Conventions for the dashboard JSON model, panel/target structures, PromQL/LogQL/SQL query patterns, folder organization, and safe editing are packaged in the skill file .claude/skills/grafana-dashboards-and-queries/SKILL.md. Agents that load this skill can build and edit dashboards according to a unified standard without having to relearn it each time.

Applicable Scenarios

Suitable for development and operations scenarios that require AI agents to securely access Grafana observability data, such as querying metrics and logs, inspecting alert rules, and generating or modifying dashboards according to specifications, while controlling the scope of operations through modes, allowlists, dry runs, and audit logs.

Limitations

The repository materials do not provide specific installation commands, dependency versions, supported platforms, or pricing information; these are not yet available. Deletion operations are irreversible, and even in admin mode an additional flag is required and, when supported, human confirmation is required. Actual write capability is doubly restricted by the service account role and the various allowlists.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools