高命令:高命令API MCP服务器
用于与High-Command API无缝集成的模型上下文协议(MCP)服务器。该项目提供工具和资源,通过一个全面的、专用的游戏数据API访问《地狱潜水员2》的实时游戏数据。
特性
- 🔌 MCP服务器:使用HTTP和Stdio传输实现完整的模型上下文协议
- 🎮 高通用API:直接访问游戏数据(战争状态、战役、行星、生物群落、派系、统计数据)
- 📦 异步/等待:使用现代异步Python和httpx构建
- 🐳 Docker支持:通过多阶段构建实现简单的容器化
- 🧪 综合测试:17次测试,50%覆盖率
- 📚 文档:完整的API和使用文档
- 🔄 CI/CD:用于测试和Docker构建的GitHub Actions工作流
- ⚙️ 可配置的:API终结点和日志记录的基于环境的配置
快速开始
先决条件
- Python 3.14.0+
- pip或uv
- Docker(可选)
安装
# Clone the repository
git clone https://github.com/yourusername/high-command.git
cd high-command
# Install dependencies
make install
# Install development dependencies
make dev运行服务器
# Run with make
make run
# Or with Docker
make docker-run
# Or directly
python -m highcommand.server运行测试
# Run all tests with coverage
make test
# Run tests quickly without coverage
make test-fast
# Run specific test file
pytest tests/test_api_client.py -v代码质量
# Format code
make format
# Run linters
make lint
# Run all checks
make check� Docker和Kubernetes支持
码头工人
# Build image
make docker-build
# Run container
make docker-run
# Or manually
docker build -t high-command:latest .
docker run -p 8000:8000 high-command:latestKubernetes
High Command支持Kubernetes部署的HTTP/SSE传输:
# Install with Kubernetes support
pip install high-command[kubernetes]
# Deploy to cluster
kubectl apply -f k8s/rbac.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl apply -f k8s/hpa.yaml
# Check status
kubectl get pods -l app=high-command
kubectl port-forward svc/high-command 8000:80备注:Kubernetes部署清单可在 k8s/ 目录。根据您的集群设置配置它们。
�💻 VS代码集成
High Command MCP服务器与VS Code和GitHub Copilot无缝集成。
设置
- 安装依赖项:
make dev- 添加到VS代码MCP配置 (
~/.config/Code/User/mcp.json):
{
"servers": {
"high-command": {
"type": "stdio",
"command": "/full/path/to/python",
"args": ["-m", "highcommand.server"],
"cwd": "/path/to/high-command-mcp"
}
}
}- 重新加载VS代码 并开始使用Copilot的工具
示例用法
/ask Get the current war status from Helldivers 2
/ask List all available planets
/ask Show me the game statistics配置:上述设置使MCP服务器能够与VS Code的Copilot集成一起工作。根据环境需要调整路径。
API工具
MCP服务器公开了以下工具:
get_war_status
从高通用API获取当前战争状态。
参数:无
退货:战争信息,包括战争ID、开始/结束时间。
get_planets
获取行星信息。
参数:无
退货:包含名称、扇区、生物群落和位置的行星列表。
get_statistics
获取全球游戏统计数据。
参数:无
退货:汇总统计数据,包括获胜/失败的任务、击杀、准确性等。
get_campaign_info
获取活动信息。
参数:无
退货:包含行星任务和类型的战役列表。
get_planet_status
获取特定行星的状态。
参数:
planet_index(整数,必填):行星的索引
退货:指定行星的详细状态信息。
项目结构
high-command/
├── mcp/ # Main MCP server package
│ ├── __init__.py
│ ├── server.py # MCP server implementation
│ ├── api_client.py # Helldivers 2 API client
│ ├── models.py # Pydantic data models
│ └── tools.py # MCP tool definitions
├── tests/ # Test suite
│ ├── test_api_client.py
│ └── test_models.py
├── docs/ # Documentation
├── Makefile # Build and development tasks
├── Dockerfile # Docker container definition
├── docker-compose.yml # Docker Compose configuration
└── pyproject.toml # Python project configuration码头工人
塑造形象
make docker-build运行容器
docker run -it --rm high-command:latest使用Docker Compose
docker-compose up环境变量
LOG_LEVEL:日志记录级别(默认值:INFO)
发展
建立发展环境
# Install development dependencies
make dev
# Run formatter
make format
# Run linters
make lint
# Run tests
make test贡献
看 贡献.md 作为指导方针。
API速率限制
高级命令MCP客户端 检测 速率限制响应,但确实如此 不实现自动重试逻辑:
- ✅ 检测429个错误 -当API返回“请求太多”时记录速率限制警告
- ✅ 透明的错误处理 -向调用应用程序传播速率限制错误
- ⚠️ 无自动重试 -应用程序必须实现自己的指数退避策略
- ✅ 示例实现 -请参阅 docs/neneneba API.md#速率限制 用于退避模式
生产最佳实践:
- 在应用层中实现指数退避(API文档中的示例)
- 尽可能在本地缓存结果,以最大限度地减少API调用
- 避免提出不必要或重复的请求
- 监控日志以查看重复的速率限制警告(
logger.warning("Rate limit exceeded")) - 考虑在应用程序级别进行请求批处理和限制
为什么没有自动重试? MCP客户端遵循透明的错误模型,让应用程序完全控制重试逻辑和超时行为,而不是在自动重试后隐藏延迟。
看 docs/neneneba API.md#速率限制 获取详细信息和代码示例。
故障排除
API返回Bot检测HTML
地狱潜水员2 API具有Cloudflare机器人程序保护。确保您包含了所需的标题:
X-Super-ClientX-Super-Contact
连接超时
增加中的超时值 HighCommandAPIClient:
client = HighCommandAPIClient(timeout=60.0) # 60 seconds许可证
此项目根据Apache许可证2.0版获得许可——请参阅 许可证 文件以获取详细信息。
版权所有2026 DataKnifeAI
致谢
支持
对于问题和疑问:
- 📝
- 💬
______________________________________________________________________
发展
该项目是使用 Claude Haiku 4.5版GitHub副本,展示了人工智能辅助软件开发创建生产就绪MCP服务器的能力。
______________________________________________________________________
制作❤️ 《地狱潜水员2》社区
