home / mcp / prometheus mcp server
Provides an MCP gateway to Prometheus metrics collected via OpenTelemetry, with an HTTP interface for MCP clients to query metrics and generate PromQL.
Configuration
View docs{
"mcpServers": {
"fabriciodf-otel_prom_mcp_server": {
"url": "http://localhost:8082",
"headers": {
"LLAMA_MODEL": "llama3.2:1b",
"PROMETHEUS_URL": "http://prometheus:9090",
"PROMETHEUS_MCP_BIND_HOST": "0.0.0.0",
"PROMETHEUS_MCP_BIND_PORT": "8082",
"PROMETHEUS_MCP_SERVER_TRANSPORT": "http"
}
}
}
}This MCP server stack collects metrics from a FastAPI-based demo, enables PromQL generation via an LLM-backed UI, and exposes an MCP-compatible HTTP interface to query the Prometheus instance. It ties together OpenTelemetry metrics, a Prometheus-backed data plane, and an MCP client workflow for programmatic access to metrics data and PromQL insights.
You interact with the Prometheus MCP Server by connecting an MCP client to the HTTP endpoint exposed by the stack. Your client can query the Prometheus data available via the MCP server, or request PromQL expressions generated from natural language prompts through the UI. Typical usage flows include generating PromQL from natural language queries, running those queries against Prometheus through the MCP gateway, and inspecting the resulting metrics data.
Prerequisites you need before starting: Docker and Docker Compose installed on your machine. You should also have sufficient disk space to fetch the Ollama model (approximately 1–2 GB for llama3.2:1b).
Step by step commands you will run to set up and start the stack:
cd prometheus-ai
./scripts/install.sh
# or to skip model download if you already have it
./scripts/install.sh --skip-model-pull
# or perform a full reset (pulls images, rebuilds, starts, and pulls the Ollama model)
./run.sh
# If you did not use the automatic run script, start the services with Docker Compose
docker compose up -d
# If you skipped the Ollama model initially, pull it afterwards
docker exec prometheus-ai-ollama ollama pull llama3.2:1bEndpoint overview for quick access after the stack is running:
Demo API: http://localhost:8000/docs (health and item endpoints)
Prompt UI: http://localhost:8080 (generates PromQL via Llama3 and shows JSON and a natural-language interpretation in PT-BR)
Prometheus: http://localhost:9090
OTel Collector endpoints: OTLP gRPC http://localhost:4317, HTTP http://localhost:4318, metrics http://localhost:9464/metrics
MCP Server (HTTP): http://localhost:8082
This stack relies on environment configuration to wire the Prometheus instance into the MCP gateway and to control the Ollama-based Llama3 model. The primary MCP-facing configuration is exposed as environment variables when starting the MCP server container.
PROMETHEUS_URL=http://prometheus:9090
PROMETHEUS_MCP_SERVER_TRANSPORT=http
PROMETHEUS_MCP_BIND_HOST=0.0.0.0
PROMETHEUS_MCP_BIND_PORT=8082The MCP server is exposed over HTTP and connects to the Prometheus instance to serve metrics data and generated PromQL to MCP clients.
{
"mcpServers": {
"prometheus": {
"type": "http",
"name": "prometheus_mcp",
"url": "http://localhost:8082",
"args": []
}
}
}Common metrics you may see include the app-level metrics like demo_requests_total, demo_request_latency_ms, and demo_pending_orders, as well as standard HTTP/runtime metrics such as process_cpu_seconds_total and up. If you encounter issues, check live logs for app-service, ui-service, and otel-collector to trace data flow from the Demo API through the OpenTelemetry collector to Prometheus.
docker compose logs -f app-service ui-service otel-collectorThe stack exposes a set of endpoints for metrics and UI interactions. The MCP server endpoint is the primary entry for programmatic access via MCP clients.
Expose and collect application metrics through OpenTelemetry in the Demo API, including requests, latency, and order processing metrics.
UI component that uses an LLM (Ollama/Llama3) to generate PromQL from natural language prompts and display results.
Ollama-based Llama3 model used to translate natural language questions into PromQL queries.
MCP gateway that exposes an HTTP interface to query Prometheus data and PromQL expressions via MCP clients.