dm-nkp-gitops定制mcp服务器
一组MCP(模型上下文协议)和A2A(代理到代理)服务器,用于监控和调试由Flux CD管理的NKP GitOps基础设施。
此存储库中的项目
此存储库包含多个独立的项目,每个项目都有自己的目的和实现:
| 项目 | 描述 | 语言 | 状态 |
|---|---|---|---|
| MCP 服务器 | 用于AI助手的主MCP服务器(Cursor、Claude Desktop) | Go | ✅ 生产 |
| A2A服务器 | 代理到代理服务器进行多代理协调 | Go | ✅ 生产 |
| kmcp服务器 | 使用kmcp/Kagent | Python | 的Kubernetes原生MCP服务器🔄 备选方案 |
| 多代理示例 | A2A多代理工作流演示代码 | Go | 📚 示例 |
| 故障排除示例 | runbook模式的工作代码示例 | Go | 📚 示例 |
📖 从这里开始:参见 部署和使用指南 有关完整的设置说明。
______________________________________________________________________
快速入门:MCP服务器(主)
MCP服务器是与AI助手集成的主要项目。
构建
make build跑
# With default kubeconfig
./bin/dm-nkp-gitops-mcp-server serve
# With specific kubeconfig in read-only mode
KUBECONFIG=/path/to/kubeconfig ./bin/dm-nkp-gitops-mcp-server serve --read-only在游标中配置
增添 ~/.cursor/mcp.json:
{
"mcpServers": {
"dm-nkp-gitops": {
"command": "/path/to/dm-nkp-gitops-mcp-server",
"args": ["serve", "--read-only"],
"env": {
"KUBECONFIG": "/Users/deepak.muley/ws/nkp/dm-nkp-mgmt-1.conf"
}
}
}
}保存后重新启动Cursor。
可用工具
| 类别 | 工具 | 描述 |
|---|---|---|
| 上下文 | list_contexts | 列出可用的Kubernetes上下文 |
get_current_context | 获取当前活动上下文 | |
| GitOps | get_gitops_status | GitOps总体运行状况摘要 |
list_kustomizations | 列出通量Kustomization及其状态 | |
get_kustomization | 获取详细的Kustomization信息 | |
list_gitrepositories | 列出GitRepository源代码 | |
| 集群 | get_cluster_status | CAPI集群状态 |
list_machines | 列出CAPI机器 | |
| 应用 | get_app_deployments | Kommander应用程序部署状态 |
get_helmreleases | 列出HelmRelease | |
| 调试 | debug_reconciliation | 调试失败协调 |
get_events | 获取Kubernetes事件 | |
get_pod_logs | 获取pod日志 | |
| 政策 | check_policy_violations | 检查违反政策的情况 |
list_constraints | 列出网守约束 |
📖 完整工具参考→ -包含参数、示例和用例的完整文档
查询示例
配置后,询问您的AI助手:
"What's the GitOps status of my cluster?"
"Why is the clusterops-clusters Kustomization failing?"
"Show me all CAPI clusters and their health"
"Check for any policy violations"
"Debug the reconciliation failure for clusterops-workspace-applications"项目详情
1.MCP服务器(主)
位置: cmd/server/\ 二进制: dm-nkp-gitops-mcp-server\ 目的:用于AI助手的MCP服务器(Cursor、Claude Desktop、VS Code)
- 通过stdio使用JSON-RPC 2.0
- 公开了15多种GitOps监控工具
- 建议用于生产的只读模式
- 看 代理商.md AI代理集成指南
快速开始: make build && ./bin/dm-nkp-gitops-mcp-server serve --read-only
______________________________________________________________________
2.A2A服务器
位置: cmd/a2a-server/\ 二进制: dm-nkp-gitops-a2a-server\ 目的:用于多代理协调的代理到代理服务器
- 基于HTTP的服务器(端口8080)
- 基于任务的执行(有状态)
- 在以下位置发现代理卡
/.well-known/agent.json - 通过以下方式与MCP服务器共享工具实现
pkg/tools/
快速开始: make build-a2a && ./bin/dm-nkp-gitops-a2a-server serve
文档:
______________________________________________________________________
3.kmcp服务器(Kubernetes原生)
位置: kmcp-server/\ 语言python\ 目的:使用kmcp/Kagent框架的替代实现
- 通过MCPServer CRD进行Kubernetes本地部署
- 自动管理RBAC和扩展
- 使用FastMCP SDK
- 具有相同工具名称的并行实现
快速开始:参见 kmcp服务器/README.md
文档:
- kmcp服务器自述文件 -完整的设置和部署指南
- KMCP学习指南 -kmcp框架的学习路径
- 框架比较 -自定义vs kmcp vs其他框架
______________________________________________________________________
4.示例
多代理示例
位置: examples/multi-agent/\ 目的:显示A2A多代理协调的演示代码
- 用于协调专业代理的编排器模式
- 示例工作流(GitOps健康检查、事件调查)
- 看 examples/multi-agent/README.md 详情
快速开始: make demo-multi-agent (需要A2A服务器运行)
故障排除示例
位置: examples/troubleshooting/\ 目的:程序化Runbook的工作代码示例
- 结构化工作流定义
- 决策树模式
- 工具调用生成示例
- 看 示例/故障排除/README.md 详情
快速开始: make build-troubleshooter && ./bin/troubleshooter gitops-failure
______________________________________________________________________
文档
入门指南
协议指南
- MCP底漆 -了解MCP协议
- A2A学习指南 -A2A教程
- A2A协议 -Agent到Agent协议的解释及其与MCP的比较
- KMCP学习指南 -kmcp框架的学习路径
- 框架比较 -自定义vs kmcp vs其他框架
运行手册和最佳实践
- K8S故障排除操作手册 - 📋 包含工作流程和示例的全面故障排除指南
- K8S安全运行手册 - 🔒 Kubernetes集群的安全评估和强化指南
- Runbook最佳实践 - 📚 创建AI代理友好运行手册的标准做法(模板参考)
- 故障排除示例 -runbook模式的工作代码示例
- 测试指导 - 📚 如何构建、测试和学习故障排除示例
架构和高级主题
- MCP服务器架构 -深入了解服务器流程和推荐功能
- 安全 -安全分析和加固指南
- 企业部署 -生产部署指南
- NKP生产部署 - 🚀 Nutanix Kubernetes平台完整指南
- 通量MCP设置 -使用官方Flux MCP服务器
发展
构建所有项目
# Build MCP server
make build
# Build A2A server
make build-a2a
# Build both servers
make build-both
# Build troubleshooting examples
make build-troubleshooter运行测试
# Run Go unit tests
make test
# Test MCP protocol
make test-mcp
# Test A2A server
make test-a2a-card
make test-a2a-health
# Test troubleshooting workflows
make test-troubleshooter代码质量
# Format code
make fmt
# Lint
make lint看 make help 对于所有可用的目标。
使用Kind集群进行测试
使用一个集群和Flux CD在本地测试MCP服务器:
# Prerequisites: kind, kubectl, flux CLI, jq
# Full setup and test (creates cluster, installs Flux, runs tests)
make kind-all
# Or step by step:
make kind-setup # Create kind cluster with Flux CD
make kind-test # Run MCP tests
make kind-interactive # Interactive testing mode
make kind-cleanup # Delete cluster
# Manual testing
./scripts/test-with-kind.sh all测试脚本将:
- 创建一个名为
mcp-test - 安装Flux CD控制器
- 部署示例GitOps资源(Kustomization、GitRepositories、HelmRelease)
- 运行一套MCP协议测试
- Cursor集成的打印配置
安全
始终使用 --read-only 生产模式 以防止意外的突变。
看 安全文档 用于:
- 安全分析和威胁模型
- 限制访问的RBAC配置
- 硬化建议
建筑
┌─────────────────┐ stdin/stdout ┌─────────────────────┐
│ AI Assistant │◄────────────────────►│ MCP Server │
│ (Cursor/Claude)│ JSON-RPC 2.0 │ │
└─────────────────┘ │ ┌───────────────┐ │
│ │ Tool Handlers │ │
│ └───────┬───────┘ │
│ │ │
│ ▼ │
│ ┌───────────────┐ │
│ │ K8s Clients │ │
│ └───────┬───────┘ │
└──────────┼──────────┘
│
▼
┌─────────────────────┐
│ Kubernetes API │
│ - Flux CRDs │
│ - CAPI CRDs │
│ - Kommander CRDs │
│ - Core resources │
└─────────────────────┘独立工程
此存储库中的每个项目都旨在 独立 为了可维护性:
- MCP 服务器 和 A2A服务器 分享
pkg/tools/但可以单独构建/部署 - kmcp服务器 完全独立(Python,独立依赖项)
- 例子 是独立的演示/学习代码
- 每个项目都有自己的README,其中包含具体的说明
这种结构允许:
- 独立的版本控制和发布
- 单独的维护周期
- 如果需要,可以轻松提取到单独的存储库
- 关注点清晰分离
相关项目
- dm-nkp-gitops基础设施 -GitOps基础架构仓库
- 通量操作员MCP -官方Flux MCP服务器
- 卡金特 -Kubernetes的CNCF AI代理框架
许可证
麻省理工学院
