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.0K stars

The Grafana MCP server provides access to your Grafana instance and ecosystem through the Model Context Protocol (MCP). It allows AI assistants and other tools to interact with Grafana dashboards, metrics, logs, incidents, and more.

Installation Options

Using Docker

The Docker image offers three operating modes:

STDIO Mode (for direct integration with AI assistants)

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

SSE Mode (HTTP server mode)

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

Streamable HTTP Mode

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

Using Prebuilt Binary

Download the latest release from the releases page and place it in your $PATH.

Building from Source

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

Configuration

Client Configuration

For Claude Desktop with Binary

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

Note: If you see Error: spawn mcp-grafana ENOENT, specify the full path to mcp-grafana.

For Claude Desktop with Docker

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

VSCode with Remote MCP Server

When using VSCode with an MCP server in SSE mode, include this in your .vscode/settings.json:

"mcp": {
  "servers": {
    "grafana": {
      "type": "sse",
      "url": "http://localhost:8000/sse"
    }
  }
}

Advanced Configuration

Debug Mode

Add the -debug flag to see detailed HTTP request/response logs:

With Binary

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

With Docker

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

TLS Configuration

For Grafana instances requiring custom TLS:

  • --tls-cert-file: Path to client certificate
  • --tls-key-file: Path to client private key
  • --tls-ca-file: Path to CA certificate
  • --tls-skip-verify: Skip certificate verification (for testing only)

With Client Certificate Authentication

{
  "mcpServers": {
    "grafana": {
      "command": "mcp-grafana",
      "args": [
        "--tls-cert-file", "/path/to/client.crt",
        "--tls-key-file", "/path/to/client.key",
        "--tls-ca-file", "/path/to/ca.crt"
      ],
      "env": {
        "GRAFANA_URL": "https://secure-grafana.example.com",
        "GRAFANA_API_KEY": "<your service account token>"
      }
    }
  }
}

With Docker and TLS

{
  "mcpServers": {
    "grafana": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-v", "/path/to/certs:/certs:ro",
        "-e", "GRAFANA_URL",
        "-e", "GRAFANA_API_KEY",
        "mcp/grafana",
        "-t", "stdio",
        "--tls-cert-file", "/certs/client.crt",
        "--tls-key-file", "/certs/client.key",
        "--tls-ca-file", "/certs/ca.crt"
      ],
      "env": {
        "GRAFANA_URL": "https://secure-grafana.example.com",
        "GRAFANA_API_KEY": "<your service account token>"
      }
    }
  }
}

Available Features

Dashboards

  • Search for dashboards
  • Get dashboard by UID
  • Update or create dashboards
  • Get panel queries and datasource info

Datasources

  • List and fetch datasource information
  • Support for Prometheus and Loki datasources

Prometheus Querying

  • Execute PromQL queries
  • Retrieve metric metadata and names
  • Get label names and values

Loki Querying

  • Run log and metric queries with LogQL
  • Retrieve label metadata and stream statistics

Incidents

  • Search, create, update, and close incidents

Sift Investigations

  • Create and manage Sift investigations
  • Find error patterns in logs
  • Detect slow requests

Alerting

  • List and fetch alert rule information
  • View notification contact points

Grafana OnCall

  • Manage on-call schedules
  • Get shift details and current on-call users
  • List teams and users

Admin

  • List all configured teams

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