MCP Server Kubernetes is an MCP (Model Context Protocol) server used to connect to Kubernetes clusters and perform management operations. It supports loading kubeconfig from multiple sources in priority order.
Purpose
The server is designed to enable AI assistants (such as Claude, Codex, etc.) to interact with Kubernetes clusters through the MCP protocol and perform common cluster management tasks, such as viewing resources, deploying applications, troubleshooting issues, and more.
Main Capabilities
- Unified kubectl API: use kubectl_get to get or list resources, kubectl_describe to describe resources, kubectl_create to create resources, kubectl_apply to apply YAML manifests, kubectl_delete to delete resources, kubectl_logs to get logs, kubectl_context to manage contexts, explain_resource to explain resources, list_api_resources to list API resources, kubectl_scale to scale, kubectl_patch to update fields, kubectl_rollout to manage deployment rollouts, kubectl_generic to execute arbitrary kubectl commands, and ping to verify connectivity.
- Advanced operations: kubectl_scale to scale deployments (replacing the older scale_deployment), port_forward to forward ports to Pods and services, Helm operations (install, upgrade, uninstall charts, with support for custom values, repositories, and versions, as well as template-based installation helm_template_apply and uninstallation helm_template_uninstall to bypass authentication issues), Pod cleanup operations (cleanup_pods to clean up Pods in Evicted, ContainerStatusUnknown, Completed, Error, ImagePullBackOff, and CrashLoopBackOff states), node management operations (node_management for cordon, drain, and uncordon for maintenance and scaling).
- Troubleshooting prompt: the k8s-diagnose prompt guides a systematic Kubernetes Pod troubleshooting process based on keywords and an optional namespace.
- Non-destructive mode: only read and create/update operations are allowed, and all destructive operations are disabled.
- Secrets masking: masks sensitive data in kubectl get secrets commands (does not affect logs).
- OpenTelemetry observability (optional): distributed tracing for all tool calls, exportable to Jaeger, Tempo, Grafana, or any OTLP backend, with support for configurable sampling strategies and rich span attributes.
Usage
Prerequisites
- kubectl is installed and in PATH.
- A valid kubeconfig file with configured contexts.
- An accessible Kubernetes cluster (such as minikube, Rancher Desktop, GKE, etc.).
- Helm v3 is installed and in PATH (optional, if Helm is not used).
Installation and Integration
- By default, kubeconfig is loaded from ~/.kube/config. For other authentication options (environment variables, custom paths, etc.), see ADVANCED_README.md.
- Add to Claude Code: use the built-in command to configure automatically.
- Add to Codex CLI: use the built-in command to register globally in ~/.codex/config.toml.
- Add to Claude Desktop: add the configuration in the configuration file, or install via the mcpb extension.
- VS Code: use the one-click install button, or add it to .vscode/mcp.json or the user mcp.json.
- Cursor: add it to ~/.cursor/mcp.json (global) or .cursor/mcp.json (project).
- Muse Code: configure it in the mcp_servers block of ~/.config/muse/settings.json, and it must include "schema_version": 1. It can also be connected via Streamable HTTP by first starting the server in HTTP mode (default port 3000 at /mcp), and then configuring streamable_http transport.
- mcp-chat: a CLI chat client that can be used to interact with it.
Local Development
- Install bun, clone the repository, and install dependencies.
- Start the server in development mode (watch for file changes).
- Run unit tests.
- Build the project.
- Use Inspector, Claude Desktop, and mcp-chat for local testing.
Non-destructive Mode
Can be enabled via an environment variable, disabling all destructive operations (such as deleting Pods, deployments, namespaces, etc.). Available commands include: kubectl_get, kubectl_describe, kubectl_logs, explain_resource, list_api_resources, kubectl_apply, kubectl_create, kubectl_scale, kubectl_patch, kubectl_rollout, install_helm_chart, upgrade_helm_chart, helm_template_apply, helm_template_uninstall, port_forward, stop_port_forward, kubectl_context. Disabled commands include: kubectl_delete, uninstall_helm_chart, cleanup, cleanup_pods, node_management, kubectl_generic, exec_in_pod.
Use Cases
- Developers and operations personnel managing Kubernetes clusters through AI assistants.
- Automating daily cluster operations, such as deployment, scaling, and log viewing.
- Troubleshooting and diagnostics.
- Scenarios requiring security restrictions (non-destructive mode, Secrets masking).
- Production environments requiring observability (OpenTelemetry).
Limitations
- Requires kubectl and kubeconfig to be configured in advance.
- Helm operations require Helm v3.
- Non-destructive mode disables some commands.
- OpenTelemetry functionality is disabled by default and must be enabled manually.
- Specific pricing, costs, platform support, etc. are not provided in the materials.