Prometheus MCP (prometheus-mcp)
Use the prometheus-mcp MCP tools as the primary interface for discovering metrics, checking scrape target health, and running instant or range PromQL queries.
Core Workflows
- Verify server & Prometheus connectivity: Call
health_checkto inspect transport/auth configuration status and verify a liveupquery against Prometheus. - Discover metrics & labels before querying:
- Call
list_metricswithfilter_pattern(case-insensitive substring) andlimit/offsetto find exact metric names without dumping the full catalog. - Call
get_metric_metadatawithmetric(orfilter_pattern+limit/offsetin bulk mode) to checktype(counter,gauge,histogram,summary),help, andunit.
- Call
- Check scrape target health: Call
get_targets(state="active"by default; optionally narrow byscrape_pooland paginate withlimit/offset) to verify targethealth,lastError, and scrape labels. - Run PromQL queries:
- Instant state or firing alerts (
up,ALERTS{alertstate="firing"}, gauge snapshots): useexecute_query(query, time?). - Rates/trends over time (
rate(...),irate(...)): useexecute_range_query(query, start, end, step)with RFC3339 or Unix timestamps and step widths like"15s","1m", or"1h".
- Instant state or firing alerts (
Read references/tools-reference.md for exact parameters, return shapes, and common PromQL patterns.
Gotchas
- PromQL-only (6 tools): There are no separate REST tools for alerts, rules, series, or label values—query alerts via
ALERTS{alertstate="firing"}and discover series/labels via PromQL (group by (...) (...)orcount by (...) (...)) withexecute_query. - 5-minute
list_metricscache: Metric names from/api/v1/label/__name__/valuesare cached in memory for300seconds. Passrefresh_cache: trueafter adding new exporters or scrape targets. get_targetsdefaults tostate="active": Dropped targets include fulldiscoveredLabelsand can be huge. Only passstate="dropped"orstate="any"when debugging relabeling, and combine withscrape_pool+limit.get_metric_metadatareturns two different shapes: Passingmetric="<name>"returns a legacylistof entries; omittingmetricreturns a paginateddict({metadata, total_count, returned_count, offset, has_more}).- Multi-instance
TOOL_PREFIX: SettingTOOL_PREFIX=<name>renames every tool to<name>_<tool_name>(e.g.,prod_execute_query). - Context-token saving: Set
PROMETHEUS_DISABLE_LINKS=trueon the server to omitlinksarrays (View in Prometheus UI) from query responses.
Connection Setup
Read references/setup-and-config.md when deploying ghcr.io/pab1it0/prometheus-mcp-server or prometheus-mcp-server, configuring http/sse/stdio transports (PROMETHEUS_MCP_STATELESS_HTTP), or setting TLS/auth variables.


