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
Provider
Grafana Labs
Release date
Mar 18, 2025
Language
Go
Stats
588 stars

The Grafana MCP server enables you to access your Grafana instance and ecosystem through the Model Context Protocol. It provides various features like searching dashboards, getting datasource information, querying Prometheus and Loki data, managing incidents, and accessing Grafana OnCall functionality.

Installation

Prerequisites

  • A Grafana instance with appropriate access
  • A service account token with required permissions

Step 1: Create a Service Account

Create a service account in Grafana with sufficient permissions for the tools you want to use:

  1. Follow the Grafana documentation to create a service account
  2. Generate a service account token
  3. Copy the token for use in the configuration file

Step 2: Install the MCP Server

Download and install the Grafana MCP server using one of these methods:

Option 1: Download pre-built binary Download the latest release from the releases page and place it in your $PATH.

Option 2: Install with Go If you have the Go toolchain installed:

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

Configuration

Client Configuration

Add the server configuration to your MCP client configuration file. For Claude Desktop:

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

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

Debug Mode

Enable debug mode to get detailed logging of HTTP requests and responses:

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

Available Tools

The MCP server provides various tools to interact with your Grafana instance, organized by category:

Search and Dashboard Tools

  • search_dashboards: Search for dashboards
  • get_dashboard_by_uid: Get a dashboard by UID

Datasource Tools

  • list_datasources: List all available datasources
  • get_datasource_by_uid: Get datasource details by UID
  • get_datasource_by_name: Get datasource details by name

Prometheus Tools

  • query_prometheus: Execute a query against a Prometheus datasource
  • list_prometheus_metric_metadata: List metric metadata
  • list_prometheus_metric_names: List available metric names
  • list_prometheus_label_names: List label names matching a selector
  • list_prometheus_label_values: List values for a specific label

Loki Tools

  • query_loki_logs: Query and retrieve logs using LogQL
  • list_loki_label_names: List all available label names in logs
  • list_loki_label_values: List values for a specific log label
  • query_loki_stats: Get statistics about log streams

Incident Management

  • list_incidents: List incidents in Grafana Incident
  • create_incident: Create an incident in Grafana Incident
  • add_activity_to_incident: Add an activity item to an incident
  • resolve_incident: Resolve an incident in Grafana Incident

Alerting

  • list_alert_rules: List alert rules
  • get_alert_rule_by_uid: Get alert rule by UID

OnCall Tools

  • list_oncall_schedules: List schedules from Grafana OnCall
  • get_oncall_shift: Get details for a specific OnCall shift
  • get_current_oncall_users: Get users currently on-call for a specific schedule
  • list_oncall_teams: List teams from Grafana OnCall
  • list_oncall_users: List users from Grafana OnCall

Sift Investigation Tools

  • get_investigation: Retrieve an existing Sift investigation by its UUID
  • get_analysis: Retrieve a specific analysis from a Sift investigation
  • list_investigations: Retrieve a list of Sift investigations with an optional limit
  • find_error_pattern_logs: Find elevated error patterns in Loki logs
  • find_slow_requests: Find slow requests from tempo datasources

Customizing Available Tools

You can disable specific categories of tools to optimize context window usage or restrict functionality:

mcp-grafana --disable-oncall

This example disables the OnCall tools. You can use similar flags for other categories:

  • --disable-search
  • --disable-dashboard
  • --disable-datasources
  • --disable-prometheus
  • --disable-incident
  • --disable-loki
  • --disable-alerting
  • --disable-sift

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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