模型上下文协议(MCP)服务器用于将Xray Cloud API与Claude Code和其他MCP客户端集成。
此MCP服务器提供了使用官方GraphQL API管理Xray Cloud中的测试用例和测试执行的工具:
createTest)getTests)deleteTest)该项目包括全面的测试覆盖:
# 运行单元测试
npm run test:unit
# 运行集成测试(需要凭证)
npm run test:integration
# 运行所有测试
npm test
有关详细的测试文档,请参阅TESTING.md
npm install
npm run build
要将此MCP服务器与Claude Code一起使用,请在您的MCP配置文件(通常在macOS上的~/Library/Application Support/Claude/claude_desktop_config.json)中添加以下配置:
{
"mcpServers": {
"xray": {
"command": "node",
"args": ["/path/to/xray-mcp/dist/index.js"],
"env": {
"XRAY_CLIENT_ID": "your_client_id",
"XRAY_CLIENT_SECRET": "your_client_secret"
}
}
}
}
重要提示: 替换:
/path/to/xray-mcp 为项目的绝对路径(例如,/Users/manuel/repositories/xray-mcp)your_client_id 和 xray_client_secret 为您自己的Xray Cloud凭证要在开发模式下测试服务器:
# 设置环境变量
export XRAY_CLIENT_ID="your_client_id"
export XRAY_CLIENT_SECRET="your_client_secret"
# 运行服务器
npm run dev
{
"projectKey": "ABC",
"summary": "验证登录功能",
"description": "测试用户能否使用有效凭据登录",
"testType": "手动",
"labels": ["登录", "身份验证"],
"priority": "高"
}
{
"jql": "项目 = ABC AND 标签 = 自动化",
"maxResults": 20
}
{
"projectKey": "ABC",
"maxResults": 50
}
{
"projectKey": "ABC",
"summary": "冲刺23回归测试",
"description": "冲刺23的回归测试",
"testIssueIds": ["10001", "10002", "10003"],
"testEnvironments": ["Chrome", "Firefox"]
}
{
"testExecutionKey": "ABC-456"
}
{
"testRunId": "5acc7ab0a3fe1b6fcdc3c737",
"status": "通过"
}
{
"jql": "项目 = ABC AND 创建时间 >= -7d",
"maxResults": 20
}
xray-mcp/
├── src/
│ ├── index.ts # 主MCP服务器
│ └── xray-client.ts # Xray Cloud API客户端
├── dist/ # 编译后的文件(构建后生成)
├── .env.example # 环境变量模板
├── .gitignore
├── package.json
├── tsconfig.json
└── README.md
此服务器使用以下Xray Cloud API:
POST /api/v1/authenticate(令牌有效期24小时)POST /api/v2/graphql
getTests - 使用JQL检索测试createTest, deleteTest - 创建/删除测试getTestExecutions - 使用JQL检索执行createTestExecution, updateTestRunStatus - 管理执行和结果getTestPlans - 使用JQL检索测试计划createTestPlan, addTestsToTestPlan, removeTestsFromTestPlan - 管理测试计划getTestSets - 使用JQL检索测试集createTestSet, addTestsToTestSet, removeTestsFromTestSet - 管理测试集完整的API文档,请访问:
使用此MCP服务器来:
使用此MCP服务器来:
ISC
对于Xray Cloud API的问题或疑问,请参考官方文档: