Kubernetes MCP
This project is intended as a both MCP server connecting to Kubernetes and a library to build more servers for any custom resources in Kubernetes.
What is Kubernetes MCP?
Kubernetes MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to this project is intended as a both mcp server connecting to kubernetes and a library to build more servers for any custom resources in kubernetes.
This project is intended as a both MCP server connecting to Kubernetes and a library to build more servers for any custom resources in Kubernetes.
This server falls under the Cloud Services category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- This project is intended as a both MCP server connecting to
Use Cases
Maintainer
Works with
Installation
NPM
npx -y @strowk/mcp-k8sManual Installation
npx -y @strowk/mcp-k8sConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Kubernetes MCP
mcp-k8s-go is a Model Context Protocol server written in Go that connects AI assistants directly to your Kubernetes clusters. It lets you list contexts, namespaces, nodes, pods, and events, retrieve pod logs, execute commands inside containers, and create or modify any Kubernetes resource — all from natural language. It also serves as a library for building custom MCP servers that expose your own Kubernetes CRDs.
Prerequisites
- Node.js 18+ (for npx installation) or Go 1.21+ (for source builds) or Docker
- A valid kubeconfig file (typically at ~/.kube/config) with access to target clusters
- kubectl context configured for the clusters you want to manage
- An MCP-compatible client such as Claude Desktop or Claude Code
Verify kubeconfig access
Ensure your kubeconfig is in place and you can reach your cluster. The server reads ~/.kube/config by default; set KUBECONFIG if yours is elsewhere.
kubectl config get-contextsChoose an installation method
The easiest approach is via npm/npx. Alternatively install globally with npm, run via Docker, or build from source with Go.
# Recommended: run directly with npx
npx -y @strowk/mcp-k8s
# Or install globally
npm install -g @strowk/mcp-k8s
# Docker (mounts your kubeconfig read-only)
docker run -i -v ~/.kube/config:/home/nonroot/.kube/config --rm mcpk8s/server:latest
# Build from source
go install github.com/strowk/mcp-k8s-go@latestAdd the server to your MCP client configuration
Open your Claude Desktop config file and add the mcp-k8s entry. Use the --allowed-contexts flag to restrict which clusters are visible, and --readonly to prevent write operations.
Configure environment and safety flags
Set KUBECONFIG if your config is not at the default path. Pass --allowed-contexts to whitelist specific contexts, and --readonly to make all operations read-only. Secrets are masked by default.
# Example with safety flags
npx -y @strowk/mcp-k8s --allowed-contexts=staging,dev --readonlyRestart your MCP client and verify the connection
Restart Claude Desktop (or reload your MCP client). Ask it to list your Kubernetes contexts to confirm the server is connected and responding.
Kubernetes MCP Examples
Client configuration
Add this block to your claude_desktop_config.json. Adjust KUBECONFIG and flags as needed.
{
"mcpServers": {
"kubernetes": {
"command": "npx",
"args": ["-y", "@strowk/mcp-k8s", "--allowed-contexts=production,staging", "--mask-secrets"],
"env": {
"KUBECONFIG": "/Users/yourname/.kube/config"
}
}
}
}Prompts to try
Sample prompts once the server is connected to your MCP client.
- "List all Kubernetes contexts available in my kubeconfig"
- "Show me all pods in the production namespace that are not in Running state"
- "Get the last 100 lines of logs from the api-gateway pod in the default namespace"
- "List all nodes in the cluster and their resource capacity"
- "Show recent events in the staging namespace"
- "Create a ConfigMap named app-config in the default namespace with key LOG_LEVEL=debug"Troubleshooting Kubernetes MCP
Server starts but cannot find any clusters or contexts
Check that your KUBECONFIG environment variable points to the correct file, or that ~/.kube/config exists and contains valid context entries. Run `kubectl config get-contexts` in a terminal to verify.
Permission denied errors when trying to list or modify resources
The server uses the permissions of your current kubeconfig context. Ensure the service account or user in that context has the required RBAC roles. Remove --readonly if you need write access.
Secrets are showing as masked or redacted
By default --mask-secrets is enabled. If you need to inspect actual secret values, pass --mask-secrets=false explicitly, but treat the output as sensitive.
Frequently Asked Questions about Kubernetes MCP
What is Kubernetes MCP?
Kubernetes MCP is a Model Context Protocol (MCP) server that this project is intended as a both mcp server connecting to kubernetes and a library to build more servers for any custom resources in kubernetes. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Kubernetes MCP?
Install via npm with the command: npx -y @strowk/mcp-k8s. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).
Which AI clients work with Kubernetes MCP?
Kubernetes MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Kubernetes MCP free to use?
Yes, Kubernetes MCP is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.
Kubernetes MCP Alternatives — Similar Cloud Services Servers
Looking for alternatives to Kubernetes MCP? Here are other popular cloud services servers you can use with Claude, Cursor, and VS Code.
Open WebUI
★ 138.2kUser-friendly AI Interface (Supports Ollama, OpenAI API, ...)
Anything LLM
★ 60.4kThe all-in-one AI productivity accelerator. On device and privacy first with no annoying setup or configuration.
LocalAI
★ 46.4kLocalAI is the open-source AI engine. Run any model - LLMs, vision, voice, image, video - on any hardware. No GPU required.
Nacos
★ 33.0kan easy-to-use dynamic service discovery, configuration and service management platform for building AI cloud native applications.
Xiaozhi ESP32
★ 26.7k本项目为xiaozhi-esp32提供后端服务,帮助您快速搭建ESP32设备控制服务器。Backend service for xiaozhi-esp32, helps you quickly build an ESP32 device control server.
Gateway
★ 11.8kA blazing fast AI Gateway with integrated guardrails. Route to 1,600+ LLMs, 50+ AI Guardrails with 1 fast & friendly API.
Browse More Cloud Services MCP Servers
Explore all cloud services servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Kubernetes MCP in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Kubernetes MCP?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.