The Grafana MCP server provides a powerful interface for interacting with Grafana instances through the Model Context Protocol. This tool enables you to access dashboards, metrics, logs, and other Grafana resources programmatically.
You can install the Grafana MCP server using one of several methods:
docker pull mcp/grafana
For STDIO mode (recommended for direct integration with AI assistants):
docker run --rm -i \
-e GRAFANA_URL=http://localhost:3000 \
-e GRAFANA_SERVICE_ACCOUNT_TOKEN=<your-token> \
mcp/grafana -t stdio
For SSE mode:
docker run --rm -p 8000:8000 \
-e GRAFANA_URL=http://localhost:3000 \
-e GRAFANA_SERVICE_ACCOUNT_TOKEN=<your-token> \
mcp/grafana
For Streamable HTTP mode:
docker run --rm -p 8000:8000 \
-e GRAFANA_URL=http://localhost:3000 \
-e GRAFANA_SERVICE_ACCOUNT_TOKEN=<your-token> \
mcp/grafana -t streamable-http
Download the latest release from the releases page and add it to your PATH.
GOBIN="$HOME/go/bin" go install github.com/grafana/mcp-grafana/cmd/mcp-grafana@latest
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
You can authenticate with Grafana using either:
Service account token (recommended):
GRAFANA_SERVICE_ACCOUNT_TOKEN=<your-token>
Username and password:
GRAFANA_USERNAME=<your-username>
GRAFANA_PASSWORD=<your-password>
For Claude Desktop, add this to your configuration:
{
"mcpServers": {
"grafana": {
"command": "mcp-grafana",
"args": [],
"env": {
"GRAFANA_URL": "http://localhost:3000",
"GRAFANA_SERVICE_ACCOUNT_TOKEN": "<your-token>"
}
}
}
}
For Docker with Claude Desktop:
{
"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>"
}
}
}
}
Specify which organization to interact with:
GRAFANA_ORG_ID=1
For client certificates when connecting to Grafana:
mcp-grafana \
--tls-cert-file /path/to/client.crt \
--tls-key-file /path/to/client.key \
--tls-ca-file /path/to/ca.crt
For HTTPS when using streamable HTTP transport:
mcp-grafana \
-t streamable-http \
--server.tls-cert-file /path/to/server.crt \
--server.tls-key-file /path/to/server.key \
-addr :8443
The Grafana MCP server provides access to numerous Grafana features:
Each tool requires specific RBAC permissions. For example:
dashboards:read or dashboards:writedatasources:read or datasources:queryalert.rules:readYou can disable specific tool categories using flags like --disable-dashboard or --disable-write (for read-only mode).
Enable detailed logging with the --debug flag:
mcp-grafana --debug
When using SSE or streamable HTTP transport, access the health endpoint:
GET /healthz
If you encounter datasource API errors with the message "id is invalid", you likely need to upgrade to Grafana version 9.0 or later.
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.
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 > 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>"
}
}
}
}
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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. 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