Prometheus Mcp

io.github.mshegolev由 GitHub 账号 mshegolev 发布v0.1.0更新于 Oct 24, 2026

Prometheus MCP — query metrics, inspect alerts, and explore scrape targets (read-only).

发布方自己的服务:Prometheus MCP

已验证STDIO仅桌面安全与监控数据与分析

概览

AI 生成的概览

只读 MCP 服务器,让助手用 PromQL 查询 Prometheus 指标、列出指标名、查看活动告警和抓取目标。

可以做什么
按子串筛选列出指标名称,便于在查询前了解可用指标(上限 500 条)。执行即时 PromQL 查询,返回当前值、标签和结果类型。按时间窗口和步长执行 PromQL 范围查询,返回带时间戳的序列(上限 5000 个数据点)。列出活动与待定告警,含严重级别、状态及 firing/pending 汇总。按作业、健康状态和最近抓取信息列出抓取目标,可按 active、dropped 或 any 过滤。
适用场景
适合在对话中让助手排查现有 Prometheus 部署的指标、告警或抓取健康状况,例如查看请求速率、CPU 趋势、正在触发的告警或哪些目标不可用,而无需自己编写 API 调用。
运行要求
以 PyPI 包形式通过 stdio 在本地运行(pip install prometheus-mcp 或 uvx prometheus-mcp)。需要设置环境变量 PROMETHEUS_URL 指向服务器地址,末尾不加斜杠。可选认证:PROMETHEUS_TOKEN(Bearer),或 PROMETHEUS_USERNAME 与 PROMETHEUS_PASSWORD(Basic)。自签名证书可将 PROMETHEUS_SSL_VERIFY 设为 false。需要能访问 Prometheus 服务器的网络。
安装前请注意
该服务器持有 Prometheus 实例的凭据:PROMETHEUS_TOKEN 或 PROMETHEUS_PASSWORD 通过环境变量传入,应限定为只读权限。将 PROMETHEUS_SSL_VERIFY 设为 false 会关闭证书校验。README 称工具为只读,但同时提到高级告警关联功能和一个 federation_analyze_alerts 工具,而它们不在所列五个工具之中,安装前应确认实际暴露的工具。README 说明会绕过环境代理设置。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Prometheus Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

prometheus-mcp

[PyPI version] [Python versions] [License: MIT] [Tests]

MCP server for Prometheus metrics and observability. Give Claude (or any MCP-capable agent) read access to your Prometheus instance — query metrics with PromQL, inspect active alerts, and explore scrape targets — without leaving the conversation.

Why another Prometheus MCP?

The existing Prometheus integrations require custom scripts or direct API knowledge. This server:

  • Speaks the standard Model Context Protocol over stdio — works with Claude Desktop, Claude Code, Cursor, and any MCP client.
  • Is read-only: all 5 tools carry readOnlyHint: true — zero risk of modifying Prometheus data.
  • Returns dual-channel output: structured JSON (structuredContent) for programmatic use + Markdown (content) for human-readable display.
  • Has actionable error messages that name the exact env var to fix and suggest a next step.
  • Supports Bearer token, HTTP Basic auth, or no auth (common for internal deployments).

Tools

ToolEndpointDescription
prometheus_list_metricsGET /api/v1/label/__name__/valuesList all metric names with optional substring filter (cap 500)
prometheus_queryGET /api/v1/queryExecute an instant PromQL query
prometheus_query_rangeGET /api/v1/query_rangeExecute a PromQL range query returning time-series
prometheus_list_alertsGET /api/v1/alertsList active and pending alerts
prometheus_list_targetsGET /api/v1/targetsList scrape targets by health and job

v4.0 Advanced Alert Correlation Features

Version 4.0 introduces powerful new capabilities for AI agents to autonomously investigate production errors:

Cross-Instance Alert Correlation

  • Automatically identify related alerts across multiple Prometheus instances
  • Group alerts by service identifiers to understand incident scope
  • Detect cascading alert patterns with directional dependency inference

Root Cause Analysis

  • Anomaly detection in metrics with automatic seasonality adjustment
  • Dependency chain traversal from symptoms to potential root causes
  • Change point detection correlating alerts with recent deployments or config changes
  • Ranked root cause candidates based on evidence strength and impact analysis

Dependency Mapping & Health

  • Dynamic service dependency maps built from traffic correlation analysis
  • Cross-cluster dependency visualization showing service interoperation
  • Synthetic health probing to assess dependency resilience
  • Load shedding recommendations based on dependency fragility

Trend Analysis & Benchmarking

  • Historical pattern recognition for recurring alert schedules
  • Capacity forecasting to predict resource exhaustion
  • MTTR benchmarking comparing resolution times against historical data
  • Deviation detection triggering higher-priority notifications for pattern breaks

Integrated Analysis Tool

  • New federation_analyze_alerts tool combining all v4.0 features
  • Unified output format optimized for AI agent consumption
  • Comprehensive incident context in a single tool call

Installation

bash
pip install prometheus-mcp

Or run directly without installing:

bash
uvx prometheus-mcp

Configuration

All configuration is via environment variables:

VariableRequiredDefaultDescription
PROMETHEUS_URLYes—Prometheus server URL, e.g. https://prometheus.example.com (no trailing slash)
PROMETHEUS_TOKENNo—Bearer token (takes precedence over Basic auth)
PROMETHEUS_USERNAMENo—HTTP Basic auth username
PROMETHEUS_PASSWORDNo—HTTP Basic auth password
PROMETHEUS_SSL_VERIFYNotrueSet false for self-signed certificates

Copy .env.example to .env and fill in your values.

Claude Desktop / Claude Code setup

Add to your MCP config (claude_desktop_config.json or .claude/mcp.json):

json
{  "mcpServers": {    "prometheus": {      "command": "prometheus-mcp",      "env": {        "PROMETHEUS_URL": "https://prometheus.example.com",        "PROMETHEUS_TOKEN": "your-token-here"      }    }  }}

Or with uvx (no install required):

json
{  "mcpServers": {    "prometheus": {      "command": "uvx",      "args": ["prometheus-mcp"],      "env": {        "PROMETHEUS_URL": "https://prometheus.example.com"      }    }  }}

Docker

bash
docker run --rm -e PROMETHEUS_URL=https://prometheus.example.com prometheus-mcp

Example queries

Once configured, ask Claude:

  • "What metrics does Prometheus have about HTTP requests?"
  • "What is the current request rate for the payment service?"
  • "Show me CPU usage over the last hour with 5-minute resolution"
  • "Are there any firing alerts? What's their severity?"
  • "Which scrape targets are currently down and why?"
  • "How many node-exporter instances are up?"

Tool usage guide

prometheus_list_metrics

Returns all metric names Prometheus knows about. Use pattern to filter by substring (case-insensitive). Start here when you don't know which metrics are available. Output is capped at 500 metrics with a truncation hint.

prometheus_query

Execute an instant PromQL expression and get current values. Returns result type (vector/scalar/matrix/string), sample count, and per-sample labels and values.

Parameters:

  • query (required) — PromQL expression, e.g. up, rate(http_requests_total[5m])
  • time (optional) — RFC3339 or Unix timestamp; defaults to now

prometheus_query_range

Execute a PromQL expression over a time window. Returns one series per matching time series with timestamped values. Total data points across all series are capped at 5000.

Parameters:

  • query (required) — PromQL expression
  • start / end (required) — RFC3339 or Unix timestamps
  • step (required) — resolution like 15s, 1m, 5m

Prometheus rejects steps that would produce > 11,000 points per series (HTTP 422). Increase step or narrow the range if this happens.

Note: The Prometheus range API does not support filtering by branch or commit — filters are expressed purely in PromQL label matchers.

prometheus_list_alerts

Returns all active/pending alerts with labels (including alertname, severity), state, activation time, and current value. Includes a state summary (firing vs pending counts).

prometheus_list_targets

Returns scrape targets with job name, instance address, health (up/down/unknown), last scrape duration in milliseconds, and any error message. Includes a per-job summary. Filter by state: active (default), dropped, or any.

Performance characteristics

  • All tools use a single persistent requests.Session with connection pooling.
  • The session has trust_env = False to bypass environment proxies (Prometheus is typically an internal service).
  • Requests time out after 30 seconds.
  • prometheus_query_range caps output at 5000 total points across all series — use a larger step for long windows.
  • prometheus_list_metrics returns up to 500 metrics after filtering.

Development

bash
git clone https://github.com/mshegolev/prometheus-mcpcd prometheus-mcppip install -e '.[dev]'pytest tests/ -vruff check src testsruff format src tests

API Specification

This project includes an OpenAPI 3.0 specification in the specs/ directory that documents all MCP tools exposed by the server.

To validate the specification:

bash
python3 specs/validate_spec.py

Automation

This repository includes automated scripts and GitHub Actions workflows to streamline the release process:

Scripts

  • scripts/auto-commit-push.sh - Automatically commit and push changes with optional release trigger
  • scripts/release.sh - Full release automation including pipeline checking, version bumping, and tagging

GitHub Actions Workflows

  • post-push-check.yml - Monitors test pipeline status after each push and comments on the commit
  • auto-release.yml - Manual workflow to create releases with version bumping (patch, minor, or major)

To trigger an automated release:

  1. Go to the Actions tab in GitHub
  2. Select "Auto Release" workflow
  3. Run the workflow with your preferred version bump type

License

MIT — see LICENSE.

来源:README.md,提交 8dd31b5

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

其他 Prometheus 集成