prometheus-rs
Query Prometheus from CLI or any MCP client, with retries, caching, and an optional metrics exporter.
README
Prometheus MCP Server
A minimal Model Context Protocol (MCP) server focused on reading from Prometheus. It exposes Prometheus discovery and query tools to MCP-compatible apps and includes a convenient CLI for local queries.
Highlights
- Instant and range queries via Prometheus HTTP API
- Discovery helpers: list metrics, get metadata, series selectors, label values
- Optional internal metrics exporter at /metrics (disabled by default)
- Works as a stdio MCP server or a one-off CLI
Container images
Images are published to both Docker Hub and GHCR:
- Docker Hub:
brenoepics/prometheus-mcp - GHCR:
ghcr.io/brenoepics/prometheus-mcp
Quickstart
Pick your preferred install method.
- From crates.io (installs the
prometheus-mcpbinary):
cargo install prometheus-mcp
prometheus-mcp --help
-
Prebuilt binaries (GitHub Releases):
- Download the latest release for your OS/arch: https://github.com/brenoepics/prometheus-mcp/releases
-
Docker (pull from Docker Hub or GHCR):
# Docker Hub
docker pull brenoepics/prometheus-mcp:latest
# or GHCR
docker pull ghcr.io/brenoepics/prometheus-mcp:latest
# Run the MCP server against a local Prometheus (pick one image)
docker run --rm -it brenoepics/prometheus-mcp:latest --mcp \
--prometheus-url http://host.docker.internal:9090
Installation
Build from source (Rust):
cargo build --release
# binary at ./target/release/prometheus-mcp
Or build a Docker image locally:
docker build -t prometheus-mcp:latest .
Usage (CLI)
The CLI mirrors the tools exposed over MCP.
- Instant query
prometheus-mcp query --query 'up' --prometheus-url http://localhost:9090
# optionally set an evaluation time
prometheus-mcp query --query 'up' --time '2025-09-27T12:00:00Z'
- Range query
prometheus-mcp range --query 'rate(http_requests_total[5m])' \
--start '2025-09-27T12:00:00Z' --end '2025-09-27T13:00:00Z' --step '30s'
- List metric names
prometheus-mcp list-metrics
- Metric metadata
prometheus-mcp metadata --metric 'up'
- Series selectors (repeat --selector)
prometheus-mcp series --selector 'up' --selector 'node_cpu_seconds_total{mode="idle"}'
- Label values
prometheus-mcp label-values --label 'job'
MCP server (stdio)
Start the MCP server over stdio:
prometheus-mcp --mcp --prometheus-url http://localhost:9090
Optional: enable internal metrics at /metrics (default off):
prometheus-mcp --mcp --metrics-exporter --metrics-port 9091
Running in Docker
Use the published image from Docker Hub (or GHCR alternative shown):
# Start the MCP server (macOS/Windows: host.docker.internal works; Linux see alternatives below)
docker run --rm -it brenoepics/prometheus-mcp:latest --mcp \
--prometheus-url http://host.docker.internal:9090
Linux alternatives when Prometheus runs on the host:
# Use host networking (Linux only)
docker run --rm -it --network host brenoepics/prometheus-mcp:latest --mcp \
--prometheus-url http://localhost:9090
# Without host network: map host gateway and use host.docker.internal
docker run --rm -it --add-host=host.docker.internal:host-gateway \
brenoepics/prometheus-mcp:latest --mcp \
--prometheus-url http://host.docker.internal:9090
One-off CLI in the container:
# Instant query
docker run --rm brenoepics/prometheus-mcp:latest query --query 'up' \
--prometheus-url http://host.docker.internal:9090
# Range query
docker run --rm brenoepics/prometheus-mcp:latest range --query 'rate(http_requests_total[5m])' \
--start '2025-09-27T12:00:00Z' --end '2025-09-27T13:00:00Z' --step '30s' \
--prometheus-url http://host.docker.internal:9090
Basic Auth
Pass credentials via environment variables or CLI flags.
- Environment variables:
export PROMETHEUS_URL=https://prom.example.com
export PROMETHEUS_USERNAME=api
export PROMETHEUS_PASSWORD=secret
prometheus-mcp --mcp
- CLI flags:
prometheus-mcp --mcp \
--prometheus-url https://prom.example.com \
--prometheus-username api \
--prometheus-password secret
- Docker with env vars:
docker run --rm -it \
-e PROMETHEUS_URL=https://prom.example.com \
-e PROMETHEUS_USERNAME=api \
-e PROMETHEUS_PASSWORD=secret \
brenoepics/prometheus-mcp:latest --mcp
Configuration
All settings can be provided via environment variables; some also via flags.
| Name | Type | Default | CLI flag | Description |
|---|---|---|---|---|
| PROMETHEUS_URL | string (URL) | http://localhost:9090 | --prometheus-url | Base URL of your Prometheus server |
| PROMETHEUS_TIMEOUT | integer (seconds) | 10 | — | HTTP request timeout |
| PROMETHEUS_RETRIES | integer | 3 | — | Number of retries for Prometheus API calls |
| PROMETHEUS_RETRY_BACKOFF_MS | integer (ms) | 500 | — | Time to wait between retries |
| PROMETHEUS_MIN_INTERVAL_MS | integer (ms) | — | — | Minimum interval between query requests (basic rate limit) |
| PROMETHEUS_CACHE_TTL_SECS | integer (seconds) | — | — | TTL for simple in-process caches (list metrics and label values) |
| PROMETHEUS_USERNAME | string | — | --prometheus-username | Basic auth username |
| PROMETHEUS_PASSWORD | string | — | --prometheus-password | Basic auth password |
| — | boolean | false | --mcp | Start MCP server over stdio |
| — | boolean | false | --metrics-exporter | Enable internal Prometheus metrics at /metrics |
| — | integer (port) | 9091 | --metrics-port | Port for /metrics when exporter is enabled |
See docs/configuration.md for notes and examples.
Accessing from Claude Desktop
Follow the official guide to locate claude_desktop_config.json:
https://modelcontextprotocol.io/quickstart/user#for-claude-desktop-users
Minimal Docker-based entry:
{
"mcpServers": {
"prometheus": {
"command": "docker",
"args": ["run", "--rm", "-i", "brenoepics/prometheus-mcp:latest"]
}
}
}
With host Prometheus and exporter (macOS/Windows):
{
"mcpServers": {
"prometheus": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-p", "9091:9091",
"brenoepics/prometheus-mcp:latest",
"--mcp",
"--prometheus-url", "http://host.docker.internal:9090",
"--metrics-exporter",
"--metrics-port", "9091"
]
}
}
}
With Basic Auth via environment variables:
{
"mcpServers": {
"prometheus": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "PROMETHEUS_URL=https://prom.example.com",
"-e", "PROMETHEUS_USERNAME=api",
"-e", "PROMETHEUS_PASSWORD=secret",
"brenoepics/prometheus-mcp:latest", "--mcp"
]
}
}
}
More examples: see docs/claude-desktop.md.
Debugging
Use the MCP Inspector to exercise the server interactively:
npx @modelcontextprotocol/inspector
Connect with transport "STDIO", command prometheus-mcp, and optional args --mcp --prometheus-url http://localhost:9090.
Logs are appended to /tmp/mcp.jsonl; tail it with:
tail -f /tmp/mcp.jsonl
Security Considerations
- The server does not provide authentication itself; when running outside stdio, keep it on localhost.
- Handle credentials via environment variables or your secret manager. Avoid committing secrets.
License
Apache-2.0
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。