Prometheus MCP Server
Prometheus MCP サーバー
Prometheus 用のモデル コンテキスト プロトコル(MCP) サーバー。
これにより、標準化された MCP インターフェースを介して Prometheus メトリックとクエリにアクセスできるようになり、AI アシスタントが PromQL クエリを実行してメトリック データを分析できるようになります。
特徴
[x] Prometheusに対してPromQLクエリを実行する
[x] 指標の発見と探索
[x] 利用可能なメトリックの一覧
[x] 特定のメトリックのメタデータを取得する
[x] 即時クエリ結果を表示
[x] 異なるステップ間隔で範囲クエリの結果を表示する
[x] 認証サポート
[x] 環境変数からの基本認証
[x] 環境変数からのベアラートークン認証
[x] Dockerコンテナ化のサポート
[x] AIアシスタントのためのインタラクティブツールを提供する
ツールリストは設定可能なので、MCPクライアントで利用できるようにするツールを選択できます。特定の機能を使用しない場合や、コンテキストウィンドウをあまり占有したくない場合に便利です。
Related MCP server: Prometheus MCP Server
使用法
この MCP サーバーを実行する環境から Prometheus サーバーにアクセスできることを確認します。
.envファイルまたはシステム環境変数を使用して、Prometheus サーバーの環境変数を構成します。
# Required: Prometheus configuration
PROMETHEUS_URL=http://your-prometheus-server:9090
# Optional: Authentication credentials (if needed)
# Choose one of the following authentication methods if required:
# For basic auth
PROMETHEUS_USERNAME=your_username
PROMETHEUS_PASSWORD=your_password
# For bearer token auth
PROMETHEUS_TOKEN=your_token
# Optional: For multi-tenant setups like Cortex, Mimir or Thanos
ORG_ID=your_organization_idサーバー設定をクライアント設定ファイルに追加します。例えば、Claude Desktopの場合は以下のようになります。
{
"mcpServers": {
"prometheus": {
"command": "uv",
"args": [
"--directory",
"<full path to prometheus-mcp-server directory>",
"run",
"src/prometheus_mcp_server/main.py"
],
"env": {
"PROMETHEUS_URL": "http://your-prometheus-server:9090",
"PROMETHEUS_USERNAME": "your_username",
"PROMETHEUS_PASSWORD": "your_password"
}
}
}
}注意: Claude Desktop で
Error: spawn uv ENOENT表示される場合は、uvへのフル パスを指定するか、構成で環境変数NO_UV=1を設定する必要があります。
Dockerの使用
このプロジェクトには、簡単な展開と分離を実現する Docker サポートが含まれています。
ビルド済みのDockerイメージ
このプロジェクトを使用する最も簡単な方法は、GitHub Container Registry から事前に構築されたイメージを使用することです。
docker pull ghcr.io/pab1it0/prometheus-mcp-server:latestタグを使用して特定のバージョンを使用することもできます。
docker pull ghcr.io/pab1it0/prometheus-mcp-server:1.0.0ローカルでDockerイメージを構築する
自分でイメージを構築する場合:
docker build -t prometheus-mcp-server .Dockerで実行する
Docker を使用してサーバーを実行するにはいくつかの方法があります。
事前にビルドされたイメージで docker run を使用する:
docker run -it --rm \
-e PROMETHEUS_URL=http://your-prometheus-server:9090 \
-e PROMETHEUS_USERNAME=your_username \
-e PROMETHEUS_PASSWORD=your_password \
ghcr.io/pab1it0/prometheus-mcp-server:latestローカルでビルドされたイメージで docker run を使用する:
docker run -it --rm \
-e PROMETHEUS_URL=http://your-prometheus-server:9090 \
-e PROMETHEUS_USERNAME=your_username \
-e PROMETHEUS_PASSWORD=your_password \
prometheus-mcp-serverdocker-compose を使用する:
Prometheus の資格情報を使用して.envファイルを作成し、次を実行します。
docker-compose upClaude Desktop で Docker を実行する
Claude Desktop でコンテナ化されたサーバーを使用するには、環境変数を使用して Docker を使用するように構成を更新します。
{
"mcpServers": {
"prometheus": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e", "PROMETHEUS_URL",
"-e", "PROMETHEUS_USERNAME",
"-e", "PROMETHEUS_PASSWORD",
"ghcr.io/pab1it0/prometheus-mcp-server:latest"
],
"env": {
"PROMETHEUS_URL": "http://your-prometheus-server:9090",
"PROMETHEUS_USERNAME": "your_username",
"PROMETHEUS_PASSWORD": "your_password"
}
}
}
}この構成では、変数名のみを指定した-eフラグを使用し、 envオブジェクトに実際の値を指定して、Claude Desktop から Docker コンテナーに環境変数を渡します。
Docker実装に関する注意:Docker設定は、Claudeで正常に動作することが実証されているchess-mcpプロジェクトの構造に合わせて更新されました。新しい実装では、マルチステージビルドプロセスを採用し、シェルスクリプトを介さずにエントリポイントスクリプトを直接実行します。このアプローチにより、MCP通信におけるstdin/stdoutの適切な処理が保証されます。
発達
貢献を歓迎します!ご提案や改善点がありましたら、問題を報告するか、プルリクエストを送信してください。
このプロジェクトは依存関係の管理にuvを使用しています。お使いのプラットフォームの手順に従ってuvをインストールしてください。
curl -LsSf https://astral.sh/uv/install.sh | sh次に、次のコマンドで仮想環境を作成し、依存関係をインストールします。
uv venv
source .venv/bin/activate # On Unix/macOS
.venv\Scripts\activate # On Windows
uv pip install -e .プロジェクト構造
プロジェクトはsrcディレクトリ構造で構成されています:
prometheus-mcp-server/
├── src/
│ └── prometheus_mcp_server/
│ ├── __init__.py # Package initialization
│ ├── server.py # MCP server implementation
│ ├── main.py # Main application logic
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── .dockerignore # Docker ignore file
├── pyproject.toml # Project configuration
└── README.md # This fileテスト
このプロジェクトには、機能性を保証し、回帰を防ぐのに役立つ包括的なテスト スイートが含まれています。
pytest でテストを実行します。
# Install development dependencies
uv pip install -e ".[dev]"
# Run the tests
pytest
# Run with coverage report
pytest --cov=src --cov-report=term-missingテストは次のように分類されます:
構成検証テスト
サーバー機能テスト
エラー処理テスト
主なアプリケーションテスト
新しい機能を追加する場合は、対応するテストも追加してください。
ツール
道具 | カテゴリ | 説明 |
| クエリ | Prometheusに対してPromQLインスタントクエリを実行する |
| クエリ | 開始時刻、終了時刻、ステップ間隔を指定してPromQL範囲クエリを実行する |
| 発見 | Prometheusで利用可能なすべてのメトリックを一覧表示する |
| 発見 | 特定のメトリックのメタデータを取得する |
| 発見 | すべてのスクレイプターゲットに関する情報を取得する |
ライセンス
マサチューセッツ工科大学
Available Tools
6 toolsexecute_queryExecute PromQL QueryCRead-onlyIdempotent
Execute a PromQL instant query against Prometheus
Inputs: query (required), time. Returns: object
execute_range_queryExecute PromQL Range QueryBRead-onlyIdempotent
Execute a PromQL range query with start time, end time, and step interval
Inputs: query (required), start (required), end (required), step (required). Returns: object
get_metric_metadataGet Metric MetadataARead-onlyIdempotent
Get metadata (type, help, unit) for metrics. Returns all metric metadata when no metric name is provided. Use filter_pattern to search metric names and descriptions.
Inputs: metric, filter_pattern, limit, offset. Returns: result
get_targetsGet Scrape TargetsARead-onlyIdempotent
Get information about all scrape targets
Inputs: no named parameters. Returns: object
health_checkHealth CheckARead-onlyIdempotent
Health check endpoint for container monitoring and status verification
Inputs: no named parameters. Returns: object
list_metricsList Available MetricsARead-onlyIdempotent
List all available metrics in Prometheus with optional pagination support
Inputs: limit, offset, filter_pattern, refresh_cache. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose: query types (instant vs range), metadata retrieval, target info, health check, and metric listing. No overlap.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., execute_query, get_metric_metadata). No deviations.
Six tools cover the essential Prometheus operations without being excessive or insufficient. Well-scoped for the server's purpose.
Core CRUD-like operations for queries and metadata are present. Minor gaps like alert management or rule configuration are missing but not critical for the primary use case.
Maintenance
Related MCP Connectors
Query your app's logs, metrics and incidents from your AI assistant.
Query application logs, traces, and metrics from your AI coding assistant via Foam's MCP server.
Lets AI agents analyze API metrics, request logs, and traces, and manage apps and alerts.
List datasets, schemas, run APL queries, and use prompts for exploration, anomalies, and monitoring.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA tool that enables access to Prometheus metrics data through a Model Context Protocol server, allowing interaction with monitoring data using natural language.MIT
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI assistants to query Prometheus metrics, discover available data, and analyze system performance through natural language interactions.5224 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to query Prometheus metrics, monitor alerts, and analyze system health through read-only access to your Prometheus server with built-in query safety and optional AI-powered metric analysis.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to execute PromQL queries and discover metrics across multiple Prometheus tenants using the Model Context Protocol. It supports single and multi-tenant configurations with secure authentication for instant and range query analysis.MIT