Get the FREE Ultimate OpenClaw Setup Guide →

mcp-k8s

MCP server for Kubernetes that safely executes kubectl, helm, and cluster operations.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio xwomen1-mcp-k8s-server go build -o k8s-mcp-server \
  --env KUBECONFIG_PATH="Path to kubeconfig (e.g., /home/user/.kube/config)"

How to use

This Kubernetes MCP server provides a comprehensive, AI-assisted interface for managing Kubernetes clusters. Built with Go, it exposes a rich set of MCP tools that cover deployments, workloads, configuration management, observability, security, and multi-cluster operations. You can interact with the server using any MCP-compatible client (such as Claude, ChatGPT, Windsurf, or other MCP-enabled assistants) to perform tasks like applying manifests, managing workloads (Deployments, StatefulSets, DaemonSets, Jobs, CronJobs), monitoring resources, handling RBAC and Secrets, and coordinating across multiple clusters. The server supports real-time port-forwarding, service discovery, event filtering, and smart, safe resource updates via Server-Side Apply and dry-run validation, enabling both automation and careful human oversight when deploying to production.

To use it, start the server and point your MCP client to the server’s address. The client sends structured MCP requests to perform actions in Kubernetes, and the server returns results, including resources lists, status, logs, and metrics. Features like multi-cluster registration, dynamic context switching, and AI-driven session management allow you to manage several clusters from a single session while maintaining proper isolation and audit trails.

How to install

Prerequisites:

  • Go 1.21+ installed on your machine
  • Git installed
  • Access to a Kubernetes cluster and a kubeconfig file
  1. Clone the repository
git clone https://github.com/yourusername/k8s-mcp-server.git
cd k8s-mcp-server
  1. Build the server
go build -o k8s-mcp-server
  1. Run the server with default configuration
./k8s-mcp-server
  1. Optional: prepare a client configuration snippet Create a client-side configuration (e.g., servers.k8s) that points to the built server:
{
  "servers": {
    "k8s": {
      "command": "path/to/k8s-mcp-server",
      "env": {
        "KUBECONFIG_PATH": "/path/to/kubeconfig"
      }
    }
  }
}
  1. Verify the server is responding by issuing a simple MCP request from your client (e.g., list deployments in a namespace) and confirm you receive a structured MCP response.

Additional notes

Tips and caveats:

  • Ensure KUBECONFIG_PATH (or equivalent kubeconfig access) is correctly set so the server can authenticate to your clusters.
  • The MCP server supports multi-cluster management; use distinct cluster IDs and contexts to avoid cross-cluster confusion.
  • For production deployments, consider running the server in a container (Docker) and enabling TLS/authorization as appropriate for your environment.
  • If you enable Server-Side Apply, ensure clients provide consistent field_manager identifiers (e.g., ai-provisioner) to improve merge behavior.
  • The server offers dry-run validation to test manifests without creating resources; leverage this to validate changes before applying to your clusters.

Related MCP Servers

Sponsor this space

Reach thousands of developers