Sign inSign up

talkopsai/prometheus-mcp-server

By talkopsai

•Updated 4 months ago

MCP server for AI-driven Prometheus monitoring — PromQL, exporters, TSDB FinOps, and alerting

Image
Machine learning & AI
Developer tools
Monitoring & observability
0

5.0K

talkopsai/prometheus-mcp-server repository overview

⁠Prometheus MCP Server

A comprehensive Model Context Protocol (MCP) server that gives AI assistants the power to query, instrument, and manage Prometheus monitoring — from backend discovery to exporter deployment, PromQL execution, TSDB optimization, and governance. Supports Prometheus, Thanos, Mimir, Cortex, and VictoriaMetrics.

⁠✨ Features

  • Safe PromQL Execution: Counter enforcement (counters must use rate()/increase()), automatic range-query downsampling to ~200 points per series, and query validation before execution.
  • Application Onboarding: Recommend instrumentation strategy (direct library, exporter, or builtin metrics), generate code snippets for Go/Java/Python/Node.js, validate /metrics endpoints, and wire up ServiceMonitors.
  • Exporter Lifecycle: Built-in catalog of 19 exporters with one-command Kubernetes deployment — including RBAC, ConfigMaps, DaemonSets, and multi-manifest orchestration.
  • TSDB FinOps & Cardinality Control: Analyze top cardinality metrics, generate relabel configs, create recording rules, and configure remote-write to Thanos/Mimir/Cortex.
  • Rule Management & Testing: Draft, upsert, delete, and simulate alerting and recording rules — with promtool validation and historical firing analysis baked in.
  • Multi-Backend Support: Manage multiple Prometheus-compatible backends with explicit backend_id on every call — no hidden defaults.
  • Governance & Security: Scoped access policies per backend (whitelist/blacklist/read-only) and in-memory audit logging.
  • Production-Ready Middleware: Response limiting (100KB max), rate limiting (10 req/s, burst 20), response caching, structured logging, and error handling.

⁠🚀 How to Use This Image

This Docker image runs an MCP server that connects to your Prometheus-compatible backend(s). AI assistants (Claude, Cline, Cursor, or any MCP client) connect to the server over HTTP, SSE, or stdio.

⁠Running Standalone (HTTP Transport)
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

The server is now listening on http://localhost:8767/mcp.

Then configure your MCP client to connect:

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

To enable exporter deployment and ServiceMonitor management, mount your kubeconfig:

docker run --rm -it \
  -p 8767:8767 \
  -v ~/.kube:/app/.kube:ro \
  -e PROMETHEUS_BASE_URL=http://host.docker.internal:9090 \
  -e K8S_KUBECONFIG=/app/.kube/config \
  -e MCP_TRANSPORT=http \
  talkopsai/prometheus-mcp-server:latest

Tip: Mount the full ~/.kube directory (not just config) so certificate paths referenced in your kubeconfig are available inside the container.

⁠Multi-Backend Setup

Connect to multiple Prometheus-compatible backends simultaneously:

docker run --rm -it \
  -p 8767:8767 \
  -e MCP_TRANSPORT=http \
  -e PROMETHEUS_BACKENDS='[
    {"id": "prod", "base_url": "https://prom-prod.example.com", "type": "prometheus"},
    {"id": "staging", "base_url": "https://thanos-staging.example.com", "type": "thanos"}
  ]' \
  talkopsai/prometheus-mcp-server:latest

⁠🛠️ Configuration (Claude Desktop — Stdio)

To use this image over stdio transport directly inside Claude Desktop:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "prometheus-mcp-server": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e", "PROMETHEUS_BASE_URL=http://host.docker.internal:9090",
        "-e", "MCP_TRANSPORT=stdio",
        "-e", "MCP_LOG_LEVEL=INFO",
        "talkopsai/prometheus-mcp-server:latest"
      ]
    }
  }
}

To include Kubernetes access, add volume and environment variable args:

{
  "mcpServers": {
    "prometheus-mcp-server": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v", "/Users/YOUR_USERNAME/.kube:/app/.kube:ro",
        "-e", "PROMETHEUS_BASE_URL=http://host.docker.internal:9090",
        "-e", "K8S_KUBECONFIG=/app/.kube/config",
        "-e", "MCP_TRANSPORT=stdio",
        "-e", "MCP_LOG_LEVEL=INFO",
        "talkopsai/prometheus-mcp-server:latest"
      ]
    }
  }
}

Replace /Users/YOUR_USERNAME/.kube with your actual kubeconfig path (e.g. C:\Users\YourUser\.kube on Windows).


⁠⚙️ Environment Variables

⁠Server Configuration
VariableDefaultDescription
MCP_TRANSPORThttpTransport protocol: http, sse, streamable-http, or stdio
MCP_HOST0.0.0.0Host interface to bind to
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)
⁠Prometheus Backend
VariableDefaultDescription
PROMETHEUS_BASE_URLhttp://localhost:9090Prometheus HTTP API base URL
PROMETHEUS_BACKEND_IDdefaultBackend identifier used in tool calls
PROMETHEUS_TYPEprometheusBackend type: prometheus, thanos, mimir, cortex, victoriametrics
PROMETHEUS_AUTH_HEADER(empty)Authorization header (e.g. Bearer <token>)
PROMETHEUS_VERIFY_SSLtrueVerify SSL certificates
PROMETHEUS_TIMEOUT30HTTP timeout for Prometheus API calls (seconds)
PROMETHEUS_BACKENDS(empty)JSON array for multi-backend config (overrides single-backend vars)
⁠Kubernetes
VariableDefaultDescription
K8S_KUBECONFIG(empty)Path to kubeconfig file inside the container
K8S_CONTEXT(empty)Specific Kubernetes context to use
K8S_IN_CLUSTERtrueSet true when running inside a Kubernetes pod
K8S_ENABLEDtrueEnable Kubernetes integration

⁠🏷️ Supported Tags

  • latest — Latest stable release
  • 0.1.0 — Initial release

⁠🔧 Available Tools (28 Total)

⁠PromQL Query Engine

Execute, validate, and explore Prometheus metrics with safety rails.

ToolDescription
prom_validate_promqlCheck PromQL syntax before executing
prom_query_instantPoint-in-time PromQL query with counter enforcement
prom_query_rangeTime-range PromQL query with automatic downsampling
prom_explore_labelsDiscover label names and top values for a metric
prom_suggest_promqlGenerate PromQL from natural language
⁠Application Onboarding

Instrument apps and wire up scrape targets.

ToolDescription
prom_recommend_instrumentationRecommend direct instrumentation vs exporter vs builtin
prom_test_endpointValidate Prometheus/OpenMetrics /metrics endpoints
prom_apply_servicemonitorGenerate and apply ServiceMonitor CRDs
prom_apply_probeGenerate and apply Probe CRDs
prom_manage_file_sdManage static targets in file_sd_configs
⁠Exporter Lifecycle

Deploy and manage 19 built-in exporters on Kubernetes.

ToolDescription
prom_recommend_exporterGet exporter recommendations for a service type
prom_install_exporterDeploy exporter to Kubernetes (Deployment/DaemonSet + Service)
prom_uninstall_exporterRemove exporter from Kubernetes
prom_verify_exporterEnd-to-end health check (endpoint + Prometheus up{} series)
⁠TSDB FinOps & Optimization

Analyze cardinality and generate optimization configs.

ToolDescription
prom_optimize_cardinalityAnalyze top-N cardinality metrics with strategies
prom_plan_relabelGenerate metric_relabel_configs YAML
prom_create_recording_ruleGenerate recording rule group YAML
prom_configure_remote_writeGenerate remote_write config for long-term storage
⁠Rule Management & Testing

Author, validate, and simulate alerting and recording rules.

ToolDescription
prom_get_rule_groupGet rule group details by name
prom_upsert_rule_groupCreate/update rule groups (YAML, CRD, or HTTP Ruler)
prom_delete_rule_groupDelete a rule group
prom_draft_alert_ruleGenerate an alert rule from natural language
prom_tune_alert_ruleSuggest adjustments based on firing history
prom_check_rule_groupValidate syntax via promtool
prom_run_rule_testsRun promtool test rules with synthetic scenarios
prom_simulate_firing_syntheticSynthetic alert firing test via promtool
prom_simulate_firing_historicalEvaluate against real historical data
prom_analyze_firing_historyAnalyze firing frequency and duration

⁠📖 Available Resources (14 URIs)

The server exposes discoverable MCP resources that AI assistants read for context:

ResourceDescription
prom://system/backendsAll backends with health status — start here
prom://topology/servicesService catalog derived from scrape targets
prom://metadata/catalogMetric names, types, and HELP text
prom://tsdb/cardinalityTop-N high-cardinality metrics
prom://rules/groupsAlerting and recording rule inventory
prom://exporters/catalog19-exporter catalog with deploy configs
prom://best-practicesPrometheus monitoring best practices
prom://onboarding-guideStep-by-step app onboarding guide

⁠🔐 Security Best Practices

  1. Never expose the MCP server to the public internet without proper authentication.
  2. Read-Only Mount: Always mount kubeconfig with :ro so the container cannot modify your credentials.
  3. RBAC Least Privilege: Ensure the kubeconfig identity has only the permissions needed for exporter and ServiceMonitor operations.
  4. Review Before Apply: TSDB FinOps tools generate YAML only — they do NOT apply changes. Exporter tools create real K8s resources, so review first.
  5. Governance: Use scoped access policies to restrict backends to read-only or whitelist specific operations.

⁠🐳 Docker Compose Example

services:
  prometheus-mcp-server:
    image: talkopsai/prometheus-mcp-server:latest
    ports:
      - "8767:8767"
    environment:
      - PROMETHEUS_BASE_URL=http://prometheus:9090
      - MCP_TRANSPORT=http
      - MCP_LOG_LEVEL=INFO
    depends_on:
      - prometheus

  prometheus:
    image: prom/prometheus:latest
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml

If you find this MCP server useful, consider leaving a ⭐ on the GitHub repository⁠!

Tag summary

Content type

Image

Digest

sha256:12b71ee0d…

Size

130.4 MB

Last updated

4 months ago

docker pull talkopsai/prometheus-mcp-server