Kubernetes MCP Server
Connect your AI assistant to Kubernetes clusters for cluster management, pod inspection, deployment automation, and troubleshooting.
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
| Tool | Purpose | Category |
|---|---|---|
kubectl_get | Get or list Kubernetes resources by type, name, and namespace | Resources |
kubectl_describe | Describe Kubernetes resources | Resources |
kubectl_logs | Get logs from pods, deployments, or jobs | Debugging |
kubectl_apply | Apply a YAML manifest from a string or file | Resources |
kubectl_create | Create Kubernetes resources | Resources |
kubectl_delete | Delete Kubernetes resources | Resources |
kubectl_scale | Scale a deployment, replicaset, or statefulset | Deployments |
kubectl_patch | Patch a resource with a merge or JSON patch | Resources |
kubectl_rollout | Manage the rollout of a resource | Deployments |
kubectl_generic | Execute a kubectl command directly | Resources |
kubectl_context | List, get, or set the current kubeconfig context | Cluster |
explain_resource | Get documentation for a Kubernetes resource or field | Discovery |
list_api_resources | List the API resources available in the cluster | Discovery |
port_forward | Forward a local port to a pod or service | Networking |
stop_port_forward | Stop a port-forward process | Networking |
install_helm_chart | Install a Helm chart | Helm |
upgrade_helm_chart | Upgrade a Helm release | Helm |
uninstall_helm_chart | Uninstall a Helm release | Helm |
helm_template_apply | Apply a Helm chart template to the cluster | Helm |
helm_template_uninstall | Uninstall resources created from a Helm template | Helm |
node_management | Cordon, drain, or uncordon nodes | Cluster |
cleanup_pods | Clean up pods in failed states | Debugging |
cleanup | Clean up resources | Debugging |
exec_in_pod | Execute a command in a pod | Debugging |
ping | Verify that the connection is alive | Cluster |
The full tool list is in the upstream README.
Common Workflows
Investigating a Pod Crash Loop
- Use
kubectl_getto list pods in the affected namespace - Use
kubectl_describeto check recent events and container status - Use
kubectl_logsto fetch logs from the crashing container - Use
kubectl_getwithresourceTypeset to events to check for broader issues - Ask "What is causing this pod to crash loop based on the logs and events?"
Scaling for Traffic
- Use
kubectl_getto find the target deployment and check its status - Use
kubectl_scaleto set the desired replica count - Use
kubectl_getto monitor the new pods - Use
kubectl_rolloutto check rollout status - Verify service endpoints with
kubectl_get
Cluster Health Check
- Use
kubectl_getto list nodes and their status - Use
kubectl_getto review events - Use
kubectl_getto check pod distribution across namespaces - Use
kubectl_describeon any pending or failing pods - 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
| Issue | Likely Cause | Solution |
|---|---|---|
| "Connection refused" | Cluster not accessible from the MCP host | Verify the kubeconfig context and cluster endpoint reachability |
| "Unauthorized" | Kubeconfig lacks permissions | Use a service account token with appropriate RBAC bindings |
| "Pod not found" | Wrong namespace or pod name | Use kubectl_get with resourceType set to pods to verify the namespace and name |
| "Context deadline exceeded" | Cluster is unreachable or overloaded | Check cluster health and network connectivity |
| Destructive tool is unavailable | Non-destructive mode is enabled | Unset ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS if the operation is intended |
Security Notes
- Run with
ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS=truefor production clusters - Use read-only service accounts and limit RBAC permissions to required resources
- The server masks sensitive data in
kubectl get secretsoutput, but logs are not masked - Never expose a kubeconfig with admin credentials to AI assistants
Sources
Related Articles & Guides
Accessibility Scanner MCP Server
Accessibility Scanner MCP servers enable AI models to perform WCAG compliance checks, capture annotated screenshots, and generate detailed accessibility reports.
Auth0 MCP Server
Auth0 MCP server enables AI models to interact with Auth0 identity and access management, including applications, APIs, actions, logs, and forms.
AWS MCP Server
Interact with Amazon Web Services through your AI assistant using the AWS API MCP Server.