MCP-K8sWizard
 ](https://golang.org/)       
Kubernetes现代DevOps向导\ 通过AI驱动的自然语言界面和全面的DevOps自动化简化Kubernetes操作。
🚀 概述
MCP-K8sWizard是一个为专业DevOps团队设计的全面的模型上下文协议(MCP)解决方案。它为复杂的Kubernetes工作流提供了自然语言接口,使团队能够通过人工智能驱动的对话高效地管理集群、监控应用程序和执行操作任务。
✨ 主要特点
🎯 多云Kubernetes管理
- 通用兼容性:对EKS、AKS、GKE、RKE2、K3和标准Kubernetes发行版的原生支持
- 智能集群检测:自动识别和配置集群类型和能力
- 高级资源管理:跨所有Kubernetes资源类型的全面CRUD操作
- 实时监控:实时集群运行状况、资源利用率和性能指标
🤖 人工智能驱动的操作
- 自然语言处理:用于复杂DevOps操作的对话界面
- 智能故障排除:人工智能驱动的诊断和逐步解决方案指导
- 智能提示:针对不同场景的上下文感知提示建议
- 自动化洞察:主动识别潜在问题和优化机会
🔒 安全和访问控制
- RBAC集成:与Kubernetes RBAC和身份提供者完全集成
- 审计日志:对所有操作和访问进行全面的审计跟踪
- 安全通信:所有通信的TLS加密
- 最低特权:采用最小权限访问模式设计安全
🏗️ 建筑
MCP协议集成
下图显示了MCP-K8sWizard如何通过模型上下文协议与VSCode/Cursor AI集成:
┌─────────────┐ ┌──────────────┐ ┌─────────────────┐
│ Cursor AI │───▶│ MCP Protocol │───▶│ MCP-K8sWizard │
└─────────────┘ └──────────────┘ │ Server │
└─────────┬───────┘
│
┌────────────────────────────┼────────────────────────────┐
│ │ │
┌───────▼───────┐ ┌───────▼───────┐ ┌───────▼───────┐
│ Kubernetes │ │ Context │ │ Tool Handlers │
│ API │ │ Manager │ │ │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
┌────────────────────────────┼────────────────────────────┐
│ │ │
┌───────▼───────┐ ┌───────▼───────┐ ┌───────▼───────┐
│ K8s Tools │ │ Kubectl Tools │ │ Prompt Tools │
│ │ │ │ │ │
│ • Cluster Info│ │ • Resource │ │ • Diagnostics │
│ • Resources │ │ CRUD │ │ • Troubleshoot│
│ • Logs/Events │ │ • Scaling │ │ • Optimization│
│ • Pod Exec │ │ • Rollouts │ │ • Security │
└───────────────┘ └───────────────┘ └───────────────┘组件体系结构
MCP-K8sWizard的内部架构遵循分层方法:
┌─────────────────────────────────────────────────────────────────────────────┐
│ MCP Layer │
├─────────────────────────────────────────────────────────────────────────────┤
│ MCP Server ──▶ Tool Registry ──▶ Request Router │
└──────────────────────────────────┬──────────────────────────────────────────┘
│
┌──────────────────────────────────▼──────────────────────────────────────────┐
│ Core Services │
├─────────────────────────────────────────────────────────────────────────────┤
│ Context Manager ──▶ K8s Client Manager ──▶ Resource Handler │
│ │ │ │ │
│ └───────────────────────┼────────────────────────┘──────────────────┘
│ │ │
│ Config Manager ──▶ Event Monitor ──▶ Kubernetes API │
└─────────────────────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────▼───────────────────────────────────────────┐
│ Tool Handlers │
├─────────────────────────────────────────────────────────────────────────────┤
│ K8s Tools │ Kubectl Tools │ Prompt Tools │ Context Tools │
│ ───────── │ ──────────── │ ─────────── │ ──────────── │
│ • Cluster Ops │ • Resource Mgmt │ • AI Guidance │ • Multi-Cluster│
│ • Monitoring │ • CRUD Ops │ • Diagnostics │ • Context Sw. │
│ • Debugging │ • Scaling │ • Optimization │ • Health Chk │
└─────────────────────────────────────────────────────────────────────────────┘🛠️ 可用工具
Kubernetes管理工具(共37个)
| 类别 | 工具 | 描述 |
|---|---|---|
| Kubernetes操作(14) | k8s_cluster_info, k8s_check_all_clusters, ping, k8s_list_resources, k8s_get_resource, k8s_get_logs, k8s_get_events, k8s_exec_in_pod, k8s_natural_language_query | 直接Kubernetes API操作、监控和调试 |
| Kubectl操作(12) | kubectl_get, kubectl_describe, kubectl_create, kubectl_apply, kubectl_delete, kubectl_context, kubectl_scale, kubectl_patch, kubectl_rollout, kubectl_generic, explain_resource, list_api_resources | 通过kubectl进行完整的CRUD操作、扩展、推出和资源管理 |
| 上下文管理(4) | k8s_set_context, k8s_get_current_context, k8s_list_contexts, k8s_clear_context | 多集群上下文切换和管理 |
| 人工智能制导(7) | k8s_diagnose, k8s_troubleshoot, k8s_optimize, k8s_security, k8s_performance, k8s_deployment, prompt_suggestions | 智能诊断、优化和故障排除提示 |
🚀 快速开始
先决条件
- 转到1.25.1或更高版本
- Kubernetes集群访问(kubeconfig配置)
- 支持MCP的VSCode/Cursor AI
- macOS或Linux操作系统
安装
有关详细的安装说明,请参阅我们的综合 安装手册.
快速设置:
- 克隆并安装
git clone https://github.com/your-org/mcp-k8swizard.git
cd mcp-k8swizard
make install- 配置光标AI
添加到您的 ~/.cursor/mcp.json:
{
"mcpServers": {
"k8s-wizard": {
"command": "/path/to/mcp-k8swizard",
"args": ["--verbose"]
}
}
}- 重新启动游标AI 并开始使用自然语言命令!
📖 需要详细的说明吗? 查看我们的 安装手册 用于分步设置、故障排除和高级配置选项。
基本用法
# Check cluster health
"Show me the status of all my Kubernetes clusters"
# List resources
"List all pods in the production namespace"
# Debug issues
"Get logs from the failing pod in the web-app deployment"
# Scale applications
"Scale the frontend deployment to 5 replicas"
# Troubleshoot problems
"Help me diagnose why my pod is stuck in Pending state"📋 自然语言示例
群集管理
"Show me all my Kubernetes clusters and their health status"
"Check the resource usage across all nodes in my EKS cluster"
"List all namespaces and their resource quotas"资源操作
"Create a new namespace called 'staging'"
"List all deployments with more than 3 replicas"
"Show me the configuration of the nginx service"
"Delete all pods with the label 'app=test'"调试与故障排除
"Get the logs from the last 100 lines of the api-server pod"
"Show me events related to the failing deployment"
"Execute a shell command in the debug container"
"Why is my pod not starting? Help me troubleshoot"扩展和更新
"Scale the web-app deployment to 10 replicas"
"Roll out a new version of the frontend service"
"Pause the rollout of the database deployment"
"Show me the rollout history for the api service"🔧 配置
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
KUBECONFIG | kubeconfig文件的路径 | ~/.kube/config |
K8S_CONTEXT | 默认Kubernetes上下文 | 当前上下文 |
LOG_LEVEL | 日志记录级别(调试、信息、警告、错误) | INFO |
LOG_FILE | 日志文件路径 | stdout |
命令行选项
./mcp-k8swizard --help
Options:
-log-level string
Set log level (DEBUG, INFO, WARN, ERROR)
-verbose
Enable verbose logging (equivalent to DEBUG level)
-version
Show version information
-help
Show help information🤝 贡献
我们欢迎捐款!请查看我们的 贡献指南 了解详情。
开发设置
- 分叉存储库
- 创建要素分支
- 进行更改
- 提交拉取请求
开发命令
# Build the project
make build
# Install dependencies
make deps
# Format code
make fmt
# Run linter
make lint
# Run go vet
make vet
# Clean build artifacts
make clean代码的风格
- 遵循Go标准格式(
gofmt) - 使用有意义的变量和函数名
- 为公共功能添加评论
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
🙏 致谢
- 模型上下文协议 对于MCP规范
- Kubernetes 令人惊叹的容器编排平台
- 去 优秀的编程语言
- 开源社区提供灵感和支持
📚 文档
手册
快速链接
📞 支持
- 文档: 维基
- 问题:
- 讨论:
______________________________________________________________________
由以下材料制成❤️ Kubernetes社区
