MCP Server Kubernetes
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
MCP Server that can connect to a Kubernetes cluster and manage it. Supports loading kubeconfig from multiple sources in priority order.
https://github.com/user-attachments/assets/f25f8f4e-4d04-479b-9ae0-5dac452dd2ed
Installation & Usage
Prerequisites
Before using this MCP server with any tool, make sure you have:
1. kubectl installed and in your PATH
2. A valid kubeconfig file with contexts configured
3. Access to a Kubernetes cluster configured for kubectl (e.g. minikube, Rancher Desktop, GKE, etc.)
4. Helm v3 installed and in your PATH (no Tiller required). Optional if you don't plan to use Helm.
You can verify your connection by running kubectl get pods in a terminal to ensure you can connect to your cluster without credential issues.
By default, the server loads kubeconfig from ~/.kube/config. For additional authentication options (environment variables, custom paths, etc.), see ADVANCED_README.md.
Claude Code
Add the MCP server to Claude Code using the built-in command:
This will automatically configure the server in your Claude Code MCP settings.
Codex
Add the MCP server to Codex CLI using the built-in command:
This registers the server globally in ~/.codex/config.toml and makes its tools available in all Codex sessions.
Claude Desktop
Add the following configuration to your Claude Desktop config file:
Claude Desktop Connector via mcpb
MCP Server Kubernetes is also available as a mcpb (formerly dxt) extension. In Claude Desktop, go to Settings (Cmd+, on Mac) -> Extensions -> Browse Extensions and scroll to find mcp-server-kubernetes in the modal. Install it & it will install & utilize kubectl via command line & your kubeconfig.
To manually install, you can also get the .mcpb by going to the latest Release and downloading it.
VS Code
VS Code has built-in MCP support. Use the one-click install button above, or add the server to .vscode/mcp.json in your workspace (or to your user mcp.json via **MCP: Open User Configuration**):
Cursor
Cursor supports MCP servers through its AI integration. Add the server to ~/.cursor/mcp.json (global) or .cursor/mcp.json (project):
The server will automatically connect to your current kubectl context. You can verify the connection by asking the AI assistant to list your pods or create a test deployment.
Muse Code
Muse Code reads MCP servers from the mcp_servers block of ~/.config/muse/settings.json. The file must include "schema_version": 1:
To connect over Streamable HTTP instead, first start the server in HTTP mode (it serves /mcp on port 3000 by default; see Streamable HTTP Transport):
Then point Muse Code at that endpoint with the streamable_http transport (headers is optional):
"mode": "optional" lets Muse Code start with a warning if the HTTP server isn't running, instead of aborting.
Start a new Muse Code session after editing the file, then run /mcp to confirm the kubernetes server and its tools are connected.
Usage with mcp-chat
mcp-chat is a CLI chat client for MCP servers. You can use it to interact with the Kubernetes server.
Alternatively, pass it your existing Claude Desktop configuration file from above (Linux should pass the correct path to config):
Mac:
Windows:
Features
- [x] Connect to a Kubernetes cluster
- [x] Unified kubectl API for managing resources
- Get or list resources with kubectl_get
- Describe resources with kubectl_describe
- List resources with kubectl_get
- Create resources with kubectl_create
- Apply YAML manifests with kubectl_apply
- Delete resources with kubectl_delete
- Get logs with kubectl_logs
- Manage kubectl contexts with kubectl_context
- Explain Kubernetes resources with explain_resource
- List API resources with list_api_resources
- Scale resources with kubectl_scale
- Update field(s) of a resource with kubectl_patch