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.
Create a service account in Grafana with sufficient permissions for the tools you want to use:
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
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 themcp-grafana
executable.
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>"
}
}
}
}
The MCP server provides various tools to interact with your Grafana instance, organized by category:
search_dashboards
: Search for dashboardsget_dashboard_by_uid
: Get a dashboard by UIDlist_datasources
: List all available datasourcesget_datasource_by_uid
: Get datasource details by UIDget_datasource_by_name
: Get datasource details by namequery_prometheus
: Execute a query against a Prometheus datasourcelist_prometheus_metric_metadata
: List metric metadatalist_prometheus_metric_names
: List available metric nameslist_prometheus_label_names
: List label names matching a selectorlist_prometheus_label_values
: List values for a specific labelquery_loki_logs
: Query and retrieve logs using LogQLlist_loki_label_names
: List all available label names in logslist_loki_label_values
: List values for a specific log labelquery_loki_stats
: Get statistics about log streamslist_incidents
: List incidents in Grafana Incidentcreate_incident
: Create an incident in Grafana Incidentadd_activity_to_incident
: Add an activity item to an incidentresolve_incident
: Resolve an incident in Grafana Incidentlist_alert_rules
: List alert rulesget_alert_rule_by_uid
: Get alert rule by UIDlist_oncall_schedules
: List schedules from Grafana OnCallget_oncall_shift
: Get details for a specific OnCall shiftget_current_oncall_users
: Get users currently on-call for a specific schedulelist_oncall_teams
: List teams from Grafana OnCalllist_oncall_users
: List users from Grafana OnCallget_investigation
: Retrieve an existing Sift investigation by its UUIDget_analysis
: Retrieve a specific analysis from a Sift investigationlist_investigations
: Retrieve a list of Sift investigations with an optional limitfind_error_pattern_logs
: Find elevated error patterns in Loki logsfind_slow_requests
: Find slow requests from tempo datasourcesYou 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
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.
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"
]
}
}
}
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.
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.