Mcp Prometheus

io.github.jeanlopezxyz由 GitHub 账号 jeanlopezxyz 发布v2.1.1更新于 Oct 24, 2026

A Model Context Protocol (MCP) server for Prometheus monitoring

发布方自己的服务:Prometheus MCP

概览

AI 生成的概览

一个本地 MCP 服务器,将助手连接到 Prometheus,使其能执行 PromQL 查询并诊断 Kubernetes/OpenShift 集群健康状况。

可以做什么
对 Prometheus 执行 PromQL 即时查询和范围查询,并比较两个时间段之间的指标。查看抓取目标、告警与记录规则,以及服务器版本和运行时状态。获取集群健康概览,并诊断特定节点或命名空间。找出 CPU、内存和网络占用最高的对象,并深入排查单个 Pod。
适用场景
当你希望助手在 Kubernetes 或 OpenShift 环境中回答关于 Prometheus 指标、集群健康、资源占用或 Pod 问题,而无需自己运行 kubectl 或端口转发时,适合使用。
运行要求
通过 npx(Node.js)或 Go 二进制在本地运行。需要一个可访问的 Prometheus 端点,通过 PROMETHEUS_URL 环境变量或 --url 参数设置;或通过 kubeconfig 或集群内配置获得 Kubernetes 访问权限,以便经 K8s API 服务代理自动连接。命名空间、服务和端口可用命令行参数设置。
安装前请注意
Kubernetes 自动连接会使用你的 kubeconfig 或集群内凭据,助手因此能以你的身份访问集群监控数据。README 提到部署时可使用 cluster-reader RBAC 角色。请仅指向你有权查询的 Prometheus 实例。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Prometheus MCP Server (Go)

[License: MIT] [npm version] [Go] [GitHub release]

A Model Context Protocol (MCP) server for Prometheus integration. Native Go binary with built-in Kubernetes connectivity via client-go.

Installation

npx

bash
npx -y mcp-prometheus@latest

MCP Client Configuration

Add to your MCP client configuration (VS Code, Cursor, Windsurf, etc.):

json
{  "mcpServers": {    "prometheus": {      "command": "npx",      "args": ["-y", "mcp-prometheus@latest"],      "env": {        "PROMETHEUS_URL": "http://localhost:9090"      }    }  }}

VS Code

shell
code --add-mcp '{"name":"prometheus","command":"npx","args":["-y","mcp-prometheus@latest"],"env":{"PROMETHEUS_URL":"http://localhost:9090"}}'

Kubernetes Auto-Connect

Automatically connects to Prometheus running in OpenShift/Kubernetes via the K8S API service proxy. Uses native kubeconfig/in-cluster config via client-go. No kubectl or port-forwarding required.

Default: openshift-monitoring/prometheus-operated:9090

json
{  "mcpServers": {    "prometheus": {      "command": "npx",      "args": ["-y", "mcp-prometheus@latest"]    }  }}

Binary

Download from GitHub Releases or build from source:

bash
make build./mcp-prometheus

Configuration

Environment Variables

VariableDescription
PROMETHEUS_URLDirect Prometheus API URL (overrides K8S auto-connect)

CLI Flags

FlagDescriptionDefault
--urlDirect Prometheus URL-
--namespaceKubernetes namespaceopenshift-monitoring
--serviceKubernetes service nameprometheus-operated
--service-portKubernetes service port9090
--service-schemeService scheme (http/https)https
--kubeconfigPath to kubeconfig fileauto-detect

Precedence: --url / PROMETHEUS_URL > K8S auto-connect

Connection strategy:

  1. Direct URL (if --url or PROMETHEUS_URL is set)
  2. K8S API proxy (auto-detect kubeconfig or in-cluster config)

Tools (11)

Basic Queries

ToolDescription
queryExecute a PromQL instant query
queryRangeExecute a PromQL range query over time
getTargetsGet scrape targets status
getRulesGet alerting and recording rules
getPrometheusStatusGet server version and runtime info

Cluster Diagnostics

ToolDescription
getClusterHealthOverviewComprehensive cluster health overview
diagnoseNodeDiagnose a specific node's health
diagnoseNamespaceDiagnose a namespace's health

Resource Analysis

ToolDescription
getTopResourceConsumersTop CPU/memory/network consumers
investigatePodDeep investigation of a specific pod
compareTimeRangesCompare metrics between two time periods

Example Prompts

"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?"

Development

Build

bash
make build              # Build for current platformmake build-all-platforms # Cross-compile for all platforms

Container

bash
podman build -f Containerfile -t mcp-prometheus .

Kubernetes / OpenShift Deployment

Container Image

The container image is available on GitHub Container Registry:

ghcr.io/jeanlopezxyz/mcp-prometheus:latest

Helm Chart

Deploy using the included Helm chart:

bash
# 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 Values
ParameterDescriptionDefault
image.registryContainer registryghcr.io
image.repositoryImage repositoryjeanlopezxyz/mcp-prometheus
image.versionImage taglatest
openshiftEnable OpenShift Routesfalse
service.portService port8080
prometheus.namespacePrometheus namespaceopenshift-monitoring
prometheus.servicePrometheus service nameprometheus-operated
rbac.useClusterReaderUse cluster-reader roletrue
Example with custom Prometheus
bash
helm upgrade --install mcp-prometheus ./charts/mcp-prometheus \  --namespace mcp-servers \  --set openshift=true \  --set prometheus.url=http://prometheus.monitoring:9090

License

MIT

来源:README.md,提交 4b7c47b

工具

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

版本历史

1
  1. v2.1.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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

其他 Prometheus 集成