A read-only MCP server for Kubernetes that allows querying cluster information and diagnosing issues through natural language interfaces like Claude.
A Python-based, read-only Model Context Protocol (MCP) server for Kubernetes clusters that exposes a comprehensive API to retrieve cluster information and diagnose issues.
dependencies
in pyproject.toml
)# To install uv curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository git clone git@github.com:vlttnv/k8s-mcp.git cd k8s-mcp # Install dependencies uv venv source .venv/bin/activate uv sync
If using Claude configure open your Claude for Desktop App configuration at ~/Library/Application Support/Claude/claude_desktop_config.json in a text editor. Make sure to create the file if it doesn’t exist.
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
{ "mcpServers": { "k8s-mcp": { "command": "uv", "args": [ "--directory", "/ABSOLUTE/PATH/TO/PARENT/FOLDER/k8s-mcp", "run", "server.py" ] } } }
You may need to put the full path to the uv executable in the command field. You can get this by running which uv on MacOS/Linux or where uv on Windows.
The application automatically tries two methods to connect to your Kubernetes cluster:
~/.kube/config
)No additional configuration is required if your kubeconfig is properly set up or if you're running inside a cluster with appropriate RBAC permissions.
Here are some useful example prompts you can ask Claude about your Kubernetes cluster and its resources:
get_namespaces()
: List all available namespaces in the clusterlist_pods(namespace=None)
: List all pods, optionally filtered by namespacefailed_pods()
: List all pods in Failed or Error statepending_pods()
: List all pods in Pending state with reasonshigh_restart_pods(restart_threshold=5)
: Find pods with restart counts above thresholdlist_nodes()
: List all nodes and their statusnode_capacity()
: Show available capacity on all nodeslist_deployments(namespace=None)
: List all deploymentslist_services(namespace=None)
: List all serviceslist_events(namespace=None)
: List all eventsorphaned_resources()
: List resources without owner referencesget_resource_yaml(namespace, resource_type, resource_name)
: Get YAML configuration for a specific resourceContributions are welcome! Please feel free to submit a Pull Request.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!