k8s-mcp-server

k8s-mcp-server

Securely enable Claude to run Kubernetes CLI tools via Anthropic's Model Context Protocol.

166
Stars
31
Forks
166
Watchers
4
Issues
K8s MCP Server provides a Docker-based implementation of Anthropic's Model Context Protocol (MCP), allowing Claude to securely execute Kubernetes CLI tools such as kubectl, helm, istioctl, and argocd within a containerized environment. It integrates with Claude Desktop so users can interact with their Kubernetes clusters using natural language. The server emphasizes security by operating as a non-root user and offering strict command validation, while also supporting major cloud providers like AWS, Google Cloud, and Azure. Easy configuration and support for various Unix tools further enhance its capabilities.

Key Features

Implements Anthropic's Model Context Protocol for Claude integration
Containerized execution of kubectl, helm, istioctl, and argocd
Supports AWS EKS, Google GKE, and Azure AKS
Runs with strict command validation and non-root user
Command piping with jq, grep, sed and other Unix tools
Easy configuration via environment variables
Detailed security configuration options
Demo and usage guides
Multiple cluster and namespace targeting
Natural language operations through Claude Desktop

Use Cases

Running Kubernetes CLI commands via Claude using natural language
Deploying and troubleshooting Kubernetes applications
Managing multi-cloud Kubernetes clusters (EKS, GKE, AKS)
Securely executing Helm deployments and chart management
Automating service mesh operations with istioctl
Continuous integration with Kubernetes for DevOps workflows
Onboarding users to Kubernetes through simplified interfaces
Explaining and teaching Kubernetes concepts interactively
Performing advanced operations like canary deployments via ArgoCD
Auditing and securing kubectl and related tool usage

README

K8s MCP Server

CI Status Release Status codecov Image Tags Image Size Python Version License: MIT

K8s MCP Server is a Docker-based server implementing Anthropic's Model Context Protocol (MCP) that enables Claude to run Kubernetes CLI tools (kubectl, istioctl, helm, argocd) in a secure, containerized environment.

Demo: Deploy and Troubleshoot WordPress

Session 1: Using k8s-mcp-server and Helm CLI to deploy a WordPress application in the claude-demo namespace, then intentionally breaking it by scaling the MariaDB StatefulSet to zero.

Session 2: Troubleshooting session where we use k8s-mcp-server to diagnose the broken WordPress site through kubectl commands, identify the missing database issue, and fix it by scaling up the StatefulSet and configuring ingress access..

Demo

How It Works

mermaid
flowchart LR
    A[User] --> |Asks K8s question| B[Claude]
    B --> |Sends command via MCP| C[K8s MCP Server]
    C --> |Executes kubectl, helm, etc.| D[Kubernetes Cluster]
    D --> |Returns results| C
    C --> |Returns formatted results| B
    B --> |Analyzes & explains| A

Claude can help users by:

  • Explaining complex Kubernetes concepts
  • Running commands against your cluster
  • Troubleshooting issues
  • Suggesting optimizations
  • Crafting Kubernetes manifests

Quick Start with Claude Desktop

Get Claude helping with your Kubernetes clusters in under 2 minutes:

  1. Create or update your Claude Desktop configuration file:

    • macOS: Edit $HOME/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: Edit %APPDATA%\Claude\claude_desktop_config.json
    • Linux: Edit $HOME/.config/Claude/claude_desktop_config.json
    json
    {
      "mcpServers": {
        "kubernetes": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-v",
            "/Users/YOUR_USER_NAME/.kube:/home/appuser/.kube:ro",
            "ghcr.io/alexei-led/k8s-mcp-server:latest"
          ]
        }
      }
    }
    
  2. Restart Claude Desktop

    • After restart, you'll see the Tools icon (🔨) in the bottom right of your input field
    • This indicates Claude can now access K8s tools via the MCP server
  3. Start using K8s tools directly in Claude Desktop:

    • "What Kubernetes contexts do I have available?"
    • "Show me all pods in the default namespace"
    • "Create a deployment with 3 replicas of nginx:1.21"
    • "Explain what's wrong with my StatefulSet 'database' in namespace 'prod'"
    • "Deploy the bitnami/wordpress chart with Helm and set service type to LoadBalancer"

Note: Claude Desktop will automatically route K8s commands through the MCP server, allowing natural conversation about your clusters without leaving the Claude interface.

Cloud Providers: For AWS EKS, GKE, or Azure AKS, you'll need additional configuration. See the Cloud Provider Support guide.

Features

  • Multiple Kubernetes Tools: kubectl, helm, istioctl, and argocd in one container
  • Cloud Providers: Native support for AWS EKS, Google GKE, and Azure AKS
  • Security: Runs as non-root user with strict command validation
  • Command Piping: Support for common Unix tools like jq, grep, and sed
  • Easy Configuration: Simple environment variables for customization

Documentation

Usage Examples

Once connected, you can ask Claude to help with Kubernetes tasks using natural language:

mermaid
flowchart TB
    subgraph "Basic Commands"
        A1["Show me all pods in the default namespace"]
        A2["Get all services across all namespaces"]
        A3["Display the logs for the nginx pod"]
    end
    
    subgraph "Troubleshooting"
        B1["Why is my deployment not starting?"]
        B2["Describe the failing pod and explain the error"]
        B3["Check if my service is properly connected to the pods"]
    end
    
    subgraph "Deployments & Configuration"
        C1["Deploy the Nginx Helm chart"]
        C2["Create a deployment with 3 replicas of nginx:latest"]
        C3["Set up an ingress for my service"]
    end
    
    subgraph "Advanced Operations"
        D1["Check the status of my Istio service mesh"]
        D2["Set up a canary deployment with 20% traffic to v2"]
        D3["Create an ArgoCD application for my repo"]
    end

Claude can understand your intent and run the appropriate kubectl, helm, istioctl, or argocd commands based on your request. It can then explain the output in simple terms or help you troubleshoot issues.

Advanced Claude Desktop Configuration

Configure Claude Desktop to optimize your Kubernetes workflow:

Target Specific Clusters and Namespaces

json
{
  "mcpServers": {
    "kubernetes": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/Users/YOUR_USER_NAME/.kube:/home/appuser/.kube:ro",
        "-e", "K8S_CONTEXT=production-cluster",
        "-e", "K8S_NAMESPACE=my-application",
        "-e", "K8S_MCP_TIMEOUT=600",
        "ghcr.io/alexei-led/k8s-mcp-server:latest"
      ]
    }
  }
}

Connect to AWS EKS Clusters

json
{
  "mcpServers": {
    "kubernetes": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/Users/YOUR_USER_NAME/.kube:/home/appuser/.kube:ro",
        "-v", "/Users/YOUR_USER_NAME/.aws:/home/appuser/.aws:ro",
        "-e", "AWS_PROFILE=production",
        "-e", "AWS_REGION=us-west-2",
        "ghcr.io/alexei-led/k8s-mcp-server:latest"
      ]
    }
  }
}

Connect to Google GKE Clusters

json
{
  "mcpServers": {
    "kubernetes": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/Users/YOUR_USER_NAME/.kube:/home/appuser/.kube:ro",
        "-v", "/Users/YOUR_USER_NAME/.config/gcloud:/home/appuser/.config/gcloud:ro",
        "-e", "CLOUDSDK_CORE_PROJECT=my-gcp-project",
        "-e", "CLOUDSDK_COMPUTE_REGION=us-central1",
        "ghcr.io/alexei-led/k8s-mcp-server:latest"
      ]
    }
  }
}

Connect to Azure AKS Clusters

json
{
  "mcpServers": {
    "kubernetes": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/Users/YOUR_USER_NAME/.kube:/home/appuser/.kube:ro",
        "-v", "/Users/YOUR_USER_NAME/.azure:/home/appuser/.azure:ro",
        "-e", "AZURE_SUBSCRIPTION=my-subscription-id",
        "ghcr.io/alexei-led/k8s-mcp-server:latest"
      ]
    }
  }
}

Permissive Security Mode

json
{
  "mcpServers": {
    "kubernetes": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/Users/YOUR_USER_NAME/.kube:/home/appuser/.kube:ro",
        "-e", "K8S_MCP_SECURITY_MODE=permissive",
        "ghcr.io/alexei-led/k8s-mcp-server:latest"
      ]
    }
  }
}

For detailed security configuration options, see Security Documentation.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Star History

Star History Chart

Repository Owner

alexei-led
alexei-led

User

Repository Details

Language Python
Default Branch master
Size 389 KB
Contributors 1
License MIT License
MCP Verified Sep 5, 2025

Programming Languages

Python
96.26%
Dockerfile
2.81%
Makefile
0.93%

Tags

Topics

ai-assistant argocd claude devops docker helm istioctl k8s kubectl kubernetes mcp mcp-server modelcontextprotocol

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • cloudflare/mcp-server-cloudflare

    cloudflare/mcp-server-cloudflare

    Connect Cloudflare services to Model Context Protocol (MCP) clients for AI-powered management.

    Cloudflare MCP Server enables integration between Cloudflare's suite of services and clients using the Model Context Protocol (MCP). It provides multiple specialized servers that allow AI models to access, analyze, and manage configurations, logs, analytics, and other features across Cloudflare's platform. Users can leverage natural language interfaces in compatible MCP clients to read data, gain insights, and perform automated actions on their Cloudflare accounts. This project aims to streamline the orchestration of security, development, monitoring, and infrastructure tasks through standardized MCP connections.

    • 2,919
    • MCP
    • cloudflare/mcp-server-cloudflare
  • awslabs/mcp

    awslabs/mcp

    Specialized MCP servers for seamless AWS integration in AI and development environments.

    AWS MCP Servers is a suite of specialized servers implementing the open Model Context Protocol (MCP) to bridge large language model (LLM) applications with AWS services, tools, and data sources. It provides a standardized way for AI assistants, IDEs, and developer tools to access up-to-date AWS documentation, perform cloud operations, and automate workflows with context-aware intelligence. Featuring a broad catalog of domain-specific servers, quick installation for popular platforms, and both local and remote deployment options, it enhances cloud-native development, infrastructure management, and workflow automation for AI-driven tools. The project includes Docker, Lambda, and direct integration instructions for environments such as Amazon Q CLI, Cursor, Windsurf, Kiro, and VS Code.

    • 6,220
    • MCP
    • awslabs/mcp
  • mcpmcp-server

    mcpmcp-server

    Seamlessly discover, set up, and integrate MCP servers with AI clients.

    mcpmcp-server enables users to discover, configure, and connect MCP servers with preferred clients, optimizing AI integration into daily workflows. It supports streamlined setup via JSON configuration, ensuring compatibility with various platforms such as Claude Desktop on macOS. The project simplifies the connection process between AI clients and remote Model Context Protocol servers. Users are directed to an associated homepage for further platform-specific guidance.

    • 17
    • MCP
    • glenngillen/mcpmcp-server
  • mcp-server-templates

    mcp-server-templates

    Deploy Model Context Protocol servers instantly with zero configuration.

    MCP Server Templates enables rapid, zero-configuration deployment of production-ready Model Context Protocol (MCP) servers using Docker containers and a comprehensive CLI tool. It provides a library of ready-made templates for common integrations—including filesystems, GitHub, GitLab, and Zendesk—and features intelligent caching, smart tool discovery, and flexible configuration options via JSON, YAML, environment variables, or CLI. Perfect for AI developers, data scientists, and DevOps teams, it streamlines the process of setting up and managing MCP servers and has evolved into the MCP Platform for enhanced capabilities.

    • 5
    • MCP
    • Data-Everything/mcp-server-templates
  • 1mcp-app/agent

    1mcp-app/agent

    A unified server that aggregates and manages multiple Model Context Protocol servers.

    1MCP Agent provides a single, unified interface that aggregates multiple Model Context Protocol (MCP) servers, enabling seamless integration and management of external tools for AI assistants. It acts as a proxy, managing server configuration, authentication, health monitoring, and dynamic server control with features like asynchronous loading, tag-based filtering, and advanced security options. Compatible with popular AI development environments, it simplifies setup by reducing redundant server instances and resource usage. Users can configure, monitor, and scale model tool integrations across various AI clients through easy CLI commands or Docker deployment.

    • 96
    • MCP
    • 1mcp-app/agent
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results