- Home
- MCP servers
- Grafana
Grafana
- python
5
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"drdroidlab-grafana-mcp-server": {
"command": "uv",
"args": [
"run",
"-m",
"src.grafana_mcp_server.mcp_server"
],
"env": {
"GRAFANA_HOST": "YOUR_GRAFANA_HOST",
"GRAFANA_API_KEY": "YOUR_API_KEY",
"MCP_SERVER_PORT": "8000",
"MCP_SERVER_DEBUG": "true",
"GRAFANA_SSL_VERIFY": "true"
}
}
}
}You run a Grafana MCP Server to expose Grafana data access through MCP clients. It lets you query PromQL, fetch dashboards, dashboards variables, and more from Grafana using a standard MCP interface, enabling automation and integration with AI assistants and other tools.
How to use
Decide how you want to run the server. For local development, you can start it directly with the recommended runtime. For production or containerized setups, you can deploy via Docker Compose. The server exposes MCP endpoints that let you perform PromQL queries, Loki queries, and retrieve Grafana metadata and dashboards.
How to install
Prerequisites: ensure Python is available and you have a working Grafana instance with an API key. You will also use a runtime tool to start the MCP server locally.
- Install the MCP runtime and dependencies for local development.
uv venv .venv
source .venv/bin/activate
uv sync
- Run the MCP server locally using the standard IO server entrypoint.
uv run -m src.grafana_mcp_server.mcp_server
Configuration and usage notes
Configure Grafana details by providing your Grafana host and API key, either through environment variables or a YAML configuration file. The environment variables you use are listed below. You can override the defaults as needed for your environment.
Environment variables you will set.
GRAFANA_HOST=https://your-grafana-instance.com
GRAFANA_API_KEY=YOUR_GRAFANA_API_KEY
GRAFANA_SSL_VERIFY=true
MCP_SERVER_PORT=8000
MCP_SERVER_DEBUG=true
Security and deployment considerations
Use a strong Grafana API key with limited permissions suitable for MCP access. When deploying in production, prefer secured HTTP endpoints and proper network restrictions. If using Docker, ensure the container has access to Grafana over a secure connection and that SSL verification is correctly configured.
Health check
Verify the MCP server is running and reachable.
Available tools
test_connection
Verify connectivity to your Grafana instance and configuration.
grafana_promql_query
Execute PromQL queries against Grafana's Prometheus datasource and optimize responses to reduce token size.
grafana_loki_query
Query Grafana Loki for log data over a specified duration and convert relative times to absolute timestamps.
grafana_get_dashboard_config
Retrieve dashboard configuration details from the database, querying dashboard metadata.
grafana_query_dashboard_panels
Execute queries for specific dashboard panels, supporting up to 4 panels at once and template variables.
grafana_fetch_label_values
Fetch label values for dashboard variables from Prometheus datasource with optional metric filtering.
grafana_fetch_dashboard_variables
Fetch all dashboard template variables and their current values.
grafana_fetch_all_dashboards
Fetch all dashboards with basic information such as title, UID, folder, and tags.
grafana_fetch_datasources
Fetch all Grafana datasources with their configuration details.
grafana_fetch_folders
Fetch all Grafana folders with metadata and permissions.