PR

Prometheus MCP Server: Query and Analyze Metrics

Query and analyze Prometheus metrics with the MCP server to monitor, visualize, and troubleshoot system performance in real time.

Quick Install
npx -y @pab1it0/prometheus-mcp-server

Overview

Prometheus MCP Server is a lightweight bridge that lets developers query and analyze Prometheus metrics through a simple HTTP API. It connects to an existing Prometheus server, exposes query endpoints, and formats the results for programmatic use — enabling real-time inspection, troubleshooting workflows, and integration with other tools or models that need metric context.

This server is useful when you want a dedicated, minimal layer between consumers (dashboards, automation scripts, or external systems) and Prometheus itself. Instead of calling Prometheus directly, teams can centralize access, apply consistent configuration, and integrate metric queries into automated analysis or monitoring pipelines.

Features

  • Exposes Prometheus query endpoints over a clean HTTP API
  • Supports instant and range PromQL queries (Prometheus HTTP API compatibility)
  • Configurable Prometheus target URL and server bind address
  • Docker-friendly: run as a container for easy deployment
  • Lightweight and easy to integrate into CI/CD or observability workflows
  • Returns JSON results ready for consumption by scripts, UIs, or other services

Installation / Configuration

Clone the repository and run locally, or use Docker.

Clone repository:

git clone https://github.com/pab1it0/prometheus-mcp-server.git
cd prometheus-mcp-server

Build and run with Go (if repository contains a Go server):

# Build
go build -o prometheus-mcp-server ./cmd/server

# Run with environment variables
PROMETHEUS_URL="http://localhost:9090" BIND_ADDR="0.0.0.0:8080" ./prometheus-mcp-server

Run with Docker:

# Build an image (optional)
docker build -t prometheus-mcp-server:latest .

# Run container
docker run -d \
  -e PROMETHEUS_URL="http://<prometheus-host>:9090" \
  -e BIND_ADDR="0.0.0.0:8080" \
  -p 8080:8080 \
  prometheus-mcp-server:latest

Example configuration (YAML):

prometheus:
  url: "http://prometheus.example.local:9090"

server:
  bind_addr: "0.0.0.0:8080"
  read_timeout: 10s
  write_timeout: 10s

Common environment variables:

  • PROMETHEUS_URL — full URL to the Prometheus HTTP API (required)
  • BIND_ADDR — host:port to bind the MCP server (default: 0.0.0.0:8080)
  • LOG_LEVEL — logging verbosity (optional)

Available Resources

The server exposes a small set of HTTP endpoints that mirror common Prometheus operations. Replace with your MCP host:port.

EndpointMethodDescription
/queryGETInstant PromQL query. Params: query, time (optional)
/query_rangeGETRange PromQL query. Params: query, start, end, step
/targetsGET(Optional) List Prometheus scrape targets (if proxied)
/healthGETHealth check for the MCP server

Example instant query:

curl -G "http://<server>/query" --data-urlencode 'query=up{job="api"}'

Example range query:

curl -G "http://<server>/query_range" \
  --data-urlencode 'query=rate(http_requests_total[5m])' \
  --data-urlencode 'start=2026-04-08T00:00:00Z' \
  --data-urlencode 'end=2026-04-08T01:00:00Z' \
  --data-urlencode 'step=60s'

Refer to the project repository for additional endpoints, health checks, and any custom routes added by the implementation.

Use Cases