Grafana MCP server

Integrates with Grafana to enable searching dashboards, fetching datasource information, querying Prometheus metrics, and managing incidents through both stdio and SSE transport modes.
Back to servers
Setup instructions
Provider
Grafana Labs
Release date
Mar 18, 2025
Language
Go
Stats
1.9K stars

The Grafana MCP server provides a protocol interface to interact with your Grafana instance and its ecosystem through the Model Context Protocol (MCP). This tool allows AI assistants and other clients to connect to your Grafana data sources and dashboards.

Installation

Prerequisites

  • Grafana version 9.0 or later for full functionality
  • Service account with appropriate permissions (or username/password)

Installation Options

Using Docker

The Docker image defaults to SSE mode, but most users will want STDIO mode for direct integration with AI assistants:

STDIO Mode (recommended for Claude Desktop):

docker pull mcp/grafana
docker run --rm -i \
  -e GRAFANA_URL=http://localhost:3000 \
  -e GRAFANA_SERVICE_ACCOUNT_TOKEN=<your-token> \
  mcp/grafana -t stdio

SSE Mode (for HTTP clients):

docker pull mcp/grafana
docker run --rm -p 8000:8000 \
  -e GRAFANA_URL=http://localhost:3000 \
  -e GRAFANA_SERVICE_ACCOUNT_TOKEN=<your-token> \
  mcp/grafana

Streamable HTTP Mode (for multiple clients):

docker pull mcp/grafana
docker run --rm -p 8000:8000 \
  -e GRAFANA_URL=http://localhost:3000 \
  -e GRAFANA_SERVICE_ACCOUNT_TOKEN=<your-token> \
  mcp/grafana -t streamable-http

Using Binary

Download the latest binary from the releases page.

Building from Source

GOBIN="$HOME/go/bin" go install github.com/grafana/mcp-grafana/cmd/mcp-grafana@latest

Using Helm for Kubernetes

helm repo add grafana https://grafana.github.io/helm-charts
helm install --set grafana.apiKey=<Grafana_ApiKey> --set grafana.url=<GrafanaUrl> my-release grafana/grafana-mcp

Configuration

Claude Desktop Configuration

Add this to your Claude Desktop configuration:

{
  "mcpServers": {
    "grafana": {
      "command": "mcp-grafana",
      "args": [],
      "env": {
        "GRAFANA_URL": "http://localhost:3000",
        "GRAFANA_SERVICE_ACCOUNT_TOKEN": "<your-token>"
      }
    }
  }
}

For Docker, use:

{
  "mcpServers": {
    "grafana": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "GRAFANA_URL",
        "-e", "GRAFANA_SERVICE_ACCOUNT_TOKEN",
        "mcp/grafana", "-t", "stdio"
      ],
      "env": {
        "GRAFANA_URL": "http://localhost:3000",
        "GRAFANA_SERVICE_ACCOUNT_TOKEN": "<your-token>"
      }
    }
  }
}

Multi-Organization Support

Specify an organization ID using:

"env": {
  "GRAFANA_URL": "http://localhost:3000",
  "GRAFANA_SERVICE_ACCOUNT_TOKEN": "<your-token>",
  "GRAFANA_ORG_ID": "2"
}

Debug Mode

Enable debug logging with the -debug flag:

"args": ["-debug"]

TLS Configuration

For secure Grafana instances:

"args": [
  "--tls-cert-file", "/path/to/client.crt",
  "--tls-key-file", "/path/to/client.key",
  "--tls-ca-file", "/path/to/ca.crt"
]

Usage Examples

Dashboard Operations

  • Search dashboards
  • Get dashboard details
  • Update dashboards
  • Extract specific dashboard properties using JSONPath

Prometheus Queries

  • Execute PromQL queries against Prometheus data sources
  • Retrieve metric metadata, names, and label information

Loki Log Queries

  • Query logs using LogQL
  • List label names and values
  • Get log stream statistics

Alerting Operations

  • List alert rules
  • Get alert rule details
  • List notification contact points

Incident Management

  • List, create, and update incidents in Grafana Incident
  • Add activities to incidents

Many More Features

The MCP server includes tools for:

  • OnCall schedules and alerts
  • Sift investigations
  • Annotations
  • Datasource management
  • Admin operations (teams, users)
  • Navigation and deep linking

Controlling Available Tools

Disable specific tool categories with flags:

mcp-grafana --disable-write --disable-oncall

For read-only mode that prevents any modifications:

mcp-grafana --disable-write

Troubleshooting

If you see errors with datasource operations mentioning "id is invalid", you're likely using a Grafana version earlier than 9.0. Upgrade to at least Grafana 9.0 for full compatibility.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "grafana" '{"command":"mcp-grafana","args":[],"env":{"GRAFANA_URL":"http://localhost:3000","GRAFANA_API_KEY":"<your service account token>"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "grafana": {
            "command": "mcp-grafana",
            "args": [],
            "env": {
                "GRAFANA_URL": "http://localhost:3000",
                "GRAFANA_API_KEY": "<your service account token>"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "grafana": {
            "command": "mcp-grafana",
            "args": [],
            "env": {
                "GRAFANA_URL": "http://localhost:3000",
                "GRAFANA_API_KEY": "<your service account token>"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later