home / mcp / kubernetes mcp server
MCP server connecting to Kubernetes
Configuration
View docs{
"mcpServers": {
"strowk-mcp-k8s-go": {
"command": "mcp-k8s-go",
"args": [],
"env": {
"KUBECONFIG": "${KUBECONFIG_PATH:-~/.kube/config}"
}
}
}
}You run an MCP server that you connect to Kubernetes to browse, retrieve, and manage cluster resources from any MCP client. This Go-based MCP K8S server lets you list contexts, namespaces, nodes, pods, events, and much more, while also enabling you to run commands inside pods. It bridges your Kubernetes cluster with MCP-enabled clients so you can orchestrate and observe clusters from a single, consistent interface.
You access the MCP K8S Go server from an MCP client (such as Claude Desktop or Inspector) by configuring the client to point to the MCP server and then issuing actions like listing contexts, namespaces, or Kubernetes resources, or executing commands inside pods.
Practical usage patterns include: 1) listing available Kubernetes contexts, namespaces, and core resources; 2) listing Kubernetes nodes and pods; 3) retrieving events and pod logs; 4) running commands inside a Kubernetes pod. You can also restrict which contexts are accessible and enable read-only mode to prevent changes to the cluster. The server supports masking of secrets in outputs by default for safer sharing.
Prerequisites: you need a supported runtime to run the MCP server. Choose one of the following installation flows based on your preference for manual setup, Docker usage, or seamless client integration.
Docker usage
docker run -i -v ~/.kube/config:/home/nonroot/.kube/config --rm mcpk8s/server:latest
Windows users might need to replace ~/.kube/config with //c/Users/<username>/.kube/config in Git Bash.Environment variables and command-line options supported by the MCP server include:
Environment variable - KUBECONFIG: Path to your Kubernetes configuration file (optional, defaults to ~/.kube/config)
Command-line options - --allowed-contexts=<ctx1,ctx2,...>: Comma-separated list of allowed Kubernetes contexts. If not specified, all contexts are allowed - --readonly: Disables any write-capable tools to protect the cluster - --help: Display help information - --version: Display version information - --mask-secrets: Mask secrets in the output (default: true). Use --mask-secrets=false to disable masking
If you configure a client like Claude Desktop, you can specify how the MCP server starts. For example, you can limit contexts and enable read-only mode by passing relevant flags in the client configuration.
To run the MCP server via a local binary, you can use the following start command in Claude Desktop configuration:
{
"mcpServers": {
"mcp_k8s_go": {
"command": "mcp-k8s-go",
"args": []
}
}
}List Kubernetes contexts available from your cluster and filter by allowed contexts if configured.
List all Kubernetes namespaces accessible in the selected context.
List, get, create, and modify Kubernetes resources including core and custom resources.
List Kubernetes nodes in the cluster.
List Kubernetes pods across namespaces.
Get Kubernetes events for debugging and auditing.
Retrieve logs from a specific Kubernetes pod.
Execute a command inside a Kubernetes pod and return output.