Hercules MCP服务器
模型上下文协议(MCP)服务器和VS代码扩展,提供与Hercules测试自动化框架的无缝集成。该项目使开发人员能够直接从VS代码编写、触发和查看Hercules的测试用例。
🚀 特性
MCP服务器
- 创建测试用例:使用Gherkin内容注册新的Hercules测试用例
- 运行测试:通过AI驱动的自动化触发Hercules测试执行
- 查看结果:访问结构化结果,包括日志、屏幕截图和报告
- 资源管理:将测试用例作为MCP资源进行浏览和管理
📁 项目结构
├── hercules mcp服务器/#mcp服务器实现 │ ├── src/ │ │ ├── types.ts#TypeScript类型定义 │ │ ├── hercules-client.ts#hercules集成客户端 │ │ ├── mcp-server.ts#mcp服务器实现 │ │ └── index.ts#服务器入口点 │ ├── package.json#服务器依赖关系 │ └── tsconfig.json#TypeScript配置
🛠️ 安装和设置
先决条件
- Node.js (v18或更高版本)
- python (v3.8或更高版本)
- 赫拉克勒斯框架 (安装在
../../testzeus-hercules)
设置MCP服务器
- 导航到MCP服务器目录:
git clone git@github.com:akshay619-dev/hercules-mcp-server.git
cd hercules-mcp-server- 安装依赖项:
npm install- 构建服务器:
npm run build- 启动服务器:
npm run start:http🧪 测试和📬 API使用和邮差集合
Postman集合可帮助您探索和测试Hercules MCP服务器的所有可用API端点。
导入收藏
- 打开邮递员。
- 点击 导入 并选择
hercules-mcp-server.postman_collection.json从项目根开始。 - 将基本URL设置为
http://localhost:3000(或您配置的端口)。
可用端点
GET /health--健康检查GET /tools--列出可用工具POST /tools/create_test_case--创建新的测试用例POST /tools/run_test_case--运行测试用例GET /tools/list_test_cases--列出所有测试用例GET /tools/get_test_case/:testCaseId--获取测试用例的详细信息GET /tools/get_execution_results/:testCaseId--获取执行结果GET /resources--列出资源GET /resources/read?uri=hercules://test-case/--读取资源内容GET /results/:testCaseId/:filename--下载结果文件(如报告)
示例:创建测试用例
POST /tools/create_test_case
Content-Type: application/json
{
"name": "Sample Test Case",
"gherkinContent": "Feature: Example\n Scenario: Test\n Given something\n When something happens\n Then expect something",
"testDataPath": "optional/path/to/data.json",
"llmModel": "gpt-4o",
"llmApiKey": "your-api-key"
}示例:运行测试用例
POST /tools/run_test_case
Content-Type: application/json
{
"testCaseId": "",
"llmModel": "gpt-4o",
"llmApiKey": "your-api-key"
}示例:获取测试用例详细信息
GET /tools/get_test_case/有关更多信息,请参阅工作区中导入的Postman收藏
🔍 故障排除
常见问题
- MCP服务器连接失败
- 确保Hercules框架已安装且可访问 - 检查服务器路径是否正确 - 验证Python环境和依赖关系
🤝 贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 如果适用,添加测试
- 提交拉取请求
📄 许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
