Kubernetes MCP Server
A powerful Model Context Protocol (MCP) server for interacting with Kubernetes and OpenShift clusters. This skill provides native Go-based access to Kubernetes APIs without requiring kubectl or other external tools.
What This Skill Does
The Kubernetes MCP Server enables AI assistants to:
Manage Kubernetes resources (any CRUD operation on any resource)Control pods (list, get, delete, logs, exec, run)View and manage namespaces and projectsHandle Helm charts (install, list, uninstall)Monitor cluster eventsExecute commands inside containersView resource usage metricsInteract with multiple clusters simultaneouslyKey Features
**Native Implementation**: Direct API server communication without kubectl dependency**Multi-Cluster Support**: Work with multiple Kubernetes clusters from your kubeconfig**Cross-Platform**: Available as native binaries, npm package, Python package, or container**Lightweight & Fast**: Single binary with no external dependencies**Configurable**: Read-only mode, destructive operation controls, custom output formats**Well-Tested**: Extensive test suite across different Kubernetes environmentsInstallation Instructions
For Claude Code
1. The server can be installed via npx (fastest method if npm is available)
2. No additional Kubernetes tools need to be installed - the server is self-contained
3. Ensure you have access to a Kubernetes cluster with a valid kubeconfig file
4. For production use, configure a dedicated ServiceAccount with appropriate RBAC permissions
For Claude Desktop
Add to your `claude_desktop_config.json`:
```json
{
"mcpServers": {
"kubernetes": {
"command": "npx",
"args": ["-y", "kubernetes-mcp-server@latest"]
}
}
}
```
For VS Code / VS Code Insiders
Install via command:
```bash
code --add-mcp '{"name":"kubernetes","command":"npx","args":["kubernetes-mcp-server@latest"]}'
```
For Cursor
Add to your `mcp.json`:
```json
{
"mcpServers": {
"kubernetes-mcp-server": {
"command": "npx",
"args": ["-y", "kubernetes-mcp-server@latest"]
}
}
}
```
Usage Instructions for AI Agent
When a user requests Kubernetes operations, follow these steps:
1. Verify Cluster Access
First, check the current Kubernetes configuration to understand available clusters and contexts:
Use the configuration viewing tool to see active kubeconfigIdentify the current context and available namespacesConfirm cluster connectivity2. Understand the Request
Determine what operation is needed:
**Read operations**: List, get, describe resources**Write operations**: Create, update, patch resources**Destructive operations**: Delete resources**Pod-specific**: Logs, exec, port-forward**Helm operations**: Install, upgrade, uninstall charts3. Select the Appropriate Tool
Choose from available toolsets:
**Generic Resource Tools**: For any Kubernetes resource (Deployments, Services, ConfigMaps, etc.)**Pod Tools**: For pod-specific operations (logs, exec, top, run)**Namespace Tools**: For listing and managing namespaces**Event Tools**: For viewing cluster events**Helm Tools**: For Helm chart operations**Project Tools**: For OpenShift projects4. Execute Operations Safely
When performing operations:
**For read operations**: Proceed directly with listing or getting resources**For write operations**: Confirm the action with the user first**For destructive operations**: Always get explicit user confirmation before deleting resources**For multi-step operations**: Break down complex tasks and explain each step5. Handle Results
After executing operations:
Parse and present results in a user-friendly formatIf errors occur, explain them clearly and suggest remediation stepsFor large outputs (like logs), summarize key informationHighlight any warnings or important status conditions6. Context Awareness
Maintain awareness of:
Current namespace contextCluster being operated on (in multi-cluster scenarios)Resource interdependencies (e.g., Deployments and their Pods)Whether running in read-only or restricted modeConfiguration Options
The server supports several command-line options:
`--read-only`: Prevents all write operations (useful for safe exploration)`--disable-destructive`: Blocks delete operations while allowing creates/updates`--disable-multi-cluster`: Restricts operations to current context only`--log-level`: Controls verbosity (0-9, similar to kubectl -v)`--kubeconfig`: Specifies custom kubeconfig file path`--list-output`: Sets output format (yaml or table)`--stateless`: Disables tool/prompt change notifications (for serverless deployments)Common Use Cases
Debugging a Pod
1. List pods in the namespace to identify the problematic one
2. Get detailed pod information to check status and conditions
3. View pod logs to identify errors
4. Check recent events for scheduling or runtime issues
5. If needed, exec into the pod to investigate further
Deploying an Application
1. Verify the target namespace exists
2. Apply or create the necessary resources (Deployment, Service, etc.)
3. Monitor the rollout status
4. Check pod status to ensure successful startup
5. View logs to confirm application is running correctly
Installing a Helm Chart
1. Confirm the namespace and release name
2. Use Helm install tool with appropriate values
3. Monitor the installation progress
4. List created resources
5. Verify application health
Troubleshooting a Service
1. Get the service details to check endpoints
2. List pods matching the service selector
3. Check pod readiness and health
4. View recent events for the service and pods
5. Examine pod logs for errors
Important Notes
**No kubectl Required**: This is a native implementation that talks directly to the Kubernetes API**Multi-Cluster**: Can work with all clusters defined in your kubeconfig simultaneously**Security**: Respects kubeconfig RBAC permissions - operations are limited by configured credentials**Read-Only Mode**: Available for safe cluster inspection without modification risk**Resource Types**: Supports ANY Kubernetes or OpenShift resource type, not just built-in kindsExample Interactions
**User**: "Show me all pods in the production namespace"
**Agent**: Uses the pod list tool with namespace filter set to "production"
**User**: "What's wrong with my deployment?"
**Agent**:
1. Lists pods for the deployment
2. Checks pod statuses and conditions
3. Views recent events
4. Examines logs from failed pods
5. Presents diagnosis with specific error details
**User**: "Deploy nginx using Helm"
**Agent**:
1. Confirms target namespace
2. Uses Helm install tool with nginx chart
3. Monitors deployment progress
4. Verifies pods are running
5. Reports success with access information