Kubernetes MCP Server

Connect your AI assistant to Kubernetes clusters for cluster management, pod inspection, deployment automation, and troubleshooting.

October 19, 2026
MCP ServerDevelopment Tools & DevOpsKubernetes MCP Server

Kubernetes MCP Server

This page documents the maintained community server Flux159/mcp-server-kubernetes. It is published on npm as mcp-server-kubernetes and on Docker Hub as mcp/kubernetes.

The server connects to a Kubernetes cluster through kubectl and exposes cluster operations as MCP tools.

What it Does

  • Cluster inspection: Get and describe nodes, namespaces, pods, deployments, services, and other resources
  • Pod operations: Fetch logs, execute commands in pods, and clean up pods in failed states
  • Deployment operations: Create, apply, patch, scale, delete, and manage rollouts
  • Helm operations: Install, upgrade, and uninstall charts
  • Networking: Forward ports to pods and services
  • Node management: Cordon, drain, and uncordon nodes
  • Safety modes: Non-destructive mode and secrets masking

Installation

Prerequisites: kubectl installed and in your PATH, a valid kubeconfig with contexts configured, and Helm v3 if you plan to use Helm tools.

# Using npx
npx -y mcp-server-kubernetes

# Using Docker
docker run -i --rm -v ~/.kube:/root/.kube mcp/kubernetes

By default the server loads kubeconfig from ~/.kube/config.

Configuration

{
  "mcpServers": {
    "kubernetes": {
      "command": "npx",
      "args": ["-y", "mcp-server-kubernetes"]
    }
  }
}

To run without destructive operations, set the documented environment variable:

{
  "mcpServers": {
    "kubernetes-readonly": {
      "command": "npx",
      "args": ["-y", "mcp-server-kubernetes"],
      "env": {
        "ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS": "true"
      }
    }
  }
}

Available Tools

ToolPurposeCategory
kubectl_getGet or list Kubernetes resources by type, name, and namespaceResources
kubectl_describeDescribe Kubernetes resourcesResources
kubectl_logsGet logs from pods, deployments, or jobsDebugging
kubectl_applyApply a YAML manifest from a string or fileResources
kubectl_createCreate Kubernetes resourcesResources
kubectl_deleteDelete Kubernetes resourcesResources
kubectl_scaleScale a deployment, replicaset, or statefulsetDeployments
kubectl_patchPatch a resource with a merge or JSON patchResources
kubectl_rolloutManage the rollout of a resourceDeployments
kubectl_genericExecute a kubectl command directlyResources
kubectl_contextList, get, or set the current kubeconfig contextCluster
explain_resourceGet documentation for a Kubernetes resource or fieldDiscovery
list_api_resourcesList the API resources available in the clusterDiscovery
port_forwardForward a local port to a pod or serviceNetworking
stop_port_forwardStop a port-forward processNetworking
install_helm_chartInstall a Helm chartHelm
upgrade_helm_chartUpgrade a Helm releaseHelm
uninstall_helm_chartUninstall a Helm releaseHelm
helm_template_applyApply a Helm chart template to the clusterHelm
helm_template_uninstallUninstall resources created from a Helm templateHelm
node_managementCordon, drain, or uncordon nodesCluster
cleanup_podsClean up pods in failed statesDebugging
cleanupClean up resourcesDebugging
exec_in_podExecute a command in a podDebugging
pingVerify that the connection is aliveCluster

The full tool list is in the upstream README.

Common Workflows

Investigating a Pod Crash Loop

  1. Use kubectl_get to list pods in the affected namespace
  2. Use kubectl_describe to check recent events and container status
  3. Use kubectl_logs to fetch logs from the crashing container
  4. Use kubectl_get with resourceType set to events to check for broader issues
  5. Ask "What is causing this pod to crash loop based on the logs and events?"

Scaling for Traffic

  1. Use kubectl_get to find the target deployment and check its status
  2. Use kubectl_scale to set the desired replica count
  3. Use kubectl_get to monitor the new pods
  4. Use kubectl_rollout to check rollout status
  5. Verify service endpoints with kubectl_get

Cluster Health Check

  1. Use kubectl_get to list nodes and their status
  2. Use kubectl_get to review events
  3. Use kubectl_get to check pod distribution across namespaces
  4. Use kubectl_describe on any pending or failing pods
  5. Generate a cluster health summary

Example Prompts

  • "Show me all pods in the default namespace"
  • "What deployments are failing in production?"
  • "Get logs from the api-server pod"
  • "Scale the web deployment to 5 replicas"
  • "List all services with external IPs"
  • "Check events for the last hour across all namespaces"

Troubleshooting

IssueLikely CauseSolution
"Connection refused"Cluster not accessible from the MCP hostVerify the kubeconfig context and cluster endpoint reachability
"Unauthorized"Kubeconfig lacks permissionsUse a service account token with appropriate RBAC bindings
"Pod not found"Wrong namespace or pod nameUse kubectl_get with resourceType set to pods to verify the namespace and name
"Context deadline exceeded"Cluster is unreachable or overloadedCheck cluster health and network connectivity
Destructive tool is unavailableNon-destructive mode is enabledUnset ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS if the operation is intended

Security Notes

  • Run with ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS=true for production clusters
  • Use read-only service accounts and limit RBAC permissions to required resources
  • The server masks sensitive data in kubectl get secrets output, but logs are not masked
  • Never expose a kubeconfig with admin credentials to AI assistants

Sources