AI Skill Hub 推荐使用:k8s MCP 服务 是一款优质的MCP工具。AI 综合评分 7.5 分,在同类工具中表现稳健。如果你正在寻找可靠的MCP工具解决方案,这是一个值得深入了解的选择。
k8s MCP 服务:管理您的 Kubernetes 集群
k8s MCP 服务 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
k8s MCP 服务:管理您的 Kubernetes 集群
k8s MCP 服务 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/reza-gholizade/k8s-mcp-server
# 方式二:手动配置 claude_desktop_config.json
{
"mcpServers": {
"k8s-mcp---": {
"command": "npx",
"args": ["-y", "k8s-mcp-server"]
}
}
}
# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
# 安装后在 Claude 对话中直接使用 # 示例: 用户: 请帮我用 k8s MCP 服务 执行以下任务... Claude: [自动调用 k8s MCP 服务 MCP 工具处理请求] # 查看可用工具列表 # 在 Claude 中输入:"列出所有可用的 MCP 工具"
// claude_desktop_config.json 配置示例
{
"mcpServers": {
"k8s_mcp___": {
"command": "npx",
"args": ["-y", "k8s-mcp-server"],
"env": {
// "API_KEY": "your-api-key-here"
}
}
}
}
// 保存后重启 Claude Desktop 生效
A Kubernetes Model Context Protocol (MCP) server that provides tools for interacting with Kubernetes clusters through a standardized interface.
kubectl describe.stdio mode for CLI tools, sse mode, or streamable-http mode for web applications, and --readonly for no change in the cluster.kubectl configured with appropriate cluster accessA hosted deployment is available on Fronteir AI.
1. Clone the repository:
git clone https://github.com/reza-gholizade/k8s-mcp-server.git
cd k8s-mcp-server
2. Install dependencies:
go mod download
3. Build the server:
go build -o k8s-mcp-server main.go
You can also run the server using the pre-built Docker image from Docker Hub.
1. Pull the image:
docker pull ginnux/k8s-mcp-server:latest
You can replace latest with a specific version tag (e.g., 1.0.0).
Note: The server supports multiple authentication methods. You can either mount a kubeconfig file (as shown below) or use environment variables for authentication (see Kubernetes Authentication section above).
* SSE Mode (default behavior of the image):
docker run -p 8080:8080 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest
This maps port 8080 of the container to port 8080 on your host and mounts your Kubernetes config read-only to the non-root user's home directory. The server will be available at http://localhost:8080. The image defaults to sse mode on port 8080.
* Streamable-HTTP Mode:
docker run -p 8080:8080 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest --mode streamable-http
This runs the server in streamable-http mode. The server will be available at http://localhost:8080/mcp.
* Stdio Mode:
docker run -i --rm -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest --mode stdio
The -i flag is important for interactive stdio communication. --rm cleans up the container after exit.
* Custom Port for SSE Mode:
docker run -p 9090:9090 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest --mode sse --port 9090
* Custom Port for Streamable-HTTP Mode:
docker run -p 9090:9090 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest --mode streamable-http --port 9090
* Alternative: Mount entire .kube directory:
docker run -p 8080:8080 -v ~/.kube:/home/appuser/.kube:ro ginnux/k8s-mcp-server:latest
* Using environment variables for authentication (no file mounting required):
# Using kubeconfig content from environment variable
docker run -p 8080:8080 \
-e KUBECONFIG_DATA="$(cat ~/.kube/config)" \
ginnux/k8s-mcp-server:latest
# Or using API server URL and token
docker run -p 8080:8080 \
-e KUBERNETES_SERVER="https://kubernetes.example.com:6443" \
-e KUBERNETES_TOKEN="your-token-here" \
-e KUBERNETES_CA_CERT_PATH="/path/to/ca.crt" \
-v /path/to/ca.crt:/path/to/ca.crt:ro \
ginnux/k8s-mcp-server:latest
Create a docker-compose.yml file:
Option 1: Using kubeconfig file (traditional method):
version: '3.8'
services:
k8s-mcp-server:
image: ginnux/k8s-mcp-server:latest # Or a specific version
container_name: k8s-mcp-server
ports:
- "8080:8080" # Host:Container, adjust if using a different SERVER_PORT
volumes:
- ~/.kube:/home/appuser/.kube:ro # Mount kubeconfig read-only to non-root user home
environment:
- KUBECONFIG=/home/appuser/.kube/config
- SERVER_MODE=sse # Can be 'stdio', 'sse', or 'streamable-http'
- SERVER_PORT=8080 # Port for SSE/streamable-http modes
# command: ["--read-only"] # Uncomment this line to enable read-only mode
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
Option 2: Using environment variables (no file mounting):
version: '3.8'
services:
k8s-mcp-server:
image: ginnux/k8s-mcp-server:latest
container_name: k8s-mcp-server
ports:
- "8080:8080"
environment:
- KUBECONFIG_DATA=${KUBECONFIG_DATA} # Set this in your .env file or shell
# Or use API server and token:
# - KUBERNETES_SERVER=https://kubernetes.example.com:6443
# - KUBERNETES_TOKEN=${KUBERNETES_TOKEN}
- SERVER_MODE=sse
- SERVER_PORT=8080
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
Note: To enable read-only mode, use the command override as shown in Option 1. For stdio mode, you might need to adjust 'ports', add 'stdin_open: true' and 'tty: true', and potentially override the command.
Then start with:
docker compose up -d To see logs: docker compose logs -f k8s-mcp-server.
The Docker image runs as a non-root user (appuser with UID 1001) for enhanced security: - The application binary is located at /usr/local/bin/k8s-mcp-server - The kubeconfig should be mounted to /home/appuser/.kube/config - Health checks are enabled to monitor container status - The container includes minimal dependencies (ca-certificates and curl only)
#### Making API Calls (SSE/Streamable-HTTP Mode) Once the server is running in SSE or streamable-http mode, you can make JSON-RPC calls to its HTTP endpoint:
curl -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "getAPIResources",
"arguments": {
"includeNamespaceScoped": true,
"includeClusterScoped": true
}
}
}' http://localhost:8080/
You can also check the health status:
curl -f http://localhost:8080/
macOS/Linux:
curl -sSL https://raw.githubusercontent.com/reza-gholizade/k8s-mcp-server/main/scripts/install-vscode-config.sh | bash
Windows (PowerShell):
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/reza-gholizade/k8s-mcp-server/main/scripts/install-vscode-config.ps1'))
1. Install the MCP extension in VS Code:
code --install-extension modelcontextprotocol.mcp
Open VS Code settings (Cmd/Ctrl + ,) → Open Settings JSON → Add:
macOS/Linux:
{
"mcp.mcpServers": {
"k8s-mcp-server": {
"command": "k8s-mcp-server",
"args": ["--mode", "stdio"],
"env": {
"KUBECONFIG": "${env:HOME}/.kube/config"
}
}
}
}
Read-Only Mode (recommended for safety):
{
"mcp.mcpServers": {
"k8s-mcp-server": {
"command": "k8s-mcp-server",
"args": ["--mode", "stdio", "--read-only"],
"env": {
"KUBECONFIG": "${env:HOME}/.kube/config"
}
}
}
}
Kubernetes Tools Only:
{
"mcp.mcpServers": {
"k8s-mcp-server": {
"command": "k8s-mcp-server",
"args": ["--mode", "stdio", "--no-helm"],
"env": {
"KUBECONFIG": "${env:HOME}/.kube/config"
}
}
}
}
Helm Tools Only:
{
"mcp.mcpServers": {
"k8s-mcp-server": {
"command": "k8s-mcp-server",
"args": ["--mode", "stdio", "--no-k8s"],
"env": {
"KUBECONFIG": "${env:HOME}/.kube/config"
}
}
}
}
Read-Only with Kubernetes Tools Only:
{
"mcp.mcpServers": {
"k8s-mcp-server": {
"command": "k8s-mcp-server",
"args": ["--mode", "stdio", "--read-only", "--no-helm"],
"env": {
"KUBECONFIG": "${env:HOME}/.kube/config"
}
}
}
}
Windows:
{
"mcp.mcpServers": {
"k8s-mcp-server": {
"command": "k8s-mcp-server.exe",
"args": ["--mode", "stdio"],
"env": {
"KUBECONFIG": "${env:USERPROFILE}/.kube/config"
}
}
}
}
Download the appropriate binary from the releases page and add it to your system PATH.
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: k8s-mcp-server-rb subjects: - kind: ServiceAccount name: k8s-mcp-server-sa namespace: default roleRef: kind: ClusterRole name: k8s-mcp-server-role
./k8s-mcp-server
export KUBECONFIG=/path/to/your/kubeconfig ./k8s-mcp-server
**Note:** The server automatically detects which authentication method to use based on the available environment variables and file system. You don't need to explicitly configure the authentication method - it will use the first available method in the priority order listed above.
#### Read-Only Mode
The server supports a read-only mode that disables all write operations, providing a safer way to explore and monitor your Kubernetes cluster without the risk of making changes.
Enable read-only mode with the `--read-only` flag:
bash ./k8s-mcp-server --read-only
You can combine read-only mode with any server mode:
bash
You can customize the configuration by modifying the settings:
{
"mcp.mcpServers": {
"k8s-mcp-server": {
"command": "k8s-mcp-server",
"args": ["--mode", "stdio"],
"env": {
"KUBECONFIG": "/path/to/your/kubeconfig",
"KUBERNETES_CONTEXT": "your-context-name"
}
}
}
}
apiVersion: apps/v1 kind: Deployment metadata: name: k8s-mcp-server namespace: default spec: replicas: 1 selector: matchLabels: app: k8s-mcp-server template: metadata: labels: app: k8s-mcp-server spec: serviceAccountName: k8s-mcp-server-sa containers: - name: k8s-mcp-server image: ginnux/k8s-mcp-server:latest ports: - containerPort: 8080 env: - name: SERVER_MODE value: "sse" - name: SERVER_PORT value: "8080"
#### 4. Kubeconfig File Path (Default)
If none of the above methods are available, the server falls back to using a kubeconfig file:
- Uses the path provided via `--kubeconfig` flag (if implemented) or `KUBECONFIG` environment variable
- Defaults to `~/.kube/config` if neither is specified
bash
Once configured, you can use the Kubernetes MCP server in VS Code with Claude or other MCP-compatible tools:
1. Open VS Code 2. Access Claude (or other MCP-enabled AI assistant) 3. Use natural language to interact with your Kubernetes cluster: - "List all pods in the default namespace" - "Show me the logs for pod nginx-123" - "Get the CPU usage for worker-node-1" - "Describe the deployment called my-app"
k8s-mcp-server is in your PATHKUBECONFIG path is correctk8s MCP 服务是一个开源的 Kubernetes 集群管理工具,使用 Go 语言编写,提供了一个易于使用的 API,用于管理 Kubernetes 集群。该工具可以提高集群的可用性和可靠性,但需要注意的是,工具的稳定性和安全性需要进一步的测试和评估。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
总体来看,k8s MCP 服务 是一款质量良好的MCP工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。
| 原始名称 | k8s-mcp-server |
| 原始描述 | 开源MCP工具:Manage Your Kubernetes Cluster with k8s mcp-server。⭐157 · Go |
| Topics | mcpkubernetesgo |
| GitHub | https://github.com/reza-gholizade/k8s-mcp-server |
| License | MIT |
| 语言 | Go |
收录时间:2026-05-23 · 更新时间:2026-05-23 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端