| Crates.io | prometheus-mcp |
| lib.rs | prometheus-mcp |
| version | 0.0.1 |
| created_at | 2025-09-28 09:47:33.141919+00 |
| updated_at | 2025-09-28 09:47:33.141919+00 |
| description | Prometheus Model Context Protocol (MCP) Rust server |
| homepage | https://github.com/brenoepics/prometheus-mcp |
| repository | https://github.com/brenoepics/prometheus-mcp |
| max_upload_size | |
| id | 1858176 |
| size | 180,634 |
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
Build from source (Rust):
cargo build --release
# binary at ./target/release/prometheus-mcp
Or build a Docker image:
docker build -t prometheus-mcp:latest .
The CLI mirrors the tools exposed over MCP.
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'
prometheus-mcp range --query 'rate(http_requests_total[5m])' \
--start '2025-09-27T12:00:00Z' --end '2025-09-27T13:00:00Z' --step '30s'
prometheus-mcp list-metrics
prometheus-mcp metadata --metric 'up'
prometheus-mcp series --selector 'up' --selector 'node_cpu_seconds_total{mode="idle"}'
prometheus-mcp label-values --label 'job'
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
Build the image:
docker build -t prometheus-mcp:latest .
Run the MCP server:
# Linux: easiest if Prometheus is on the host at :9090
docker run --rm -it --network host prometheus-mcp:latest --mcp \
--prometheus-url http://localhost:9090
# macOS/Windows: use host.docker.internal
docker run --rm -it prometheus-mcp:latest --mcp \
--prometheus-url http://host.docker.internal:9090
# Linux without host network: map host gateway
docker run --rm -it --add-host=host.docker.internal:host-gateway \
prometheus-mcp:latest --mcp \
--prometheus-url http://host.docker.internal:9090
One-off CLI in the container:
# Instant query
docker run --rm prometheus-mcp:latest query --query 'up' \
--prometheus-url http://host.docker.internal:9090
# Range query
docker run --rm 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
Pass credentials via environment variables or CLI flags.
export PROMETHEUS_URL=https://prom.example.com
export PROMETHEUS_USERNAME=api
export PROMETHEUS_PASSWORD=secret
prometheus-mcp --mcp
prometheus-mcp --mcp \
--prometheus-url https://prom.example.com \
--prometheus-username api \
--prometheus-password secret
docker run --rm -it \
-e PROMETHEUS_URL=https://prom.example.com \
-e PROMETHEUS_USERNAME=api \
-e PROMETHEUS_PASSWORD=secret \
prometheus-mcp:latest --mcp
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.
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", "prometheus-mcp:latest"]
}
}
}
With host Prometheus and exporter (macOS/Windows):
{
"mcpServers": {
"prometheus": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-p", "9091:9091",
"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",
"prometheus-mcp:latest", "--mcp"
]
}
}
}
More examples: see docs/claude-desktop.md.
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
Apache-2.0