Mcp Grafana

io.github.dockndevaiPublished by GitHub account dockndevaiv0.3.3Updated Oct 27, 2026

Search & edit Grafana dashboards, query datasources (PromQL/LogQL/SQL), inspect alerts.

VerifiedSTDIODesktop onlySecurity & MonitoringData & Analytics

Overview

AI-generated overview

Local MCP server for Grafana: lets an assistant search and read dashboards, query Prometheus/Loki/SQL datasources, and inspect alerts and annotations.

What you can do
  • Check instance health and version
  • Search and list dashboards and folders, and read a dashboard's full JSON model
  • List datasources and run PromQL, LogQL or SQL queries through the unified query API
  • List Grafana-managed alert rules and annotations
  • In read-write mode, create or update dashboards, create folders and write annotations
  • In admin mode with an extra delete flag, delete dashboards, folders and annotations
When to use it
Useful when an assistant should work with an existing Grafana instance: finding dashboards, reading their JSON, running metric or log queries, checking alert rules, or maintaining dashboards and annotations. It starts read-only, so it also suits teams that only want inspection.
Requirements
Runs locally via npx from the npm package. Needs GRAFANA_URL pointing at the Grafana instance and a Grafana service-account token in GRAFANA_TOKEN, plus network access to that instance. GRAFANA_MODE selects read-only (default), read-write or admin; deletes additionally need GRAFANA_ALLOW_DELETE.
Before you install
Requires a Grafana service-account token; grant the least role that works (Viewer for read-only). Read-write mode can create or change dashboards, folders and annotations, and admin mode with the delete flag can irreversibly delete them. Optional folder and datasource allowlists, protected folders, dry-run and audit logging exist but are not on by default. Datasource secrets are stripped from responses.

Installation

In SourceWeft

  1. Open Mcp Grafana in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

mcp-grafana

[npm] [CI] [licence]

A safe-by-default Model 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.

Part of the dockndevai MCP server suite — one governance model across all of them.

[mcp-grafana — safe by default: read-only exposes 11 tools; raising the access mode unlocks writes and (gated) deletes]

What it gives an agent

The server starts read-only (see Safe by default); higher-capability tools are only registered when you raise the mode.

ToolForNeeds mode
get_healthcheck the instance is up, versionread-only
searchfind dashboards & folders by name/tag (get UIDs)read-only
list_dashboards / list_foldersenumerate dashboards / foldersread-only
get_dashboardthe full dashboard JSON model + metaread-only
list_datasources / get_datasourcedatasources (secrets redacted)read-only
query_datasourcerun PromQL / LogQL / SQL via the unified query APIread-only
list_alert_rulesGrafana-managed alert rulesread-only
list_annotationsevents overlaid on graphsread-only
create_or_update_dashboardupsert a dashboard (versioned, reversible)read-write
create_foldercreate a folderread-write
create_annotationmark a deploy/incident on graphsread-write
delete_dashboard / delete_folder / delete_annotationdelete (irreversible)admin + GRAFANA_ALLOW_DELETE

Install

bash
npx -y @dockndevai/mcp-grafana

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.

Configure

json
{  "mcpServers": {    "grafana": {      "command": "npx",      "args": ["-y", "@dockndevai/mcp-grafana"],      "env": {        "GRAFANA_URL": "http://localhost:3000",        "GRAFANA_TOKEN": "glsa_...",        "GRAFANA_MODE": "read-only"      }    }  }}

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.

[Interactive confirmation — the agent asks to delete a dashboard; the server pauses and asks the human via MCP elicitation. Declining leaves the dashboard untouched; approving proceeds.]

See SECURITY.md.

Working with dashboards & queries

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 installnpm run buildGRAFANA_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

Source: README.md at commit 3216c7b

Tools

11

get_health

Grafana health

Check the Grafana instance is reachable and return its version and database status.

Takes no parameters.

list_dashboards

List dashboards

List dashboards (optionally filtered by tag). Shorthand for search with type=dash-db.

Parameterstaglimit

get_dashboard

Get dashboard

Return the full dashboard JSON model (panels, targets, templating, time) plus meta (folder, version, url) for a dashboard UID. This is the model you edit and pass back to create_or_update_dashboard.

Parametersuidrequired

list_folders

List folders

List dashboard folders with their UIDs and titles.

Takes no parameters.

get_folder

Get folder

Return a folder's details by UID.

Parametersuidrequired

list_datasources

List datasources

List configured datasources (uid, name, type, url). Secrets (secureJsonData, passwords, tokens) are never returned. Use the uid with query_datasource.

Takes no parameters.

get_datasource

Get datasource

Return a single datasource by UID (secrets redacted).

Parametersuidrequired

query_datasource

Query a datasource

Run a query against a datasource through Grafana's unified query API and return the result frames. For Prometheus/Loki set `expr` (PromQL / LogQL); for SQL datasources set `rawSql`. Reading data only — this never mutates anything. Use a bounded time range and a small maxDataPoints to keep results manageable.

ParameterstoexprfromrawSqldatasourceUidrequiredmaxDataPoints

list_alert_rules

List alert rules

List Grafana-managed alert rules (via the provisioning API): title, condition, folder, state.

Takes no parameters.

list_annotations

List annotations

List annotations (events overlaid on graphs), optionally within a time range or by tag.

Parameterstofromtagslimit

Version history

3
  1. v0.3.3LatestOct 26, 2026
  2. v0.3.0Sep 29, 2026
  3. v0.2.3Sep 16, 2026

Score

90% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts
  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listedRequired15 pts
  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts