Get the FREE Ultimate OpenClaw Setup Guide →

kube

learn let llm use mcp to manage k8s cluster

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio boqier-kube-mcp-server docker run -i boqier-kube-mcp-server:latest \
  --env LOKI_URL="Loki server URL (default: http://127.0.0.1:3100)" \
  --env SERVER_MODE="Server mode (default: stdio; options: stdio, sse, streamable-http)" \
  --env SERVER_PORT="Server port (default: 8080)" \
  --env PROMETHEUS_URL="Prometheus server URL (default: http://127.0.0.1:9090)"

How to use

kube-mcp-server exposes a multi-functional MCP interface for managing Kubernetes clusters and querying Prometheus and Loki data sources. When running, it can operate in several modes (stdio for local development and AI integrations, SSE for a persistent HTTP interface, or streamable-http for REST-like streaming). The server supports Kubernetes API resource queries, Pod log viewing, resource monitoring metrics, and events/Ingress queries, alongside Prometheus instantaneous and range queries, metric name lookups, and alert information. Loki support adds real-time and range log queries, tag/value discovery, and log stream queries using LogQL. Configure Prometheus and Loki integrations via command line flags or environment variables to enable/disable features and point to your monitoring stack. The server will gracefully disable a failed integration while continuing to operate otherwise.

To start, ensure the Docker image boqier-kube-mcp-server:latest is available, then run the container with the desired environment settings. Access the API as configured by SERVER_PORT and the chosen mode (stdio, sse, or streamable-http).

How to install

Prerequisites:

  • Docker installed and running on your host
  • Internet access to pull the MCP server image (or a pre-built image available in your registry)

Installation steps:

  1. Pull the MCP server image docker pull boqier-kube-mcp-server:latest

  2. Run the server with environment configuration (example) docker run -i
    -e PROMETHEUS_URL=http://prometheus.example.com:9090
    -e LOKI_URL=http://loki.example.com:3100
    -e SERVER_PORT=8080
    -e SERVER_MODE=stdio
    -p 8080:8080
    boqier-kube-mcp-server:latest

  3. Optional: customize via a docker compose file or additional environment variables as needed.

If you instead have a native build or another packaging method, follow the corresponding installation steps and ensure the same environment variables are provided.

Additional notes

Notes and tips:

  • Environment variables take effect at startup; command-line arguments override environment variables if both are provided.
  • If Prometheus or Loki endpoints are unreachable at startup, the server will log a warning and disable the corresponding integrations rather than failing.
  • Modes:
    • stdio: communicates via standard I/O, suitable for local development and AI assistant integration.
    • sse: uses Server-Sent Events for a persistent HTTP connection, ideal for web apps.
    • streamable-http: provides a streaming HTTP interface for REST-like clients.
  • Security: you can enable safe-mode (disable write operations) via the -safe-mode flag or equivalent environment setting when building/starting the container.
  • Common issues: verify network connectivity to Prometheus/Loki endpoints, correct port mappings, and that the selected mode is supported by your MCP client.

Related MCP Servers

Sponsor this space

Reach thousands of developers