
prom-mcp
io.github.aniketatgithubv0.2.0更新于 Oct 9, 2026
Prometheus MCP server for AI agents: PromQL queries, alert explanations, series discovery.
概览
让 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 配置文件路径。
安装
在 SourceWeft 中
- 打开 控制台中的 prom-mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
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
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):
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):
VS Code
Add to .vscode/mcp.json (same file as examples/vscode-mcp.json):
Go install / build from source
Plain binaries for all four platforms are also on the v0.2.0 release, next to the MCPB bundles above.
What to ask
See it in action
Alert triage: why is the node down?
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:
Plus a built-in triage prompt template that walks the agent through alerts, discovery, and trend checks in order.
Tools
Resources: prometheus://alerts (explained alerts), prometheus://config. Prompt: triage.
Try it with no server
Configuration
Config file is JSON, looked up at $PROM_CONFIG, then ./prom-mcp.json, then ~/.prom-mcp.json:
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- v0.2.0最新Oct 9, 2026


