必须收集MCP服务器
为AI助手提供对OpenShift全面访问的模型上下文协议(MCP)服务器必须收集数据以进行故障排除和诊断。
概述
必须收集的MCP服务器使AI助手能够通过必须收集的档案深入分析OpenShift集群,提供:
- 完成集群配置和状态
- 网络连接和性能数据
- ETCD数据库运行状况和指标
- 带有日志的Pod和节点诊断
- 操作员状态和版本跟踪
特性
🚀 演出
- 快速资源访问:对约11000个资源进行内存索引
- 计划任务管理软件:加载和索引需要5-10秒
- 快速查询:对于索引资源查找,\
cd must-gather-mcp-server make build
### 通过npm(发布时)
npx must-gather-mcp-server@latest --must-gather-path /path/to/must-gather
### 通过Python(发布时)
uvx must-gather-mcp-server --must-gather-path /path/to/must-gather
## 用法
### STDIO模式(默认)
用于Claude Desktop、MCP Inspector和其他使用STDIO的MCP客户端:
./must-gather-mcp-server --must-gather-path /path/to/must-gather
#### 使用克劳德桌面
增添 `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS):
{ "mcpServers": { "must-gather": { "command": "/path/to/must-gather-mcp-server", "args": ["--must-gather-path", "/path/to/your/must-gather"] } } }
#### 与MCP检查员一起
npx @modelcontextprotocol/inspector@latest ./must-gather-mcp-server \ --must-gather-path /path/to/must-gather
### HTTP/SSE模式
用于Goose或其他基于HTTP的MCP客户端等代理:
./must-gather-mcp-server \ --must-gather-path /path/to/must-gather \ --http \ --http-addr localhost:8080
服务器将于启动 `http://localhost:8080` SSE端点位于 `http://localhost:8080/sse`.
#### 与鹅
配置Goose以连接到HTTP端点:
goose config
mcp_servers: must-gather: url: http://localhost:8080/sse
然后启动Goose,它将连接到MCP服务器。
## 命令行选项
Flags: --must-gather-path string Path to must-gather directory (required) --http Run in HTTP/SSE mode instead of STDIO --port string HTTP server port (replaces deprecated --http-addr) --http-addr string HTTP server address (deprecated, use --port)
--config string Path to configuration file --config-dir string Path to drop-in configuration directory
--log-level int Log verbosity level (0-9)
--require-oauth Require OAuth authentication --oauth-audience string OAuth audience for token validation --authorization-url string OIDC authorization server URL
--version Show version information -h, --help help for must-gather-mcp-server
有关完整的配置选项,请参阅 [身份验证指南](docs/AUTHENTICATION.md).
## 查询示例
### 聚类分析
- “此集群运行的是哪个版本的OpenShift?”
- “显示所有降级的群集运算符”
- “列出所有主节点及其状态”
- “这个集群在哪个平台上,在哪个地区?”
### 机器配置
- “显示所有MachineConfigPools及其状态”
- “是否有任何节点因计算机配置问题而降级?”
- “哪些MachineConfig应用于工作节点?”
### 存储故障排除
- “哪个是默认的StorageClass?”
- “显示所有失败的卷附件”
- “列出所有处于失败状态的持久卷”
- “群集中有哪些CSI驱动程序可用?”
### 安全和RBAC
- “哪些SecurityContextConstraints允许特权容器?”
- “显示具有通配符权限的ClusterRoles”
- “列出所有有权访问特权SCC的用户”
### 操作员生命周期(OLM)
- “是否有任何运营商订阅处于UpgradeFailed状态?”
- “显示需要批准的待定安装计划”
- “认证运营商目录来源是否健康?”
### 事件和事件
- “显示最近一小时的所有警告事件”
- “X舱发生了什么事?”
- “过去2小时命名空间Y的事件时间表”
- 查找所有原因为“回退”或“失败”的事件
### ETCD监控
- “检查ETCD群集运行状况”
- “ETCD数据库大小和配额使用情况如何?”
- “ETCD集群中是否存在筏板滞后?”
- “列出所有ETCD成员”
### 网络故障排除
- “显示所有失败的网络连接检查”
- “这个集群的网络规模是多少?”
- “哪些OVN组件使用的资源最多?”
### Pod和节点诊断
- “获取命名空间Y中pod X的日志”
- “显示节点Z的kubelet日志”
- “按'error'字符串过滤节点Z的kubelet日志”
- “在所有节点的kubelet日志中搜索'OOM'”
- “列出所有具有诊断数据的节点”
- “获取节点A的全面诊断”
### 扩展节点诊断
- 显示节点X的硬件信息(CPU、PCI设备)
- “在所有节点上分析dmesg的错误和OOM终止”
- “节点Y的内核引导参数是什么?”
### 主机级调试
- “列出所有主机系统服务日志”
- “显示最后100行的crio服务日志”
- “在所有主机服务日志中搜索'error'”
### 控制平面调试
- “显示主-0的kube-apiserver终止日志”
- “有任何控制飞机吊舱坠毁吗?”
### 准入控制
- “列出所有验证和变异的Webhook”
- “配置了哪些准入政策?”
### 配置
- “列出所有群集配置资源”
- “显示OAuth配置”
- “启用了哪些功能门?”
### 入口和路线
- “列出所有显示其入场状态的路线”
- “显示命名空间Y中路由X的详细信息”
- “默认IngressController的状态是什么?”
- “列出所有具有TLS边缘终止的路由”
- “是否有Kubernetes Ingress资源?”
### 监测和可观察性
- “普罗米修斯服务器状态和TSDB统计数据是什么?”
- “显示所有失败的普罗米修斯刮靶”
- “列出当前正在触发的所有关键警报”
- “按系列计数,最重要的指标是什么?”
- “显示AlertManager群集状态”
- “列出群集中的所有ServiceMonitors”
- “配置了哪些警报规则?”
## 建筑
### 需求
- 转到1.25或更高版本
- 制造
### 构建命令
Build for current platform
make build
Build for all platforms
make build-all-platforms
Run tests
make test
Run linter
make lint
Format code
make fmt
## 建筑
┌─────────────────────────────────────────────────────────────────┐ │ MCP Client │ │ (Claude Desktop, Goose, etc.) │ └────────────────────────────┬────────────────────────────────────┘ │ MCP Protocol │ (STDIO or HTTP/SSE) ┌────────────────────────────▼────────────────────────────────────┐ │ Must-Gather MCP Server │ │ ┌──────────────────────────────────────────────────────────┐ │ │ │ 62 MCP Tools (5 Toolsets) │ │ │ │ Cluster | Core | Diagnostics | Network | Monitoring │ │ │ └─────────────────────┬────────────────────────────────────┘ │ │ │ │ │ ┌─────────────────────▼──────────────┬──────────────────────┐ │ │ │ In-Memory Index │ On-Demand Files │ │ │ │ • ~11k YAML resources │ • Pod logs │ │ │ │ • GVK, namespace, labels │ • Node diagnostics │ │ │ │ • <50ms lookups │ • ETCD metrics │ │ │ └────────────────────────────────────┴──────────────────────┘ │ └────────────────────────────┬────────────────────────────────────┘ │ ┌────────────────────────────▼────────────────────────────────────┐ │ Must-Gather Archive │ │ cluster-scoped-resources/ | namespaces/ | nodes/ | etcd_info/ │ │ network_logs/ | pod_network_connectivity_check/ | monitoring/ │ └─────────────────────────────────────────────────────────────────┘
### 数据加载
1. **初创公司**:从集群范围的资源/和命名空间加载YAML资源/
1. **索引**:根据GVK、命名空间和标签构建内存索引(~5-10s)
1. **查询**:使用索引数据快速查找(\<50ms)
1. **日志**:调用工具时按需加载(未编入索引)
### 目录结构
must-gather/ ├── quay-io-okd-scos-content-sha256-.../ (container directory) │ ├── cluster-scoped-resources/ # Cluster-wide resources │ │ ├── config.openshift.io/ # Cluster config, operators, version │ │ └── core/ # Nodes, PVs │ ├── namespaces/ # Namespaced resources │ │ └── {namespace}/ │ │ ├── core/ # Pods, services, etc. │ │ └── pods/ # Pod logs │ ├── nodes/ # Node diagnostics │ ├── etcd_info/ # ETCD health and metrics │ ├── network_logs/ # Network scale and OVN metrics │ ├── pod_network_connectivity_check/ # Connectivity test results │ └── monitoring/ # Prometheus and AlertManager data │ ├── alertmanager/ # AlertManager status │ ├── prometheus/ # Prometheus metrics and configuration │ │ ├── prometheus-k8s-0/ # Replica 0 (targets, TSDB stats) │ │ ├── prometheus-k8s-1/ # Replica 1 (targets, TSDB stats) │ │ ├── rules.json # Alerting and recording rules │ │ └── status/ # Shared configuration and flags │ └── servicemonitors/ # ServiceMonitor CRDs
### 工具类别
**索引资源** (快速查询):
- 集群资源(运营商、版本、基础设施、节点)
- 核心资源(Pod、服务、配置映射等)
- 所有Kubernetes/OOpenShift API资源
**按需数据** (从文件中读取):
- Pod容器日志
- 节点诊断(kubelet日志、sysinfo、硬件信息)
- ETCD详细状态
- 网络连接检查
## 文档
- [工具参考](docs/TOOLS.md) -所有62个MCP工具的完整参考
- [身份验证指南](docs/AUTHENTICATION.md) -OAuth/OIDC设置和配置
- [开发指南](docs/DEVELOPMENT.md) -构建、测试和贡献
## 演出
### 初创公司
- 加载时间:11000个资源约5-10秒
- 索引时间:~2-3秒
- 内存使用量:~100-200MB(取决于集群大小)
### 查询性能
- 索引查询:\<50ms
- 日志检索:\<500ms(大多数情况下)
- Kubelet日志解压:\<1s(371K.gz文件)
## 故障排除
### 必须收集但未找到
Error: must-gather path does not exist: /path
解决方案:验证路径指向提取的必须收集的目录(而不是.tar文件)。
### 未找到容器目录
加载器自动检测容器目录(通常命名为 `quay-io-okd-scos-content-sha256-...`).如果失败,请检查必须收集的数据是否已正确提取。
### 缺少工具
Registered 0 toolsets
解决方案:确保工具集导入存在于 `cmd/must-gather-mcp-server/cmd/root.go`.
## 贡献
欢迎投稿!请确保:
- 代码格式为 `make fmt`
- 测试通过 `make test`
- 林特尔与 `make lint`
- 文档已针对新功能进行了更新
## 许可证
Apache许可证2.0
## 版本
跑 `./must-gather-mcp-server --version` 查看版本信息。