Grafana MCP Server is a server based on the Model Context Protocol (MCP), specifically designed for integration with Grafana instances and their surrounding ecosystem. This project provides AI agents (such as Claude Desktop) with the ability to access and manipulate various Grafana functionalities.
This project provides flexible tool configuration options, allowing you to enable or disable specific feature categories:
Tool Name | Category | Description |
---|---|---|
search_dashboards |
Search | Search dashboards |
get_dashboard_by_uid |
Dashboard | Get dashboard by UID |
update_dashboard |
Dashboard | Update or create new dashboard |
list_datasources |
Datasources | List data sources |
query_prometheus |
Prometheus | Execute Prometheus query |
query_loki_logs |
Loki | Query and retrieve logs |
list_incidents |
Incident | List incidents |
list_alert_rules |
Alerting | List alert rules |
list_oncall_schedules |
OnCall | List OnCall schedules |
find_error_pattern_logs |
Sift | Find error patterns |
Use the --disable-<category>
flag to disable specific tool categories. For example, use --disable-oncall
to disable OnCall-related tools.
docker pull mcp/grafana
docker run -p 8000:8000 -e GRAFANA_URL=http://localhost:3000 -e GRAFANA_API_KEY=<your_token> mcp/grafana
Download the latest version from the releases page and place it in the $PATH
directory.
GOBIN="$HOME/go/bin" go install github.com/grafana/mcp-grafana/cmd/mcp-grafana@latest
Using Binary File:
{
"mcpServers": {
"grafana": {
"command": "mcp-grafana",
"args": [],
"env": {
"GRAFANA_URL": "http://localhost:3000",
"GRAFANA_API_KEY": "<your service account token>"
}
}
}
}
Using Docker:
{
"mcpServers": {
"grafana": {
"command": "docker",
"args": [
"run", "--rm", "-p", "8000:8000",
"-e", "GRAFANA_URL", "-e", "GRAFANA_API_KEY",
"mcp/grafana"
],
"env": {
"GRAFANA_URL": "http://localhost:3000",
"GRAFANA_API_KEY": "<your service account token>"
}
}
}
}
Enable debug mode by adding the -debug
flag to provide detailed HTTP request and response logs:
{
"mcpServers": {
"grafana": {
"command": "mcp-grafana",
"args": ["-debug"],
"env": {
"GRAFANA_URL": "http://localhost:3000",
"GRAFANA_API_KEY": "<your service account token>"
}
}
}
}
# Run the server
make run
# Build Docker image
make build-image
# Run Docker container
docker run -it --rm -p 8000:8000 mcp-grafana:latest
make test-unit
# Or
make test
# Requires a running Docker container
make test-integration
# Requires a cloud Grafana instance and credentials
make test-cloud
# Start a local Grafana instance
docker-compose up -d
# Run all tests
make test-all
make lint
The project includes a custom linter to check for unescaped commas in jsonschema
struct tags:
make lint-jsonschema
This project represents a new trend in the integration of AI with traditional monitoring tools, providing developers with a powerful bridge connecting AI assistants and the Grafana ecosystem.