prom-mcp

io.github.aniketatgithubv0.2.0更新於 Oct 9, 2026

Prometheus MCP server for AI agents: PromQL queries, alert explanations, series discovery.

概覽

AI 產生的概覽

讓 AI 助理用 PromQL 查詢 Prometheus、結合規則定義解釋正在觸發的告警,並探索實際存在的序列與標籤值。

功能
一個本機 Prometheus MCP 伺服器,提供五個工具:prom_query 執行即時 PromQL 查詢,prom_query_range 對時間範圍查詢依序列彙總,prom_alerts_explain 將作用中的告警與規則運算式、規則群組、for 時長與註解關聯起來,prom_label_values 列出真實標籤值,prom_series_discover 檢查哪些序列存在。另提供 prometheus://alerts 與 prometheus://config 資源以及 triage 提示詞。輸出為精簡的帶標籤文字,而非原始 JSON。
適用情境
適合助理需要排查指標或處理 Prometheus 告警的情境,例如詢問某個告警為何觸發、有哪些 job 與 instance。面向值班與監控工作流程,讓助理在查詢前先探索真實的指標名稱。
執行需求
以本機程序透過 stdio 執行;以 macOS 與 Linux 的 MCPB 套件以及 Go 二進位檔(go install 或從原始碼建置)發佈。需要可連線的 Prometheus HTTP API 位址,透過 PROM_URL 設定(預設 PROM_TOKEN 用於受驗證保護的 Prometheus,PROM_TIMEOUT 設定請求逾時,PROM_CONFIG 指定 JSON 設定檔路徑。
安裝前請注意
PROM_TOKEN 是用於受驗證保護 Prometheus 的 bearer 權杖,應以密鑰方式提供,不要提交到版本庫。此伺服器會從你的 Prometheus 讀取指標與告警資料並傳送給 AI 用戶端,因此查詢結果會離開你的環境。它對 Prometheus 為唯讀;未描述寫入、刪除或付款操作。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 prom-mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

prom-mcp — Prometheus MCP Server for AI Agents (Claude Code, Cursor)

[CI] [Go] [License: MIT] [MCP Registry]

prom-mcp is a Prometheus MCP server (Model Context Protocol) that gives AI agents production-grade eyes on your metrics. Connect Claude Code, Cursor, or any MCP client to Prometheus and let the agent run PromQL queries, explain firing alerts with their rule definitions, and discover which series actually exist before querying — so it investigates instead of guessing.

Built by a production engineer who works on-call, so the output reads like a triage note, not a raw JSON dump.

5 tools • 2 resources • 1 triage prompt • single Go binary • zero dependencies • stdio

[prom-mcp demo: agent asks why a node is down, prom-mcp explains the firing alert with its rule, then checks up{job="node"}]

Install

Claude Desktop (MCPB, no toolchain needed)

Download the bundle for your platform, then open it or drag it into Claude Desktop (Settings → Extensions). You will be asked for your Prometheus URL, which defaults to http://localhost:9090.

Claude Code

With the binary on your PATH (release download or go install, see below):

bash
claude mcp add prom -- prom-mcp

Set PROM_URL in your shell first if your Prometheus is not at http://localhost:9090, or pass --env PROM_URL=... to the command. More variants in examples/claude-code.md.

Cursor

Add to ~/.cursor/mcp.json (same file as examples/cursor-mcp.json):

json
{  "mcpServers": {    "prom": {      "command": "prom-mcp",      "env": {        "PROM_URL": "http://localhost:9090"      }    }  }}

VS Code

Add to .vscode/mcp.json (same file as examples/vscode-mcp.json):

json
{  "servers": {    "prom": {      "command": "prom-mcp",      "env": {        "PROM_URL": "http://localhost:9090"      }    }  }}

Go install / build from source

bash
go install github.com/aniketatgithub/prom-mcp@latest
bash
git clone https://github.com/aniketatgithub/prom-mcp && cd prom-mcpgo build -o prom-mcp ./cmd/prom-mcp

Plain binaries for all four platforms are also on the v0.2.0 release, next to the MCPB bundles above.

What to ask

You askprom-mcp does
"Why is NodeDown firing?"prom_alerts_explain returns the active alert joined with its rule expression, group, for, labels, and annotations.
"What jobs and instances actually exist?"prom_series_discover and prom_label_values list real series and label values before any query is written.
"Is this getting worse?"prom_query_range summarizes the window per series: points, first, last, min, max.

See it in action

Alert triage: why is the node down?

[prom-mcp alert triage demo]

Discover what exists before querying:

[prom-mcp discovery demo: series discovery and label values for the node job]

Check the trend: is node1 getting worse?

[prom-mcp range query demo: up for the node job over the last 5 minutes]

What it looks like

Ask your agent "why is the node down?" and the alert tool answers in triage shape:

text
1 active alert(s)
[firing] NodeDown (since 2026-10-08T10:00:00Z, value 0)  labels: {alertname="NodeDown", instance="node1:9100", job="node", severity="critical"}  summary: Node node1:9100 is down  description: Scrapes failing for 5m  rule: up{job="node"} == 0  group: node.rules  for: 5m0s

Plus a built-in triage prompt template that walks the agent through alerts, discovery, and trend checks in order.

Tools

ToolWhat it does
prom_queryInstant PromQL query, rendered as compact labelled series and values.
prom_query_rangeRange query over the last N minutes; per-series points, first, last, min, max.
prom_alerts_explainActive alerts joined with alerting-rule expressions, rule group, for duration, and annotations.
prom_label_valuesLists real values of a label (optionally scoped), so the agent learns actual job/instance names.
prom_series_discoverChecks which series exist for a label matcher, so the agent stops hallucinating metric names.

Resources: prometheus://alerts (explained alerts), prometheus://config. Prompt: triage.

Try it with no server

bash
prom-mcp demo        # fixture-backed self-test: query, alert explanation, series discoveryprom-mcp query 'up'  # one-shot CLI query against $PROM_URL

Configuration

SettingEnv varConfig file key
Prometheus base URLPROM_URLbase_url
Bearer token (auth-protected Prometheus)PROM_TOKENtoken
Request timeoutPROM_TIMEOUT (e.g. 30s)timeout_seconds
Config file pathPROM_CONFIG

Config file is JSON, looked up at $PROM_CONFIG, then ./prom-mcp.json, then ~/.prom-mcp.json:

json
{ "base_url": "https://prometheus.example.com", "token": "…", "timeout_seconds": 30 }

Env vars override the file. No config at all defaults to http://localhost:9090.

Why not just give the agent raw API access?

Agents drown in raw Prometheus JSON and invent metric names that do not exist. prom-mcp returns terse, labelled, triage-shaped text and makes the agent discover before querying. That is the difference between an agent that guesses and an agent that investigates.

Single Go binary, zero dependencies, works fully offline against your own Prometheus.

Comparing servers? See docs/comparison.md for an honest side-by-side with pab1it0/prometheus-mcp-server and the Prometheus org's prometheus/prometheus-mcp.

FAQ

Which AI clients work with prom-mcp? Any MCP client: Claude Code, Cursor, Windsurf, Zed, and custom agents. It speaks newline-delimited JSON-RPC 2.0 over stdio.

How do I connect prom-mcp to a remote Prometheus? Set PROM_URL to your Prometheus base URL (for example http://localhost:9090 or your internal endpoint) when adding the server.

Can an AI agent explain why a Prometheus alert is firing? Yes. prom_alerts_explain joins active alerts with the rule that fired them (expression, summary, description), so the agent can reason about the cause instead of reporting raw JSON.

Does prom-mcp need any API keys or cloud services? No. It is a single local binary talking only to your Prometheus.

How does prom-mcp compare to the other Prometheus MCP servers? See docs/comparison.md. Short version: prom-mcp is the focused alert-triage option with 5 tools; the others cover more of the Prometheus API or ship more deployment machinery.

How is this different from exposing the Prometheus HTTP API to an agent? Raw API access returns nested JSON the agent must parse and invites invented metric names. prom-mcp renders compact labelled text, joins alerts with the rules that fired them, caps long outputs, and nudges discovery before querying. It also retries transient failures and supports bearer-token auth.

Does it work with a remote or auth-protected Prometheus? Yes: set PROM_URL and PROM_TOKEN (or a JSON config file). See Configuration.

Which Prometheus versions are supported? Any server exposing the standard HTTP API (/api/v1/query, query_range, alerts, rules, series, label/<name>/values).

License

MIT. See LICENSE.

來源:README.md,提交 d6358e9

工具

0
工具後設資料尚未被收錄。

版本歷史

1
  1. v0.2.0最新Oct 9, 2026