README
🚀 Kubernetes 支持捆绑包 MCP 服务器
MCP(模型上下文协议)服务器是一款用于管理 Kubernetes 环境中支持捆绑包的工具。它具备丰富功能,可实现捆绑包管理、文件操作以及 kubectl 命令执行,为 Kubernetes 环境管理提供了便利。
🚀 快速开始
安装
# 克隆仓库
git clone https://github.com/your-username/mcp-server-troubleshoot.git
cd mcp-server-troubleshoot
# 创建虚拟环境
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 安装依赖
pip install -r requirements.txt
运行
# 启动服务器
python src/mcp_server_troubleshoot/__main__.py
✨ 主要特性
- 捆绑包管理:支持创建、更新和删除支持捆绑包。
- 文件操作:提供对捆绑包内容的读取和写入功能。
- Kubectl 命令执行:可以直接在服务器上执行 kubectl 命令。
📦 安装指南
开发环境安装
# 克隆仓库
git clone https://github.com/your-username/mcp-server-troubleshoot.git
cd mcp-server-troubleshoot
# 创建虚拟环境
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 安装开发依赖
pip install -e ".[dev]"
💻 使用示例
基础用法
from mcp_server_troubleshoot import kubectl
# 执行 Kubectl 命令
result = kubectl.execute("get pods")
print(result)
📚 详细文档
- README.md:项目概述。
- docs/:详细文档,包括组件设计和示例提示。
- scripts/:构建和运行脚本。
🔧 技术细节
工具模块
- bundle.py:捆绑包管理模块。
- files.py:文件操作模块。
- kubectl.py:Kubectl 命令执行模块。
项目结构
.
├── README.md # 项目概述
├── docs/ # 文档
│ ├── agentic/ # AI 代理文档
│ ├── components/ # 组件设计文档
│ └── examples/ # 示例提示和使用案例
└── src/ # 源代码
└── mcp_server_troubleshoot/
├── __init__.py
├── __main__.py # 入口点
├── bundle.py # 捆绑包管理
├── cli.py # CLI 接口
├── config.py # 配置管理
├── files.py # 文件操作
├── kubectl.py # Kubectl 命令执行
└── server.py # MCP 服务器实现
代码风格
# 使用 Black 格式化代码
black .
# 使用 Ruff 检查代码规范
ruff check .
测试
# 运行所有测试
pytest
# 运行带有详细输出的测试
pytest -v
# 运行特定类型的测试
pytest -m unit
pytest -m integration
pytest -m e2e
# 以详细警告模式运行测试
pytest -W all
# 将警告视为错误运行测试
pytest -W error
需求
| 属性 | 详情 |
|------|------|
| 运行环境 | Python 3.13 |
| 命令行工具 | kubectl 命令行工具,sbctl 命令行工具用于捆绑包管理 |
| 认证令牌 | 环境变量:SBCTL_TOKEN 或 REPLICATED |
所有依赖项均已包含在 Podman 容器中,这是推荐的部署方法。
📄 许可证
本项目 licensed under Apache License 2.0 - 详见LICENSE文件。
💡 使用建议
欢迎贡献代码!请参考开发者指南了解如何贡献。
Scan to join WeChat group