mcp-prometheus について
mcp-prometheusは、Prometheusのクエリ、ステータス、ルール、ターゲット、Kubernetes診断機能をクライアントに提供するGo製MCPサーバーです。設定したPrometheus URLへの直接接続、またはKubernetes APIプロキシ経由で接続します。
主な機能
- 01PromQLの瞬時・期間クエリ
- 02ターゲット、ルール、サーバー状態の確認
- 03クラスター、ノード、名前空間の診断
- 04CPU、メモリ、ネットワーク分析
- 05Kubernetes APIプロキシ接続
活用シーン
- 01Prometheusのメトリクスとスクレイプ対象の確認
- 02クラスターやノードの状態確認
- 03Podのリソース使用状況の調査
- 04期間別メトリクスの比較
MCP 対応
MCPサーバーは、Prometheusのクエリ、状態確認、診断を行う11種類のツールをMCPクライアントに公開します。Prometheus URLへの直接接続またはKubernetes APIプロキシ経由で接続します。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
Prometheus MCP Server(Go)
Prometheus と連携するための Model Context Protocol (MCP) サーバーです。client-go による Kubernetes 接続機能を内蔵したネイティブ Go バイナリです。
インストール
npx
npx -y mcp-prometheus@latest
MCP クライアントの設定
MCP クライアント(VS Code、Cursor、Windsurf など)の設定に追加します。
{
"mcpServers": {
"prometheus": {
"command": "npx",
"args": ["-y", "mcp-prometheus@latest"],
"env": {
"PROMETHEUS_URL": "http://localhost:9090"
}
}
}
}
VS Code
code --add-mcp '{"name":"prometheus","command":"npx","args":["-y","mcp-prometheus@latest"],"env":{"PROMETHEUS_URL":"http://localhost:9090"}}'
Kubernetes への自動接続
K8S API サービスプロキシを介して、OpenShift/Kubernetes 上で稼働している Prometheus に自動接続します。client-go を介して、ネイティブの kubeconfig/クラスター内設定を使用します。kubectl やポートフォワーディングは必要ありません。
デフォルト:openshift-monitoring/prometheus-operated:9090
{
"mcpServers": {
"prometheus": {
"command": "npx",
"args": ["-y", "mcp-prometheus@latest"]
}
}
}
バイナリ
GitHub Releases からダウンロードするか、ソースからビルドします。
make build
./mcp-prometheus
設定
環境変数
| 変数 | 説明 |
|---|---|
PROMETHEUS_URL | Prometheus API の直接 URL(K8S 自動接続より優先) |
CLI フラグ
| フラグ | 説明 | デフォルト |
|---|---|---|
--url | Prometheus の直接 URL | - |
--namespace | Kubernetes の名前空間 | openshift-monitoring |
--service | Kubernetes のサービス名 | prometheus-operated |
--service-port | Kubernetes のサービスポート | 9090 |
--service-scheme | サービスのスキーム(http/https) | https |
--kubeconfig | kubeconfig ファイルのパス | 自動検出 |
優先順位: --url / PROMETHEUS_URL > K8S 自動接続
接続方法:
- 直接 URL(
--urlまたはPROMETHEUS_URLが設定されている場合) - K8S API プロキシ(kubeconfig またはクラスター内設定を自動検出)
ツール(11)
基本クエリ
| ツール | 説明 |
|---|---|
query | PromQL の瞬時クエリを実行 |
queryRange | PromQL の範囲クエリを時間経過に沿って実行 |
getTargets | スクレイプ対象のステータスを取得 |
getRules | アラートルールと記録ルールを取得 |
getPrometheusStatus | サーバーのバージョンとランタイム情報を取得 |
クラスター診断
| ツール | 説明 |
|---|---|
getClusterHealthOverview | クラスターの健全性を包括的に確認 |
diagnoseNode | 特定のノードの健全性を診断 |
diagnoseNamespace | 名前空間の健全性を診断 |
リソース分析
| ツール | 説明 |
|---|---|
getTopResourceConsumers | CPU/メモリ/ネットワークの主な使用量を確認 |
investigatePod | 特定の Pod を詳細に調査 |
compareTimeRanges | 2 つの期間のメトリクスを比較 |
プロンプトの例
"What's the current CPU usage across all nodes?"
"Show me the cluster health overview"
"Which pods are using the most memory?"
"Diagnose node worker-1"
"Are all scrape targets healthy?"
"Compare CPU usage now vs 24 hours ago"
"Investigate pod my-app in namespace production"
"What alerting rules are defined?"
開発
ビルド
make build # Build for current platform
make build-all-platforms # Cross-compile for all platforms
コンテナ
podman build -f Containerfile -t mcp-prometheus .
Kubernetes/OpenShift へのデプロイ
コンテナイメージ
コンテナイメージは GitHub Container Registry で入手できます。
ghcr.io/jeanlopezxyz/mcp-prometheus:latest
Helm チャート
付属の Helm チャートを使用してデプロイします。
# Add the chart repository (or use local chart)
helm upgrade --install mcp-prometheus ./charts/mcp-prometheus \
--namespace mcp-servers \
--create-namespace \
--set openshift=true
Helm の値
| パラメーター | 説明 | デフォルト |
|---|---|---|
image.registry | コンテナレジストリ | ghcr.io |
image.repository | イメージリポジトリ | jeanlopezxyz/mcp-prometheus |
image.version | イメージタグ | latest |
openshift | OpenShift Routes を有効化 | false |
service.port | サービスポート | 8080 |
prometheus.namespace | Prometheus の名前空間 | openshift-monitoring |
prometheus.service | Prometheus のサービス名 | prometheus-operated |
rbac.useClusterReader | cluster-reader ロールを使用 | true |
カスタム Prometheus を使用する例
helm upgrade --install mcp-prometheus ./charts/mcp-prometheus \
--namespace mcp-servers \
--set openshift=true \
--set prometheus.url=http://prometheus.monitoring:9090
ライセンス
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。