MCP server for Prometheus — query metrics, inspect alerts, and explore scrape targets (read-only).
Project description
prometheus-mcp
MCP server for Prometheus metrics and observability. Give Claude (or any MCP-capable agent) read access to your Prometheus instance — query metrics with PromQL, inspect active alerts, and explore scrape targets — without leaving the conversation.
Why another Prometheus MCP?
The existing Prometheus integrations require custom scripts or direct API knowledge. This server:
- Speaks the standard Model Context Protocol over stdio — works with Claude Desktop, Claude Code, Cursor, and any MCP client.
- Is read-only: all 5 tools carry
readOnlyHint: true— zero risk of modifying Prometheus data. - Returns dual-channel output: structured JSON (
structuredContent) for programmatic use + Markdown (content) for human-readable display. - Has actionable error messages that name the exact env var to fix and suggest a next step.
- Supports Bearer token, HTTP Basic auth, or no auth (common for internal deployments).
Tools
| Tool | Endpoint | Description |
|---|---|---|
prometheus_list_metrics |
GET /api/v1/label/__name__/values |
List all metric names with optional substring filter (cap 500) |
prometheus_query |
GET /api/v1/query |
Execute an instant PromQL query |
prometheus_query_range |
GET /api/v1/query_range |
Execute a PromQL range query returning time-series |
prometheus_list_alerts |
GET /api/v1/alerts |
List active and pending alerts |
prometheus_list_targets |
GET /api/v1/targets |
List scrape targets by health and job |
Installation
pip install prometheus-mcp
Or run directly without installing:
uvx prometheus-mcp
Configuration
All configuration is via environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
PROMETHEUS_URL |
Yes | — | Prometheus server URL, e.g. https://prometheus.example.com (no trailing slash) |
PROMETHEUS_TOKEN |
No | — | Bearer token (takes precedence over Basic auth) |
PROMETHEUS_USERNAME |
No | — | HTTP Basic auth username |
PROMETHEUS_PASSWORD |
No | — | HTTP Basic auth password |
PROMETHEUS_SSL_VERIFY |
No | true |
Set false for self-signed certificates |
Copy .env.example to .env and fill in your values.
Claude Desktop / Claude Code setup
Add to your MCP config (claude_desktop_config.json or .claude/mcp.json):
{
"mcpServers": {
"prometheus": {
"command": "prometheus-mcp",
"env": {
"PROMETHEUS_URL": "https://prometheus.example.com",
"PROMETHEUS_TOKEN": "your-token-here"
}
}
}
}
Or with uvx (no install required):
{
"mcpServers": {
"prometheus": {
"command": "uvx",
"args": ["prometheus-mcp"],
"env": {
"PROMETHEUS_URL": "https://prometheus.example.com"
}
}
}
}
Docker
docker run --rm -e PROMETHEUS_URL=https://prometheus.example.com prometheus-mcp
Example queries
Once configured, ask Claude:
- "What metrics does Prometheus have about HTTP requests?"
- "What is the current request rate for the payment service?"
- "Show me CPU usage over the last hour with 5-minute resolution"
- "Are there any firing alerts? What's their severity?"
- "Which scrape targets are currently down and why?"
- "How many node-exporter instances are up?"
Tool usage guide
prometheus_list_metrics
Returns all metric names Prometheus knows about. Use pattern to filter by substring (case-insensitive). Start here when you don't know which metrics are available. Output is capped at 500 metrics with a truncation hint.
prometheus_query
Execute an instant PromQL expression and get current values. Returns result type (vector/scalar/matrix/string), sample count, and per-sample labels and values.
Parameters:
query(required) — PromQL expression, e.g.up,rate(http_requests_total[5m])time(optional) — RFC3339 or Unix timestamp; defaults to now
prometheus_query_range
Execute a PromQL expression over a time window. Returns one series per matching time series with timestamped values. Total data points across all series are capped at 5000.
Parameters:
query(required) — PromQL expressionstart/end(required) — RFC3339 or Unix timestampsstep(required) — resolution like15s,1m,5m
Prometheus rejects steps that would produce > 11,000 points per series (HTTP 422). Increase step or narrow the range if this happens.
Note: The Prometheus range API does not support filtering by branch or commit — filters are expressed purely in PromQL label matchers.
prometheus_list_alerts
Returns all active/pending alerts with labels (including alertname, severity), state, activation time, and current value. Includes a state summary (firing vs pending counts).
prometheus_list_targets
Returns scrape targets with job name, instance address, health (up/down/unknown), last scrape duration in milliseconds, and any error message. Includes a per-job summary. Filter by state: active (default), dropped, or any.
Performance characteristics
- All tools use a single persistent
requests.Sessionwith connection pooling. - The session has
trust_env = Falseto bypass environment proxies (Prometheus is typically an internal service). - Requests time out after 30 seconds.
prometheus_query_rangecaps output at 5000 total points across all series — use a larger step for long windows.prometheus_list_metricsreturns up to 500 metrics after filtering.
Development
git clone https://github.com/mshegolev/prometheus-mcp
cd prometheus-mcp
pip install -e '.[dev]'
pytest tests/ -v
ruff check src tests
ruff format src tests
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prometheus_mcp-0.1.0.tar.gz.
File metadata
- Download URL: prometheus_mcp-0.1.0.tar.gz
- Upload date:
- Size: 28.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6db7d6ee7e44e2318172711a8b4a1837aa396f3de3c2d8e006132694a4199f7c
|
|
| MD5 |
fd57dde705e32863ddefbe45555d2e1c
|
|
| BLAKE2b-256 |
f9735ac58003a3a6985ae30fabe0e64d9c2ce281be97528e51db86f9fe84c6e6
|
Provenance
The following attestation bundles were made for prometheus_mcp-0.1.0.tar.gz:
Publisher:
publish.yml on mshegolev/prometheus-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prometheus_mcp-0.1.0.tar.gz -
Subject digest:
6db7d6ee7e44e2318172711a8b4a1837aa396f3de3c2d8e006132694a4199f7c - Sigstore transparency entry: 1338442542
- Sigstore integration time:
-
Permalink:
mshegolev/prometheus-mcp@0171a1cdb98d8d5137da06a5a754d9bcef8c326d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mshegolev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0171a1cdb98d8d5137da06a5a754d9bcef8c326d -
Trigger Event:
push
-
Statement type:
File details
Details for the file prometheus_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: prometheus_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9975860c74883ba6ecbf17dd9a10dd683d2481e3b594318b6b0b1f97fc383681
|
|
| MD5 |
7fc3053dfc9a9dbcdd05fbbc0ab7964a
|
|
| BLAKE2b-256 |
8759d17c0fb6c5f1cd6bc927cc2a0115b44caae6116f27d33f2208d1d681b280
|
Provenance
The following attestation bundles were made for prometheus_mcp-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on mshegolev/prometheus-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prometheus_mcp-0.1.0-py3-none-any.whl -
Subject digest:
9975860c74883ba6ecbf17dd9a10dd683d2481e3b594318b6b0b1f97fc383681 - Sigstore transparency entry: 1338442666
- Sigstore integration time:
-
Permalink:
mshegolev/prometheus-mcp@0171a1cdb98d8d5137da06a5a754d9bcef8c326d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mshegolev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0171a1cdb98d8d5137da06a5a754d9bcef8c326d -
Trigger Event:
push
-
Statement type: