📊grafana-mcp-tools
- プラグイン
- grafana-mcp
- ソース
- GitHub で見る ↗
説明
Grafana MCP サーバーをインストール、設定し、効果的に利用する方法について説明します。Docker またはバイナリ(実行プログラム)での構築、環境変数の指定、ツールの分類、アクセス権限管理、そしてコンテキストウィンドウ(会話履歴を保持する領域)の管理に関するベストプラクティスをカバーしています。 次のような場合に使用: ユーザーが mcp-grafana をセットアップしたい、Grafana MCP ツールを設定したい、またはどの MCP ツールを使うべきかについてのアドバイスが必要な場合
原文を表示
Install, configure, and use the Grafana MCP server effectively. Covers setup via Docker or binary, environment variables, tool categories, RBAC, and best practices for context window management. Use when the user wants to set up mcp-grafana, configure Grafana MCP tools, or needs guidance on which MCP tool to use.
ユースケース
- ✓Grafana MCP サーバーをセットアップする
- ✓Docker またはバイナリで構築する
- ✓環境変数を指定・設定する
- ✓MCP ツールの分類を確認する
- ✓アクセス権限を管理する
本文(日本語訳)
Grafana MCP サーバー
50以上のGrafana API ツールを提供するMCP サーバーです。Grafana 9.0以上に対応しており、ローカル環境とGrafana Cloud の両方で利用できます。
前提条件
MCPサーバーは事前にインストール済みである必要があります。自動インストールを試みないでください。 インストールされていない場合は、ユーザーにまず先にインストールするよう案内してください。
インストール手順、事前ビルド済みバイナリ、Dockerイメージ、Helmチャートについては以下を参照: github.com/grafana/mcp-grafana
設定
環境変数
| 変数 | 説明 |
|---|---|
GRAFANA_URL |
GrafanaインスタンスのURL(デフォルト: http://localhost:3000) |
GRAFANA_SERVICE_ACCOUNT_TOKEN |
サービスアカウント トークン(推奨) |
GRAFANA_API_KEY |
APIキー(非推奨、サービスアカウント トークンを使用してください) |
GRAFANA_USERNAME + GRAFANA_PASSWORD |
基本認証 |
GRAFANA_ORG_ID |
複数組織設定の場合の組織ID |
GRAFANA_EXTRA_HEADERS |
カスタムHTTPヘッダーを含むJSONオブジェクト |
セットアップ手順
-
Grafanaでサービスアカウントを作成します。最低でもViewer(表示者)ロール、または書き込み操作が必要な場合はEditor(編集者)ロールを付与してください。トークンを生成します。
-
環境変数を設定します:
export GRAFANA_URL="https://mystack.grafana.net" export GRAFANA_SERVICE_ACCOUNT_TOKEN="glsa_..." -
MCPサーバーはCursorがプラグインを読み込む際に自動的に起動します。
ローカルGrafana用Docker設定
Docker内から localhost に接続する場合は、host.docker.internal を使用してください:
{
"env": {
"GRAFANA_URL": "http://host.docker.internal:3000"
}
}
バイナリ設定(Docker代替案)
Dockerではなくバイナリを使う場合は、mcp.json を更新してください:
{
"mcpServers": {
"grafana": {
"command": "mcp-grafana",
"args": [],
"env": {
"GRAFANA_URL": "${GRAFANA_URL}",
"GRAFANA_SERVICE_ACCOUNT_TOKEN": "${GRAFANA_SERVICE_ACCOUNT_TOKEN}"
}
}
}
}
CLIフラグ
| フラグ | 説明 |
|---|---|
-t, --transport |
転送方式: stdio(デフォルト)、sse、streamable-http |
--address |
SSE/HTTP用のホスト:ポート(デフォルト: localhost:8000) |
--debug |
デバッグログを有効化 |
--log-level |
debug、info、warn、error |
--disable-write |
読み取り専用モード(作成・更新・削除ツールなし) |
--enabled-tools |
有効にするツールカテゴリのカンマ区切りリスト |
--metrics |
/metrics でPrometheusメトリクス(計測値)を有効化 |
ツールカテゴリ
ダッシュボード
search_dashboards— タイトル・メタデータで検索get_dashboard_summary— コンパクトな概要表示(フルJSONより推奨)get_dashboard_property— JSONPath経由で特定部分を抽出get_dashboard_panel_queries— パネルのクエリとデータソース情報を取得get_dashboard_by_uid— ダッシュボード全体のJSON(大容量のため必要な場合のみ)update_dashboard— ダッシュボードを作成・更新patch_dashboard— フルJSONなしで対象部分のみ変更
データソース
list_datasources— すべてのデータソースを一覧表示get_datasource_by_uid/get_datasource_by_name— データソース詳細を取得
Prometheus
query_prometheus— PromQL(Prometheus問い合わせ言語)クエリを実行list_prometheus_metric_metadata— メトリクスのメタデータを取得list_prometheus_metric_names— 利用可能なメトリクスを一覧表示list_prometheus_label_names/list_prometheus_label_values— ラベルの検出query_prometheus_histogram— ヒストグラムのパーセンタイルを計算
Loki
query_loki_logs— LogQL(ログ問い合わせ言語)を使ってログ・メトリクスを照会list_loki_label_names/list_loki_label_values— ラベルの検出query_loki_stats— ストリーム統計query_loki_patterns— 検出されたログパターン
アラート
list_alert_rules/get_alert_rule_by_uid— アラートルールを読み取りcreate_alert_rule/update_alert_rule/delete_alert_rule— ルールを管理list_contact_points— 通知先
インシデント
list_incidents/get_incident— インシデントを読み取りcreate_incident/add_activity_to_incident— インシデントを管理
OnCall
list_oncall_schedules/get_oncall_shift/get_current_oncall_users— シフトスケジュールlist_oncall_teams/list_oncall_users— チーム・ユーザー検出list_alert_groups/get_alert_group— アラートグループ
Sift(調査)
list_sift_investigations/get_sift_investigation/get_sift_analysisfind_error_pattern_logs/find_slow_requests
Pyroscope(プロファイリング・処理分析)
list_pyroscope_label_names/list_pyroscope_label_valueslist_pyroscope_profile_types/fetch_pyroscope_profile
アノテーション
get_annotations/create_annotation/update_annotation/patch_annotationcreate_graphite_annotation/get_annotation_tags
ナビゲーション
generate_deeplink— ダッシュボード・パネル・探索機能のURLを生成
レンダリング
get_panel_image— パネル・ダッシュボードをPNG画像として描画(Image Rendererが必要)
デフォルトで無効
以下のカテゴリは --enabled-tools で明示的に有効にする必要があります:
- ClickHouse:
list_clickhouse_tables、describe_clickhouse_table、query_clickhouse - CloudWatch:
list_cloudwatch_namespaces、list_cloudwatch_metrics、list_cloudwatch_dimensions、query_cloudwatch - Elasticsearch:
query_elasticsearch - 管理:
list_teams、list_users_by_org、list_all_roles、get_role_details、get_role_assignments - ログ検索:
search_logs(ClickHouseとLoki全体の高レベル検索) - クエリ例:
get_query_examples
ベストプラクティス
コンテキストウィンドウ(会話の記憶領域)の管理
- ダッシュボード全体のJSONで容量を消費しないよう、
get_dashboard_by_uidではなくget_dashboard_summaryを使用してください。 - JSONPath付き
get_dashboard_propertyで必要な部分だけを抽出してください。 - フルペイロードの
update_dashboardではなく、対象部分のみ変更するpatch_dashboardを推奨します。 - UIDで取得する前に
search_dashboardsでダッシュボードを検出してください。 - Grafanaデータを示す際は、ナビゲーション手順の説明ではなく
generate_deeplinkでクリック可能なURLを提供してください。
クエリ実行時
- Prometheusをクエリする際は常に適切な時間範囲を指定し、過度な結果を避けてください。
- Lokiをクエリする際は、広範囲なクエリより、ラベルマッチャー(ラベル絞り込み条件)を含む対象的なLogQLセレクタを推奨します。
- クエリを書く前に、データソース検出ツール(
list_datasources、list_prometheus_metric_names)を使用してください。
セキュリティ
- ユーザーが明示的に要求していない限り、書き込み操作(
update_dashboard、create_incident、create_alert_rule)は避けてください。 - 書き込みアクセスが不要な場合は、
--disable-writeフラグで読み取り専用モードを使用してください。 --enabled-toolsで未使用のツールカテゴリを無効化し、攻撃対象領域とコンテキスト使用量を削減してください。
ロールベースアクセス制御(権限管理)
- Viewer(表示者)ロール: すべての読み取り操作(ダッシュボード、データソース、クエリ、アノテーション)で十分
- Editor(編集者)ロール: 書き込み操作(ダッシュボード作成・更新、アラート、インシデント)に必須
- より細かい制御のため、ツールごとに特定権限を持つカスタムロールを使用してください(完全なロール・権限マトリクスについてはmcp-grafanaのREADMEを参照)
原文(English)を表示
Grafana MCP Server
MCP server exposing 50+ Grafana API tools. Supports Grafana 9.0+ (local and Grafana Cloud).
Prerequisites
The MCP server must already be installed. Do not attempt to install it automatically. If it is not available, stop and tell the user to install it first.
Installation instructions, pre-built binaries, Docker images, and Helm charts: github.com/grafana/mcp-grafana
Configuration
Environment variables
| Variable | Description |
|---|---|
GRAFANA_URL |
Grafana instance URL (default: http://localhost:3000) |
GRAFANA_SERVICE_ACCOUNT_TOKEN |
Service account token (recommended) |
GRAFANA_API_KEY |
API key (deprecated, use service account token) |
GRAFANA_USERNAME + GRAFANA_PASSWORD |
Basic auth |
GRAFANA_ORG_ID |
Organization ID for multi-org setups |
GRAFANA_EXTRA_HEADERS |
JSON object with custom HTTP headers |
Setup steps
-
Create a service account in Grafana with at least Viewer role (or Editor for write operations). Generate a token.
-
Set environment variables:
export GRAFANA_URL="https://mystack.grafana.net" export GRAFANA_SERVICE_ACCOUNT_TOKEN="glsa_..." -
The MCP server starts automatically when Cursor loads the plugin.
Docker config for local Grafana
When connecting to localhost from Docker, use host.docker.internal:
{
"env": {
"GRAFANA_URL": "http://host.docker.internal:3000"
}
}
Binary config (alternative to Docker)
If you prefer the binary over Docker, update mcp.json:
{
"mcpServers": {
"grafana": {
"command": "mcp-grafana",
"args": [],
"env": {
"GRAFANA_URL": "${GRAFANA_URL}",
"GRAFANA_SERVICE_ACCOUNT_TOKEN": "${GRAFANA_SERVICE_ACCOUNT_TOKEN}"
}
}
}
}
CLI flags
| Flag | Description |
|---|---|
-t, --transport |
Transport type: stdio (default), sse, streamable-http |
--address |
Host:port for SSE/HTTP (default: localhost:8000) |
--debug |
Enable debug logging |
--log-level |
debug, info, warn, error |
--disable-write |
Read-only mode (no create/update/delete tools) |
--enabled-tools |
Comma-separated list of enabled tool categories |
--metrics |
Enable Prometheus metrics at /metrics |
Tool categories
Dashboards
search_dashboards— search by title/metadataget_dashboard_summary— compact overview (preferred over full JSON)get_dashboard_property— extract specific parts via JSONPathget_dashboard_panel_queries— get panel queries and datasource infoget_dashboard_by_uid— full dashboard JSON (large, avoid unless needed)update_dashboard— create or update a dashboardpatch_dashboard— targeted modifications without full JSON
Datasources
list_datasources— list all datasourcesget_datasource_by_uid/get_datasource_by_name— get datasource details
Prometheus
query_prometheus— execute PromQL querieslist_prometheus_metric_metadata— get metric metadatalist_prometheus_metric_names— list available metricslist_prometheus_label_names/list_prometheus_label_values— label discoveryquery_prometheus_histogram— calculate histogram percentiles
Loki
query_loki_logs— query logs/metrics using LogQLlist_loki_label_names/list_loki_label_values— label discoveryquery_loki_stats— stream statisticsquery_loki_patterns— detected log patterns
Alerting
list_alert_rules/get_alert_rule_by_uid— read alert rulescreate_alert_rule/update_alert_rule/delete_alert_rule— manage ruleslist_contact_points— notification endpoints
Incidents
list_incidents/get_incident— read incidentscreate_incident/add_activity_to_incident— manage incidents
OnCall
list_oncall_schedules/get_oncall_shift/get_current_oncall_users— scheduleslist_oncall_teams/list_oncall_users— team/user discoverylist_alert_groups/get_alert_group— alert groups
Sift (investigation)
list_sift_investigations/get_sift_investigation/get_sift_analysisfind_error_pattern_logs/find_slow_requests
Pyroscope (profiling)
list_pyroscope_label_names/list_pyroscope_label_valueslist_pyroscope_profile_types/fetch_pyroscope_profile
Annotations
get_annotations/create_annotation/update_annotation/patch_annotationcreate_graphite_annotation/get_annotation_tags
Navigation
generate_deeplink— generate URLs for dashboards, panels, Explore
Rendering
get_panel_image— render panel/dashboard as PNG (requires Image Renderer)
Disabled by default
These categories must be explicitly enabled with --enabled-tools:
- ClickHouse:
list_clickhouse_tables,describe_clickhouse_table,query_clickhouse - CloudWatch:
list_cloudwatch_namespaces,list_cloudwatch_metrics,list_cloudwatch_dimensions,query_cloudwatch - Elasticsearch:
query_elasticsearch - Admin:
list_teams,list_users_by_org,list_all_roles,get_role_details,get_role_assignments - Search Logs:
search_logs(high-level across ClickHouse and Loki) - Query Examples:
get_query_examples
Best practices
Context window management
- Use
get_dashboard_summaryinstead ofget_dashboard_by_uidto avoid consuming context with full dashboard JSON. - Use
get_dashboard_propertywith JSONPath to extract only the specific parts you need. - Prefer
patch_dashboardfor targeted modifications overupdate_dashboardwith full payload. - Use
search_dashboardsto discover dashboards before retrieving by UID. - When presenting Grafana data, use
generate_deeplinkto provide clickable URLs rather than describing navigation steps.
Querying
- When querying Prometheus, always specify a reasonable time range to avoid overwhelming results.
- When querying Loki, prefer targeted LogQL selectors with label matchers over broad queries.
- Use datasource discovery tools (
list_datasources,list_prometheus_metric_names) before writing queries.
Safety
- Avoid write operations (
update_dashboard,create_incident,create_alert_rule) unless explicitly asked by the user. - Use
--disable-writeflag for read-only mode when write access isn't needed. - Disable unused tool categories with
--enabled-toolsto reduce attack surface and context usage.
RBAC
- Viewer role: sufficient for all read operations (dashboards, datasources, queries, annotations)
- Editor role: required for write operations (create/update dashboards, alerts, incidents)
- For fine-grained control, use custom roles with specific permissions per tool (see mcp-grafana README for the full RBAC matrix)
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。