Skip to main content

Configuration

Complete configuration guide for the Prometheus MCP Server including environment variables, Docker setup, multi-backend configuration, and Kubernetes integration.


Prerequisites

RequirementDescription
PrometheusAccess to a Prometheus-compatible backend (Prometheus, Thanos, Mimir, Cortex, or VictoriaMetrics)
DockerFor containerized deployment (recommended)
Python 3.12+For local development
KubernetesOptional — required for exporter deployment, ServiceMonitor, and CRD features
Prometheus OperatorOptional — required for prom_apply_servicemonitor and CRD rule upsert

Installation Options

# Pull the latest image
docker pull talkopsai/prometheus-mcp-server:latest

# Run with default configuration
docker run --rm -it \
-p 8767:8767 \
-e PROMETHEUS_BASE_URL=http://host.docker.internal:9090 \
-e MCP_TRANSPORT=http \
talkopsai/prometheus-mcp-server:latest

# Run with Kubernetes access
docker run --rm -it \
-p 8767:8767 \
-v ~/.kube/config:/app/.kube/config:ro \
-e PROMETHEUS_BASE_URL=http://host.docker.internal:9090 \
-e MCP_TRANSPORT=http \
-e K8S_ENABLED=true \
talkopsai/prometheus-mcp-server:latest

Option 2: From Source (Python)

# Install uv if not already installed
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone the repository
git clone https://github.com/talkops-ai/talkops-mcp.git
cd talkops-mcp/src/prometheus-mcp-server

# Create virtual environment and install
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"

# Configure .env
cp .env.example .env
# Edit .env — at minimum set PROMETHEUS_BASE_URL

# Run the server
uv run prometheus-mcp-server

Run tests (with the venv activated):

pytest tests/

Environment Variables

Server Configuration

VariableDefaultDescription
MCP_SERVER_NAMEprometheus-mcp-serverServer name identifier
MCP_SERVER_VERSION0.1.0Server version string
MCP_TRANSPORTstdioTransport mode: http, sse, streamable-http, or stdio
MCP_HOST0.0.0.0Host address for HTTP server
MCP_PORT8767Port for HTTP server
MCP_PATH/mcpMCP endpoint path
MCP_LOG_LEVELINFOLog level: DEBUG, INFO, WARNING, ERROR
MCP_LOG_FORMATjsonLog format: json or text
MCP_HTTP_TIMEOUT300HTTP server timeout (seconds)
MCP_HTTP_KEEPALIVE_TIMEOUT5HTTP keepalive timeout (seconds)
MCP_HTTP_CONNECT_TIMEOUT60HTTP connect timeout (seconds)

Prometheus Backend (Single)

VariableDefaultDescription
PROMETHEUS_BASE_URLhttp://localhost:9090Prometheus HTTP API base URL
PROMETHEUS_BACKEND_IDdefaultBackend identifier used in all tool calls
PROMETHEUS_TYPEprometheusBackend type: prometheus, thanos, mimir, cortex, victoriametrics, other
PROMETHEUS_DISPLAY_NAME(empty)Human-readable backend name
PROMETHEUS_AUTH_HEADER(empty)Authorization header value (e.g. Bearer <token>)
PROMETHEUS_VERIFY_SSLtrueVerify SSL certificates
PROMETHEUS_TIMEOUT30HTTP timeout for Prometheus API calls (seconds)

Prometheus Backends (Multi)

For multiple backends, set PROMETHEUS_BACKENDS as a JSON array:

PROMETHEUS_BACKENDS='[
{"id": "prod", "base_url": "https://prom-prod.example.com", "type": "prometheus", "labels": {"env": "prod"}},
{"id": "staging", "base_url": "https://thanos-staging.example.com", "type": "thanos", "labels": {"env": "staging"}}
]'

When PROMETHEUS_BACKENDS is set, the single-backend env vars (PROMETHEUS_BASE_URL, etc.) are ignored. Each backend requires a unique id that becomes the backend_id in all tool calls.

Kubernetes

VariableDefaultDescription
K8S_CONTEXT(empty)Specific K8s context to use
K8S_IN_CLUSTERfalseSet true when running inside a pod
K8S_ENABLEDtrueEnable Kubernetes integration

MCP Client Configuration

The server listens on http://localhost:8767/mcp by default. Add this to your MCP client config:

{
"mcpServers": {
"prometheus": {
"url": "http://localhost:8767/mcp",
"description": "MCP Server for Prometheus observability and monitoring management"
}
}
}

For stdio transport (local process communication):

{
"mcpServers": {
"prometheus": {
"command": "uv",
"args": ["run", "prometheus-mcp-server"],
"env": {
"PROMETHEUS_BASE_URL": "http://localhost:9090",
"MCP_TRANSPORT": "stdio"
}
}
}
}

Troubleshooting

Backend Connection Issues

  1. Verify PROMETHEUS_BASE_URL points to a reachable Prometheus instance
  2. Load the prom://system/backends resource to check health status
  3. If using auth, verify PROMETHEUS_AUTH_HEADER is set correctly
  4. For SSL issues, try PROMETHEUS_VERIFY_SSL=false (development only)

Kubernetes Integration Issues

  1. Ensure K8S_ENABLED=true and your kubeconfig is accessible
  2. For in-cluster deployment, set K8S_IN_CLUSTER=true
  3. ServiceMonitor creation requires Prometheus Operator installed in the cluster

Query Timeout or Large Results

  1. The server auto-downsamples range queries to ~200 points per series
  2. Increase MCP_HTTP_TIMEOUT for slow backends
  3. Response limiting middleware caps payloads at 100KB — use more specific queries

Next Steps

  • Tools — Full reference for all 28 MCP tools
  • Resources — 14 MCP resources for discovery and monitoring
  • Common Workflows — Step-by-step workflow guides
  • Examples — Quick reference and natural language prompts