# Managing Kubernetes Clusters Using K8s MCP Server

Model Context Protocol (MCP) is a new approach to organizing context for large language models, letting them act more intelligently and maintain continuity across tasks, tools, and sessions. By defining key elements like user intent, memory, and available tools, MCP enables more seamless, context-aware interactions in AI applications. This guide walks through running a Kubernetes MCP server container so you can interact with a Kubernetes cluster using natural language, and shows how to connect it to Claude Desktop to manage the cluster conversationally. By the end, you'll have a Kubernetes MCP server running locally and wired into Claude Desktop for natural-language cluster management, following AI-assisted Kubernetes management practices documented in [**Vultr Docs**](https://docs.vultr.com/how-to-manage-kubernetes-clusters-using-k8s-mcp-server).

* * *

## Prerequisites

Before you begin:

*   Deploy a Kubernetes cluster.
    
*   Install `kubectl`.
    
*   Download your cluster's kubeconfig file.
    
*   Download the [Claude Desktop application](https://claude.ai/download).
    
*   Download the [Docker Desktop application](https://www.docker.com/products/docker-desktop/).
    

* * *

## Get Started Right Away

Make sure you've downloaded your Kubernetes cluster's kubeconfig file to your local system before proceeding.

**1\. Display all available contexts defined in the kubeconfig file:**

```console
kubectl config get-contexts
```

Copy the context value to use in the later steps.

**2\. Pull the sample Kubernetes MCP server Docker container image:**

```console
docker pull ghcr.io/alexei-led/k8s-mcp-server:latest
```

**3\. Run the sample Kubernetes MCP server Docker container image:**

```console
docker run -i --rm \
    -v ~/.kube:/home/appuser/.kube:ro \
    -e K8S_CONTEXT=<K8S_CLUSTER_CONTEXT_VALUE> \
    ghcr.io/alexei-led/k8s-mcp-server:latest
```

**4\. Confirm the image is running in the Docker Desktop application.**

* * *

## Understand the MCP Server

*   **Unified Kubernetes CLI Tools** — built-in support for multiple Kubernetes tools like `kubectl`, `helm`, `istioctl`, and `argocd`, all within a single containerized environment.
    
*   **Cloud-Native Integration** — native compatibility with major managed Kubernetes providers.
    
*   **Secure by Design** — runs as a non-root user and enforces strict validation on incoming commands to maintain security and control.
    
*   **Flexible Command Chaining** — supports command piping and integrates smoothly with Unix utilities like `jq`, `grep`, and `sed` for complex workflows.
    
*   **Simplified Configuration** — easily customizable through environment variables, minimizing setup time and complexity.
    

* * *

## Use Claude Desktop to Interact

The [Claude Desktop application](https://claude.ai/download) automatically detects MCP servers defined in its configuration file and makes them accessible within any conversation.

**1\. Start the Claude Desktop application.**

**2\. Locate the settings option in the application.**

**3\. Select Developer settings.**

**4\. Click Edit Config.**

**5\. Add the following configuration snippet to your Claude Desktop config file:**

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

Replace the value of `K8S_CONTEXT` with your actual Kubernetes context name. Also update the mount path `/Users/YOUR_USER_NAME/.kube` to point to your real `.kube` directory (usually `~/.kube` on most systems).

**6\. Restart the Claude Desktop application once the new configuration is in place.**

**7\. Confirm the server is running:** go to the Developer settings in Claude Desktop and check that the status next to the JSON file shows as running.

**8\. Make sure the MCP server tools are available to the application.**

![MCP tools](https://docs.vultr.com/public/doc-assets/2200/c0f77029-74f9-4184-956d-ece88631e8ad.png align="center")

### Ask Questions and Perform Operations

You can manage your Kubernetes cluster by chatting naturally using the Claude Desktop application.

![K8s cluster info](https://docs.vultr.com/public/doc-assets/2200/8da1d6a0-820d-47d9-a134-fc357833fa07.png align="center")

Make sure the responses match the actual state of your cluster.

### Example Operations Supported by the Kubernetes MCP Server

**Advanced Operations**

*   Check the status of the Istio service mesh.
    
*   Create an ArgoCD application for a repository.
    

**Deployments & Configuration**

*   Deploy the Nginx Helm chart.
    
*   Create a deployment with 3 replicas of `nginx:latest`.
    
*   Set up an Ingress controller.
    

**Troubleshooting**

*   Describe the failing pod and explain the error.
    
*   Check if a service is properly connected to its pods.
    

**Basic Commands**

*   Show all pods in the default namespace.
    
*   Get all services across all namespaces.
    
*   Display the logs for the Nginx pod.
    

* * *

## Next Steps

*   Extend the MCP server configuration to manage multiple cluster contexts side by side.
    
*   Pair the MCP server with the ArgoCD and Istio tooling already built into the container.
    
*   Explore additional natural-language operations for scaling, troubleshooting, and Helm deployments.
    

For the full guide with additional tips, visit the original article on [**Vultr Docs**](https://docs.vultr.com/how-to-manage-kubernetes-clusters-using-k8s-mcp-server).
