The MCP Server Kubernetes provides an interface to manage Kubernetes clusters through the Model Context Protocol. It enables AI assistants like Claude to interact with your Kubernetes infrastructure directly.
Before using the MCP Server Kubernetes, ensure you have:
To set up the MCP Server Kubernetes with Claude Desktop, add the server configuration to your Claude Desktop configuration file:
{
"mcpServers": {
"kubernetes": {
"command": "npx",
"args": ["mcp-server-kubernetes"]
}
}
}
By default, the server loads kubeconfig from ~/.kube/config
.
You can also use the MCP Server Kubernetes with mcp-chat, a CLI chat client for MCP servers:
npx mcp-chat --server "npx mcp-server-kubernetes"
Alternatively, use your existing Claude Desktop configuration:
For Mac:
npx mcp-chat --config "~/Library/Application Support/Claude/claude_desktop_config.json"
For Windows:
npx mcp-chat --config "%APPDATA%\Claude\claude_desktop_config.json"
The MCP Server supports the following kubectl operations:
View Resources:
kubectl_get
kubectl_describe
kubectl_logs
Manage Resources:
kubectl_create
kubectl_apply
kubectl_delete
kubectl_scale
kubectl_patch
kubectl_rollout
Information and Utilities:
kubectl_context
explain_resource
list_api_resources
kubectl_generic
ping
Port Forwarding:
port_forward
stop_port_forward
Helm Operations:
install_helm_chart
upgrade_helm_chart
uninstall_helm_chart
The server includes a specialized k8s-diagnose
prompt that provides systematic troubleshooting for Kubernetes pods:
keyword
to identify relevant podsnamespace
parameter narrows the searchFor safety, you can run the server in non-destructive mode that disables destructive operations:
ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS=true npx mcp-server-kubernetes
Configure this in Claude Desktop with:
{
"mcpServers": {
"kubernetes-readonly": {
"command": "npx",
"args": ["mcp-server-kubernetes"],
"env": {
"ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS": "true"
}
}
}
}
In non-destructive mode, the following operations remain available:
kubectl_get
, kubectl_describe
, kubectl_logs
, etc.kubectl_apply
, kubectl_create
, kubectl_scale
, etc.install_helm_chart
, upgrade_helm_chart
port_forward
, stop_port_forward
kubectl_context
However, destructive operations like kubectl_delete
, uninstall_helm_chart
, and cleanup
are disabled.
To verify your connection is working properly, ask Claude to list your pods or create a test deployment. If you encounter errors, open a terminal and run kubectl get pods
to check if you can connect to your cluster without credential issues.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "kubernetes" '{"command":"npx","args":["mcp-server-kubernetes"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"kubernetes": {
"command": "npx",
"args": [
"mcp-server-kubernetes"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"kubernetes": {
"command": "npx",
"args": [
"mcp-server-kubernetes"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect