DG

drdroidlab/grafana-mcp-server

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

6 stars 3 forks 品質 59 トレンド 14MIT

A Model Context Protocol (MCP) server for Grafana

概要

The following tools are available via the MCP server: - : Verify connectivity to your Grafana instance and configuration. - : Execute PromQL queries against Grafana's Prometheus datasource. Fetches metrics data using PromQL expressions, optimizes time series responses to reduce token size. - : Query Grafana Loki for log data. Fetches logs for a specified duration (e.g., '5m', '1h', '2d'), converts relative time to absolute timestamps. - : Retrieves dashboard configuration details from the database. Queries the connectors_connectormetadatamodelstore table for dashboard metadata. - : Execute queries for specific dashboard panels. Can query up to 4 panels at once, supports template variables, optimizes metrics data. - : Fetch label values for dashboard variables from Prometheus datasource. Retrieves available values for specific labels (e.g., 'instance', 'job'). Supports optional metric filtering. - : Fetch all variables and their values from a Grafana dashboard.

README

以下は原文 README の抜粋です。原文を見る。

Grafana MCP Server

Available Tools

The following tools are available via the MCP server:

  • test_connection: Verify connectivity to your Grafana instance and configuration.
  • grafana_promql_query: Execute PromQL queries against Grafana’s Prometheus datasource. Fetches metrics data using PromQL expressions, optimizes time series responses to reduce token size.
  • grafana_loki_query: Query Grafana Loki for log data. Fetches logs for a specified duration (e.g., ‘5m’, ‘1h’, ‘2d’), converts relative time to absolute timestamps.
  • grafana_get_dashboard_config: Retrieves dashboard configuration details from the database. Queries the connectors_connectormetadatamodelstore table for dashboard metadata.
  • grafana_query_dashboard_panels: Execute queries for specific dashboard panels. Can query up to 4 panels at once, supports template variables, optimizes metrics data.
  • grafana_fetch_label_values: Fetch label values for dashboard variables from Prometheus datasource. Retrieves available values for specific labels (e.g., ‘instance’, ‘job’). Supports optional metric filtering.
  • grafana_fetch_dashboard_variables: Fetch all variables and their values from a Grafana dashboard. Retrieves dashboard template variables and their current values.
  • grafana_fetch_all_dashboards: Fetch all dashboards from Grafana with basic information like title, UID, folder, tags, etc.
  • grafana_fetch_datasources: Fetch all datasources from Grafana with their configuration details.
  • grafana_fetch_folders: Fetch all folders from Grafana with their metadata and permissions.

🚀 Usage & Requirements

1. Get Your Grafana API Endpoint & Service Account Token

  1. Ensure you have a running Grafana instance (self-hosted or cloud).
  2. Generate a Service Account Token from your Grafana UI:
    • Create Service Account: In your Grafana dashboard, navigate to Admin >> Users & Access >> Service Accounts >> Create a Service Account with Viewer permissions
    • Generate Service Account Key: Within Service Account, create a new Service Account token.
    • Copy the service account token (starts with glsa_)

2. Installation & Running Options

2A.1. Install dependencies with uv

uv venv .venv
source .venv/bin/activate
uv sync

2A.2. Run the server with uv

uv run -m src.grafana_mcp_server.mcp_server
  • You can also use uv to run any other entrypoint scripts as needed.
  • Make sure your config.yaml is in the same directory as mcp_server.py or set the required environment variables (see Configuration section).

  1. Edit grafana-mcp-server/src/grafana_mcp_server/config.yaml with your Grafana details (host, API key).
  2. Start the server:
    docker compose up -d
    
GitHub で README 全文を見る

インストール

docker run --rm -i -e GRAFANA_HOST -e GRAFANA_API_KEY -e GRAFANA_SSL_VERIFY drdroidlab/grafana-mcp-server -t stdio
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "mcpServers": { "grafana": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "GRAFANA_HOST", "-e", "GRAFANA_API_KEY", "-e", "GRAFANA_SSL_VERIFY", "drdroidlab/grafana-mcp-server", "-t", "stdio" ], "env": { "GRAFANA_HOST": "https://your-grafana-instance.com", "GRAFANA_API_KEY": "your-grafana-api-key-here", "GRAFANA_SSL_VERIFY": "true" } } } }