io.github.dockndevai/mcp-grafana

Official registry Data and databases

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

Install

Add this to your client's MCP configuration (Claude Desktop: claude_desktop_config.json; Cursor: .cursor/mcp.json; VS Code and others use the same "mcpServers" shape).

NPM package @dockndevai/mcp-grafana
Claude Code
claude mcp add mcp-grafana -e 'GRAFANA_URL=<GRAFANA_URL>' -e 'GRAFANA_TOKEN=<your grafana_token>' -e 'GRAFANA_MODE=<GRAFANA_MODE>' -- npx -y @dockndevai/mcp-grafana@0.3.3
JSON configuration (Claude Desktop, Cursor, VS Code)
{
    "mcpServers": {
        "mcp-grafana": {
            "command": "npx",
            "args": [
                "-y",
                "@dockndevai/mcp-grafana@0.3.3"
            ],
            "env": {
                "GRAFANA_URL": "<GRAFANA_URL>",
                "GRAFANA_TOKEN": "<your grafana_token>",
                "GRAFANA_MODE": "<GRAFANA_MODE>"
            }
        }
    }
}

Environment variables

  • GRAFANA_URL Base URL of the Grafana instance (e.g. http://localhost:3000).
  • GRAFANA_TOKEN required secret Grafana service-account token (Bearer). Use a Viewer-role account for read-only use.
  • GRAFANA_MODE Access mode: read-only | read-write | admin. Starts read-only; writes need read-write.

Documentation

From the project's README on GitHub, refreshed weekly. Links open on GitHub.

Contents
  1. mcp-grafana
  2. What it gives an agent
  3. Install
  4. Configure
  5. Safe by default
  6. Working with dashboards & queries
  7. Developing
  8. Licence

mcp-grafana

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.

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

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

{
  "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.

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

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

Frequently asked questions

What is io.github.dockndevai/mcp-grafana?

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

How do I install io.github.dockndevai/mcp-grafana?

It runs on your machine. In Claude Code: claude mcp add mcp-grafana -e 'GRAFANA_URL=<GRAFANA_URL>' -e 'GRAFANA_TOKEN=<your grafana_token>' -e 'GRAFANA_MODE=<GRAFANA_MODE>' -- npx -y @dockndevai/mcp-grafana@0.3.3. For other clients, paste the JSON configuration from this page into their MCP settings.

Does io.github.dockndevai/mcp-grafana need an API key?

Yes. It expects GRAFANA_TOKEN, which you set in its configuration.

Is io.github.dockndevai/mcp-grafana open source?

Yes. Its code is on GitHub under the MIT license.

Who maintains io.github.dockndevai/mcp-grafana?

It is published by dockndevai. AI.tn lists it but does not maintain or endorse it.

From the official MCP Registry. Listing is not an endorsement: review a server's code and permissions before giving it access to your data.