The Kubernetes MCP Server provides safe, read-only access to Kubernetes resources for debugging and inspection. It allows comprehensive cluster visibility without modification capabilities, making it ideal for secure monitoring and troubleshooting of Kubernetes environments.
go install github.com/kkb0318/kubernetes-mcp@latest
The binary will be available at $GOPATH/bin/kubernetes-mcp
(or $HOME/go/bin/kubernetes-mcp
if GOPATH
is not set).
git clone https://github.com/kkb0318/kubernetes-mcp.git
cd kubernetes-mcp
go build -o kubernetes-mcp .
Add the server to your MCP configuration:
This setup automatically uses ~/.kube/config
:
{
"mcpServers": {
"kubernetes": {
"command": "/path/to/kubernetes-mcp"
}
}
}
{
"mcpServers": {
"kubernetes": {
"command": "/path/to/kubernetes-mcp",
"env": {
"KUBECONFIG": "/path/to/your/kubeconfig"
}
}
}
}
# Using default kubeconfig (~/.kube/config)
./kubernetes-mcp
# Using custom kubeconfig path
KUBECONFIG=/path/to/your/kubeconfig ./kubernetes-mcp
Lists and filters Kubernetes resources with advanced options.
Parameters:
context
(optional): Kubernetes context name from kubeconfigkind
(required): Resource type (Pod, Deployment, Service, etc.) or "all" for discoverygroupFilter
(optional): Filter by API group substringnamespace
(optional): Target namespacelabelSelector
(optional): Filter by labels (e.g., "app=nginx")fieldSelector
(optional): Filter by fieldslimit
(optional): Maximum number of resources to returntimeoutSeconds
(optional): Request timeout (default: 30s)showDetails
(optional): Return full resource objectsExamples:
// List pods with label selector
{
"kind": "Pod",
"namespace": "default",
"labelSelector": "app=nginx"
}
// Discover FluxCD resources
{
"kind": "all",
"groupFilter": "flux"
}
Gets detailed information about a specific Kubernetes resource.
Parameters:
context
(optional): Kubernetes context namekind
(required): Resource typename
(required): Resource namenamespace
(optional): Target namespaceExample:
{
"kind": "Pod",
"name": "nginx-pod",
"namespace": "default"
}
Retrieves pod logs with filtering options.
Parameters:
context
(optional): Kubernetes context namename
(required): Pod namenamespace
(optional): Pod namespace (defaults to "default")container
(optional): Specific container nametail
(optional): Number of lines from the end (default: 100)since
(optional): Duration like "5s", "2m", "3h"sinceTime
(optional): RFC3339 timestamptimestamps
(optional): Include timestamps in outputprevious
(optional): Get logs from previous container instanceExample:
{
"name": "nginx-pod",
"namespace": "default",
"tail": 50,
"since": "5m",
"timestamps": true
}
Lists and filters Kubernetes events for debugging and monitoring.
Parameters:
context
(optional): Kubernetes context namenamespace
(optional): Target namespaceobject
(optional): Filter by object nameeventType
(optional): Filter by event type: "Normal" or "Warning"reason
(optional): Filter by event reasonsince
(optional): Duration like "5s", "2m", "1h"sinceTime
(optional): RFC3339 timestamplimit
(optional): Maximum number of events to return (default: 100)timeoutSeconds
(optional): Request timeout (default: 30s)Examples:
// List recent warning events
{
"eventType": "Warning",
"since": "30m"
}
// List events for a specific pod
{
"object": "nginx-pod",
"namespace": "default"
}
Lists all available Kubernetes contexts from your kubeconfig file.
Parameters: None
Example Response:
{
"contexts": [
{
"name": "production-cluster",
"is_current": false
},
{
"name": "staging-cluster",
"is_current": true
},
{
"name": "development-cluster",
"is_current": false
}
],
"current_context": "staging-cluster",
"total": 3
}
All tools support an optional context
parameter to specify which cluster to query:
// Query production cluster
{
"kind": "Pod",
"context": "production-cluster",
"namespace": "default"
}
The server automatically discovers and works with any CRDs in your cluster. Simply use the CRD's Kind name with list_resources
or describe_resource
tools.
Use the groupFilter
parameter to discover resources by API group substring:
"flux"
- Discovers FluxCD resources"argo"
- Discovers ArgoCD resources"istio"
- Discovers Istio resources"cert-manager"
- Discovers cert-manager resourcesTo add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "kubernetes" '{"command":"/path/to/kubernetes-mcp"}'
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": "/path/to/kubernetes-mcp"
}
}
}
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": "/path/to/kubernetes-mcp"
}
}
}
3. Restart Claude Desktop for the changes to take effect