mcp-grafana — Claude Code MCP server: dashboards and metrics
Gives your agent access to Grafana: search dashboards, read panels, run PromQL and LogQL. Useful when you are chasing an incident or editing a graph from the chat.
claude mcp add --transport http mcp-grafana https://mcp.grafana.com/mcpWhat mcp-grafana does
The server connects to your Grafana instance and hands the agent tools for dashboards: search by title, folder, tag or starred status, fetch panels and their queries, list saved versions. get_dashboard_summary and get_dashboard_property with JSONPath pull only the piece you need, because the full JSON of a large dashboard eats context. Edits work too: update, create, and a targeted patch that skips loading the whole file.
Then come the data queries. Prometheus answers PromQL, instant and range, plus metric metadata and histogram percentiles via histogram_quantile. Loki takes LogQL, along with metadata and detected log patterns. Datasource listing covers Prometheus, Loki, ClickHouse, CloudWatch, Elasticsearch, OpenSearch, Snowflake and Athena. Some tools ship disabled: runpanelquery, examples, influxdb and sql need the --enabled-tools flag. SQL tools go through Grafana's datasource plugins, so the MCP server never sees your database credentials.
Grafana 9.0 or later is required — on older versions datasource operations break because the API endpoints are missing. The uvx route needs uv installed; the Docker route needs Docker. Config takes GRAFANA_URL and GRAFANA_SERVICE_ACCOUNT_TOKEN; on Grafana Cloud you point GRAFANA_URL at your instance address.
What it helps with
- find a dashboard by tag or folder without opening a browser
- pull every panel and its query out of a dashboard
- run a PromQL query and read the metric values
- inspect Loki log patterns over a time range
- patch one dashboard setting without loading the full JSON
Example prompts for the agent
- Find dashboards tagged
paymentsand show a summary of each - Run a PromQL range query for
http_requests_totalover the last hour - Show Loki log patterns for the
checkoutservice
How to install mcp-grafana
1Platform CLI: remote server
claude mcp add --transport http mcp-grafana https://mcp.grafana.com/mcp2Platform CLI
claude mcp add --env GRAFANA_URL=<GRAFANA_URL> --env GRAFANA_SERVICE_ACCOUNT_TOKEN=<GRAFANA_SERVICE_ACCOUNT_TOKEN> --env GRAFANA_USERNAME=<GRAFANA_USERNAME> --env GRAFANA_PASSWORD=<GRAFANA_PASSWORD> --env GRAFANA_ORG_ID=<GRAFANA_ORG_ID> --transport stdio mcp-grafana -- docker run -i --rm -e GRAFANA_URL -e GRAFANA_SERVICE_ACCOUNT_TOKEN -e GRAFANA_USERNAME -e GRAFANA_PASSWORD -e GRAFANA_ORG_ID docker.io/grafana/mcp-grafana:2.1.1Replace <…> with your own values. 2 more environment variables are in the server README
1Platform CLI: remote server
codex mcp add mcp-grafana --url https://mcp.grafana.com/mcp2Platform CLI
codex mcp add mcp-grafana --env GRAFANA_URL=<GRAFANA_URL> --env GRAFANA_SERVICE_ACCOUNT_TOKEN=<GRAFANA_SERVICE_ACCOUNT_TOKEN> --env GRAFANA_USERNAME=<GRAFANA_USERNAME> --env GRAFANA_PASSWORD=<GRAFANA_PASSWORD> --env GRAFANA_ORG_ID=<GRAFANA_ORG_ID> -- docker run -i --rm -e GRAFANA_URL -e GRAFANA_SERVICE_ACCOUNT_TOKEN -e GRAFANA_USERNAME -e GRAFANA_PASSWORD -e GRAFANA_ORG_ID docker.io/grafana/mcp-grafana:2.1.1Replace <…> with your own values. 2 more environment variables are in the server README
Config file
{
"mcpServers": {
"mcp-grafana": {
"url": "https://mcp.grafana.com/mcp"
}
}
}{
"mcpServers": {
"mcp-grafana": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GRAFANA_URL",
"-e",
"GRAFANA_SERVICE_ACCOUNT_TOKEN",
"-e",
"GRAFANA_USERNAME",
"-e",
"GRAFANA_PASSWORD",
"-e",
"GRAFANA_ORG_ID",
"docker.io/grafana/mcp-grafana:2.1.1"
],
"env": {
"GRAFANA_URL": "<GRAFANA_URL>",
"GRAFANA_SERVICE_ACCOUNT_TOKEN": "<GRAFANA_SERVICE_ACCOUNT_TOKEN>",
"GRAFANA_USERNAME": "<GRAFANA_USERNAME>",
"GRAFANA_PASSWORD": "<GRAFANA_PASSWORD>",
"GRAFANA_ORG_ID": "<GRAFANA_ORG_ID>"
}
}
}
}Replace <…> with your own values. 2 more environment variables are in the server README
Config file
{
"servers": {
"mcp-grafana": {
"type": "http",
"url": "https://mcp.grafana.com/mcp"
}
}
}{
"servers": {
"mcp-grafana": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GRAFANA_URL",
"-e",
"GRAFANA_SERVICE_ACCOUNT_TOKEN",
"-e",
"GRAFANA_USERNAME",
"-e",
"GRAFANA_PASSWORD",
"-e",
"GRAFANA_ORG_ID",
"docker.io/grafana/mcp-grafana:2.1.1"
],
"env": {
"GRAFANA_URL": "<GRAFANA_URL>",
"GRAFANA_SERVICE_ACCOUNT_TOKEN": "<GRAFANA_SERVICE_ACCOUNT_TOKEN>",
"GRAFANA_USERNAME": "<GRAFANA_USERNAME>",
"GRAFANA_PASSWORD": "<GRAFANA_PASSWORD>",
"GRAFANA_ORG_ID": "<GRAFANA_ORG_ID>"
}
}
}
}Replace <…> with your own values. 2 more environment variables are in the server README
1Platform CLI: remote server
gemini mcp add -t http mcp-grafana https://mcp.grafana.com/mcp2Platform CLI
gemini mcp add -e GRAFANA_URL=<GRAFANA_URL> -e GRAFANA_SERVICE_ACCOUNT_TOKEN=<GRAFANA_SERVICE_ACCOUNT_TOKEN> -e GRAFANA_USERNAME=<GRAFANA_USERNAME> -e GRAFANA_PASSWORD=<GRAFANA_PASSWORD> -e GRAFANA_ORG_ID=<GRAFANA_ORG_ID> mcp-grafana docker run -i --rm -e GRAFANA_URL -e GRAFANA_SERVICE_ACCOUNT_TOKEN -e GRAFANA_USERNAME -e GRAFANA_PASSWORD -e GRAFANA_ORG_ID docker.io/grafana/mcp-grafana:2.1.1Replace <…> with your own values. 2 more environment variables are in the server README
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about mcp-grafana
How do I install mcp-grafana in Claude Code?
Remote, one command: claude mcp add --transport http mcp-grafana https://mcp.grafana.com/mcp. Or locally via Docker: `claude mcp add --env GRAFANA_URL=<GRAFANA_URL> --env GRAFANA_SERVICE_ACCOUNT_TOKEN=<GRAFANA_SERVICE_ACCOUNT_TOKEN> --env GRAFANA_USERNAME=<GRAFANA_USERNAME> --env GRAFANA_PASSWORD=<GRAFANA_PASSWORD> --env GRAFANA_ORG_ID=<GRAFANA_ORG_ID> --transport stdio mcp-grafana -- docker run -i --rm -e GRAFANA_URL -e GRAFANA_SERVICE_ACCOUNT_TOKEN -e GRAFANA_USERNAME -e GRAFANA_PASSWORD -e GRAFANA_ORG_ID docker.io/grafana/mcp-grafana:2.1.1`.
What does mcp-grafana do?
It gives the agent access to your Grafana instance: searching and reading dashboards, querying Prometheus and Loki, working with datasources and SQL sources. Some tools are enabled separately with the --enabled-tools flag.
Which Grafana version is required?
Grafana 9.0 or later. On older versions datasource operations may fail because the API endpoints are missing.