🎖️ 🐍 🏠 ☁️ - Search dashboards, investigate incidents and query datasources in your Grafana instance
Grafana MCP server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
A [Model Context Protocol][mcp] (MCP) server for Grafana.
This provides access to your Grafana instance and the surrounding ecosystem.
Quick Start
Requires uv. Add the following to your MCP client configuration (e.g. Claude Desktop, Cursor):
For Grafana Cloud, replace GRAFANA_URL with your instance URL (e.g. https://myinstance.grafana.net). See Usage for more installation options including Docker, binary, and Helm.
Requirements
- **Grafana version 9.0 or later** is required for full functionality. Some features, particularly datasource-related operations, may not work correctly with earlier versions due to missing API endpoints.
Features
_The following features are currently available in MCP server. This list is for informational purposes only and does not represent a roadmap or commitment to future features._
Dashboards
- **Search for dashboards:** Find dashboards by title, folder UID, tag, or starred status
- **Get dashboard by UID:** Retrieve full dashboard details using its unique identifier. Pass optional version to load a saved snapshot instead of the current dashboard. _Warning: Large dashboards can consume significant context window space._
- **List dashboard versions:** List saved versions of a dashboard as compact metadata (version number, author, timestamp, save message)
- **Get dashboard summary:** Get a compact overview of a dashboard including title, panel count, panel types, variables, and metadata without the full JSON to minimize context window usage
- **Get dashboard property:** Extract specific parts of a dashboard using JSONPath expressions (e.g., $.title, $.panels[*].title) to fetch only needed data and reduce context window consumption
- **Update or create a dashboard:** Modify existing dashboards or create new ones. _Warning: Requires full dashboard JSON which can consume large amounts of context window space._
- **Patch dashboard:** Apply specific changes to a dashboard without requiring the full JSON, significantly reducing context window usage for targeted modifications
- **Get panel queries and datasource info:** Get the title, query string, and datasource information (including UID and type, if available) from every panel in a dashboard
Run Panel Query
> **Note:** Run panel query tools are **disabled by default**. To enable them, add runpanelquery to your --enabled-tools flag.
- **Run panel query:** Execute a dashboard panel's query with custom time ranges and variable overrides.
Context Window Management
The dashboard tools now include several strategies to manage context window usage effectively (issue #101):
- **Use get_dashboard_summary** for dashboard overview and planning modifications
- **Use get_dashboard_property** with JSONPath when you only need specific dashboard parts
- **Avoid get_dashboard_by_uid** unless you specifically need the complete dashboard JSON
Datasources
- **List and fetch datasource information:** View all configured datasources and retrieve detailed information about each.
- _Supported datasource types: Prometheus, Loki, ClickHouse, CloudWatch, Elasticsearch, OpenSearch, Snowflake, Athena._
Query Examples
> **Note:** Query examples tools are **disabled by default**. To enable them, add examples to your --enabled-tools flag.
- **Get query examples:** Retrieve example queries for different datasource types to learn query syntax.
Prometheus Querying
- **Query Prometheus:** Execute PromQL queries (supports both instant and range metric queries) against Prometheus datasources.
- **Query Prometheus metadata:** Retrieve metric metadata, metric names, label names, and label values from Prometheus datasources.
- **Query histogram percentiles:** Calculate histogram percentile values (p50, p90, p95, p99) using histogram_quantile.
Loki Querying
- **Query Loki logs and metrics:** Run both log queries and metric queries using LogQL against Loki datasources.
- **Query Loki metadata:** Retrieve label names, label values, and stream statistics from Loki datasources.
- **Query Loki patterns:** Retrieve log patterns detected by Loki to identify common log structures and anomalies.
InfluxDB Querying
> **Note:** InfluxDB tools are **disabled by default**. To enable them, add influxdb to your --enabled-tools flag.
- **Query InfluxDB:** Execute queries against InfluxDB datasources using either InfluxQL (v1.x) or Flux (v2.x). The dialect is inferred from the datasource configuration, or can be set explicitly via the dialect parameter.
SQL Datasource Querying
> **Note:** SQL tools are **disabled by default**. To enable them, add sql to your --enabled-tools flag. Back-compat aliases clickhouse, snowflake, and athena also work.