mcp-server-kubernetes
Verified Safeby Flux159
Overview
This MCP server enables AI agents to connect to and manage Kubernetes clusters by executing kubectl and Helm commands.
Installation
npx mcp-server-kubernetesEnvironment Variables
- SPAWN_MAX_BUFFER
- KUBECONFIG_YAML
- KUBECONFIG_JSON
- K8S_SERVER
- K8S_TOKEN
- K8S_CA_DATA
- K8S_SKIP_TLS_VERIFY
- KUBECONFIG_PATH
- K8S_CONTEXT
- K8S_NAMESPACE
- ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS
- ALLOWED_TOOLS
- ALLOW_ONLY_READONLY_TOOLS
- MASK_SECRETS
- ENABLE_UNSAFE_STREAMABLE_HTTP_TRANSPORT
- PORT
- HOST
- DNS_REBINDING_PROTECTION
- DNS_REBINDING_ALLOWED_HOST
- ENABLE_UNSAFE_SSE_TRANSPORT
- MCP_AUTH_TOKEN
Security Notes
The server uses `child_process.execFileSync` and `spawn` to run external `kubectl` and `helm` commands, which inherently carries risk. However, significant mitigation measures are in place: 1. The `exec_in_pod` tool explicitly accepts commands as an array of strings to prevent shell injection, strictly avoiding direct shell interpretation. 2. Other `kubectl` tools construct arguments programmatically, reducing the risk of injection. 3. Secrets masking (`MASK_SECRETS`) is implemented for `kubectl get secrets` output, though it does not cover all sensitive data exposure in logs. 4. Non-destructive (`ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS`) and read-only (`ALLOW_ONLY_READONLY_TOOLS`) modes are available via environment variables for granular access control. 5. The Helm chart templates include robust security configurations like Pod Security Contexts, `readOnlyRootFilesystem: true`, `allowPrivilegeEscalation: false`, `capabilities.drop: ALL`, customizable RBAC, and NetworkPolicies with default deny, requiring explicit egress rules. 6. For HTTP transports, `ENABLE_UNSAFE_SSE_TRANSPORT` is deprecated in favor of `ENABLE_UNSAFE_STREAMABLE_HTTP_TRANSPORT`, which includes DNS rebinding protection and supports `MCP_AUTH_TOKEN` for header-based authentication. SSE is explicitly flagged as 'unsafe'. These measures demonstrate a strong focus on security best practices for a tool that directly interacts with a Kubernetes cluster.
Similar Servers
kubernetes-mcp-server
Facilitates AI agent interaction with Kubernetes and OpenShift clusters by exposing management and observability tools via the Model Context Protocol.
mcp-k8s-go
This MCP server enables interaction with Kubernetes clusters to list, get, apply, and execute commands on various resources through a conversational interface.
mcp-k8s
Facilitates natural language interaction and automation for Kubernetes cluster management and Helm operations via the Model Control Protocol (MCP).
k8s-mcp-server
Interacting with Kubernetes clusters and Helm releases through a standardized Model Context Protocol (MCP) interface.