home / mcp / mcp server kubernetes
Provides unified Kubernetes management via MCP, enabling kubectl-like operations, Helm interactions, and observability.
Configuration
View docs{
"mcpServers": {
"flux159-mcp-server-kubernetes": {
"command": "npx",
"args": [
"mcp-server-kubernetes"
],
"env": {
"ENABLE_TELEMETRY": "true",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317",
"ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS": "true"
}
}
}
}You run MCP Server Kubernetes to connect to a Kubernetes cluster and manage it through MCP-compatible clients. It provides a unified API for kubectl-like operations, Helm interactions, port forwarding, and advanced cluster management, all with optional observability and safeguards for non-destructive workflows.
You can use this MCP server with any MCP client that supports the Model Context Protocol. Start by ensuring your local environment can reach your Kubernetes cluster via kubectl. You will interact with the MCP server to perform Kubernetes actions through familiar kubectl-like commands, Helm operations, and resource management features. The server automatically uses your kubeconfig and context to operate against the cluster.
Prerequisites to run the MCP server locally include a working Node or Bun environment and access to a Kubernetes cluster.
bash
# 1) Clone the repository
git clone https://github.com/Flux159/mcp-server-kubernetes.git
cd mcp-server-kubernetes
# 2) Install dependencies using Bun (bun install) or switch to your preferred package manager
bun install
# 3) Run in development mode (watches for file changes)
bun run dev
# 4) Optional: run unit tests
bun run test
# 5) Build for production if needed
bun run build
# 6) Local testing with Inspector (example)
npx @modelcontextprotocol/inspector node dist/index.js
# Follow further instructions on terminal for Inspector link
# 7) Local testing with Claude Desktop (example)
# Place this in your Claude Desktop mcpServers config as shown in the Claude integration section
"} ,{OpenTelemetry observability is optional and can be enabled through environment variables. When enabled, the server will emit traces to OTLP backends such as Jaeger, Grafana Tempo, or Grafana Cloud.
Enable observability by setting environment variables and then starting the server. You can route traces to your preferred OTLP backend.
bash
export ENABLE_TELEMETRY=true
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
npx mcp-server-kubernetes
# Example: view traces at your OTLP backend (e.g., Jaeger UI) if you run Jaeger locally.You can run the server in non-destructive mode to disable all destructive operations. This is useful for read-only workflows or safer exploration of cluster state.
bash
ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS=true npx mcp-server-kubernetes
# Or configure a Claude Desktop profile to enable non-destructive mode by setting the environment variable in the config
{
"mcpServers": {
"kubernetes-readonly": {
"command": "npx",
"args": ["mcp-server-kubernetes"],
"env": {
"ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS": "true"
}
}
}
}The MCP Kubernetes server includes prompts to guide you through Kubernetes troubleshooting and diagnostics. Use the provided prompts to investigate pods, namespaces, and cluster state in a structured workflow.
The server provides a unified API for Kubernetes operations, routing requests to appropriate handlers and interacting with the Kubernetes API. A typical flow involves a client request, transport, server routing, tool filtering, and execution against Kubernetes resources or Helm charts.
Development steps let you iterate quickly while contributing to the MCP server.
ConTRIBUTING guidelines outline how to contribute changes, run tests, and review code quality. Follow the project’s contribution process to propose improvements or fixes.
Advanced options include using non-destructive mode, running Helm operations, and performing port forwarding. You can also perform lifecycle operations on deployments, pods, and other Kubernetes resources through a consistent MCP API.
The MCP Kubernetes server exposes a rich set of tool functions for Kubernetes and Helm operations. You can list resources, describe resources, create or apply manifests, patch fields, manage rollouts, scale deployments, perform port forwarding, run Helm charts, and execute arbitrary kubectl commands via a unified interface.
To integrate with Claude Desktop or other MCP clients, you typically reference the MCP server as an npm-based command. A common approach is to run the MCP server with npx and point clients to that server.
Retrieve Kubernetes resources or lists, matching kubectl's get behavior via MCP.
Describe a resource to show detailed information about its state.
Apply YAML manifests to create or update resources.
Create new Kubernetes resources from definitions.
Delete Kubernetes resources.
Fetch logs from containers in pods.
Manage and switch Kubernetes contexts.
Patch fields of a resource.
Manage deployment rollouts.
Scale deployments or other scalable resources.
Forward ports from pods or services to local machine.
Install a Helm chart into the cluster.
Upgrade an existing Helm release.
Render Helm templates and apply them in a non-authenticated way.
Render Helm templates for uninstall without authentication issues.
Remove problematic pods in specific states to recover clusters.
Cordone, drain, and uncordon nodes for maintenance.
Systematic Kubernetes troubleshooting prompt for pods.
Verify connectivity to the Kubernetes API.