Provides tools for querying Prometheus metrics through instant and range queries, discovering metrics and metadata, retrieving series selectors and label values via the Prometheus HTTP API.
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-mcp
binary):
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):
Installation
Build from source (Rust):
Or build a Docker image locally:
Usage (CLI)
The CLI mirrors the tools exposed over MCP.
Instant query
Range query
List metric names
Metric metadata
Series selectors (repeat --selector)
Label values
MCP server (stdio)
Start the MCP server over stdio:
Optional: enable internal metrics at /metrics (default off):
Running in Docker
Use the published image from Docker Hub (or GHCR alternative shown):
Linux alternatives when Prometheus runs on the host:
One-off CLI in the container:
Basic Auth
Pass credentials via environment variables or CLI flags.
Environment variables:
CLI flags:
Docker with env vars:
Configuration
All settings can be provided via environment variables; some also via flags.
Name | Type | Default | CLI flag | Description |
PROMETHEUS_URL | string (URL) | --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:
With host Prometheus and exporter (macOS/Windows):
With Basic Auth via environment variables:
More examples: see docs/claude-desktop.md.
Debugging
Use the MCP Inspector to exercise the server interactively:
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:
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
This server cannot be installed
Query Prometheus from CLI or any MCP client, with retries, caching, and an optional metrics exporter.