Grafana MCP Server
Search dashboards, query datasources, and analyze metrics from Grafana directly in Claude Code. Essential for SREs and developers who need to investigate production metrics, build dashboard queries, and correlate monitoring data during incident response.
MCP Server Configuration
{ "mcpServers": { "grafana": { "command": "npx", "args": ["-y", "@grafana/mcp-server-grafana"], "env": { "GRAFANA_URL": "http://localhost:3000", "GRAFANA_API_KEY": "<your-service-account-token>" } } } }
Available Tools
| Tool | Description |
|---|---|
search_dashboards | Search for dashboards by name or tag |
get_dashboard | Get full dashboard JSON including panels |
list_datasources | List all configured datasources |
query_datasource | Execute queries against Prometheus, Loki, etc. |
list_alerts | List active and pending alerts |
get_alert_rules | Get alert rule definitions |
query_loki | Query Loki logs with LogQL |
query_prometheus | Query Prometheus metrics with PromQL |
Setup
- In Grafana, go to Administration > Service Accounts
- Create a new service account with
Viewerrole (orEditorfor write access) - Generate a token for the service account
- Replace the URL and token in the configuration
Usage Examples
- "Show me dashboards related to the payments service"
- "Query CPU usage for the api-server pod over the last 6 hours"
- "List all firing alerts and their severity"
- "Search Loki logs for 500 errors in the auth service"
- "Get the PromQL query from the latency panel on the SLA dashboard"
Query Examples
# Request rate by status code sum(rate(http_requests_total{service="api"}[5m])) by (status_code) # P99 latency histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m])) # Error rate percentage sum(rate(http_requests_total{status_code=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) * 100
Security Notes
- Use
Viewerrole service accounts for read-only access - Metrics may contain sensitive operational data
- Store tokens in
.claude/settings.local.json(gitignored) - For Grafana Cloud, use your cloud instance URL
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Database MCP Integration
MCP server configuration for connecting Claude Code to PostgreSQL, MySQL, and MongoDB databases. Enables schema inspection, query building, and migration generation.
Elevenlabs Server
Streamline your workflow with this official, elevenlabs, text, speech. Includes structured workflows, validation checks, and reusable patterns for audio.
Browser Use Portal
Powerful mcp for server, enables, agents, control. Includes structured workflows, validation checks, and reusable patterns for browser_automation.