Xray MCP Server

Xray MCP Server

Enables AI assistants to interact with Xray Test Management for both Cloud and Server deployments. Supports test execution, importing results from multiple formats (JUnit, Cucumber, Robot Framework, TestNG), and managing test plans and executions.

Category
访问服务器

README

Xray MCP Server

A Model Context Protocol (MCP) server for integrating with Xray Test Management. This server enables AI assistants like Claude to interact with Xray, supporting test execution and importing test results from various formats.

Features

  • Dual Deployment Support: Works with both Xray Cloud and Xray Server/Data Center
  • Test Execution: Create and execute test runs directly from AI conversations
  • Multiple Import Formats: Import test results from JUnit, Cucumber, Xray JSON, Robot Framework, and TestNG
  • Query & Management: Query test executions, retrieve test information, and manage test plans
  • Type-Safe: Built with TypeScript for robust type checking and IDE support

Installation

# Clone the repository
git clone <repository-url>
cd xray-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

Configuration

Environment Variables

Copy .env.example to .env and configure based on your Xray deployment:

For Xray Cloud

XRAY_DEPLOYMENT=cloud
XRAY_CLOUD_CLIENT_ID=your_client_id
XRAY_CLOUD_CLIENT_SECRET=your_client_secret

Get your API credentials from: https://xray.cloud.getxray.app/api-keys

For Xray Server/Data Center

Using Personal Access Token (Recommended)

XRAY_DEPLOYMENT=server
XRAY_JIRA_BASE_URL=https://your-jira-instance.com
XRAY_AUTH_TYPE=token
XRAY_TOKEN=your_personal_access_token

Using Basic Authentication

XRAY_DEPLOYMENT=server
XRAY_JIRA_BASE_URL=https://your-jira-instance.com
XRAY_AUTH_TYPE=basic
XRAY_USERNAME=your_username
XRAY_PASSWORD=your_password

MCP Client Configuration

Add this server to your MCP client configuration (e.g., Claude Desktop):

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "xray": {
      "command": "node",
      "args": ["/absolute/path/to/xray-mcp-server/dist/index.js"],
      "env": {
        "XRAY_DEPLOYMENT": "cloud",
        "XRAY_CLOUD_CLIENT_ID": "your_client_id",
        "XRAY_CLOUD_CLIENT_SECRET": "your_client_secret"
      }
    }
  }
}

Or if you want to use the .env file, ensure it's in the working directory:

{
  "mcpServers": {
    "xray": {
      "command": "node",
      "args": ["/absolute/path/to/xray-mcp-server/dist/index.js"],
      "cwd": "/absolute/path/to/xray-mcp-server"
    }
  }
}

Available Tools

1. import_test_results

Import automated test execution results from various formats.

Supported Formats:

  • junit - JUnit XML format
  • cucumber - Cucumber JSON format
  • xray-json - Xray native JSON format
  • robot - Robot Framework XML format
  • testng - TestNG XML format

Example:

Import JUnit test results for project DEMO with test plan DEMO-100:
- Format: junit
- Project: DEMO
- Test Plan: DEMO-100
- Results: <xml content here>

2. execute_tests

Create and execute a test run in Xray for specified test cases.

Example:

Execute tests DEMO-1, DEMO-2, and DEMO-3 with:
- Test Plan: DEMO-100
- Environments: Chrome, Production
- Summary: Regression Test Run - Sprint 5

3. query_test_executions

Query and filter test executions in Xray.

Example:

Find all test executions in project DEMO:
- Created after: 2024-01-01
- Status: FAIL
- Limit: 20

4. get_test_info

Retrieve detailed information about a specific test case.

Example:

Get information for test case DEMO-123

5. create_test_execution

Create a new test execution container in Xray.

Example:

Create a test execution in project DEMO:
- Summary: API Regression Test - Release 2.0
- Description: Testing all API endpoints for release 2.0
- Test Plan: DEMO-100
- Environments: QA, Staging

6. update_test_execution

Update status and details of a test within an execution.

Example:

Update test DEMO-5 in execution DEMO-200:
- Status: PASS
- Comment: All assertions passed successfully

7. get_test_plans

List test plans in a project.

Example:

Get test plans for project DEMO, limit 10

8. associate_tests_to_execution

Add test cases to an existing test execution.

Example:

Associate tests DEMO-10, DEMO-11, DEMO-12 to execution DEMO-200

Usage Examples

Importing JUnit Results

<!-- example-junit.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Test Suite" tests="2" failures="1" errors="0" time="5.123">
  <testcase classname="com.example.LoginTest" name="testSuccessfulLogin" time="2.5">
  </testcase>
  <testcase classname="com.example.LoginTest" name="testInvalidPassword" time="2.623">
    <failure message="Expected error message not displayed">
      AssertionError: Expected error message not displayed
    </failure>
  </testcase>
</testsuite>

Then in your AI conversation:

Import these JUnit test results to project DEMO:
- Format: junit
- Project: DEMO
- Test Plan: DEMO-100
- Results: <paste XML content>

Executing Tests

Execute the following tests:
- DEMO-1: Login with valid credentials
- DEMO-2: Login with invalid credentials
- DEMO-3: Password reset flow

Associate with test plan DEMO-100 and run in Chrome environment

Querying Test Executions

Find all failed test executions in project DEMO from the last week

API Coverage

Feature Xray Cloud Xray Server/DC
Import JUnit
Import Cucumber
Import Xray JSON
Import Robot
Execute Tests
Query Executions ✅ (GraphQL) ✅ (JQL)
Get Test Info
Create Execution
Update Test Run
Get Test Plans
Associate Tests

Architecture

The server uses a multi-client architecture:

┌─────────────────┐
│   MCP Server    │
└────────┬────────┘
         │
         ├──────────────┐
         │              │
    ┌────▼────┐    ┌────▼────┐
    │  Cloud  │    │ Server  │
    │ Client  │    │ Client  │
    └────┬────┘    └────┬────┘
         │              │
         │              │
    Xray Cloud    Xray Server/DC
  • XrayClient Interface: Common interface for both clients
  • CloudClient: Implements Xray Cloud API v2 with GraphQL
  • ServerClient: Implements Xray Server/DC REST API v1
  • Factory Pattern: Automatically creates the correct client based on configuration

Development

Running in Development Mode

npm run dev

Building

npm run build

Project Structure

xray-mcp-server/
├── src/
│   ├── index.ts                 # Entry point
│   ├── server.ts                # MCP server setup
│   ├── config/                  # Configuration management
│   ├── xray/                    # Xray API clients
│   │   ├── client.ts            # Client interface
│   │   ├── cloud-client.ts      # Cloud implementation
│   │   ├── server-client.ts     # Server implementation
│   │   ├── factory.ts           # Client factory
│   │   └── types.ts             # Type definitions
│   ├── tools/                   # MCP tool definitions
│   └── utils/                   # Utilities
├── dist/                        # Compiled output
├── package.json
├── tsconfig.json
└── .env                         # Configuration (not in git)

Troubleshooting

Authentication Errors

Error: Authentication failed. Please check your credentials.

Solution:

  • For Cloud: Verify your Client ID and Client Secret at https://xray.cloud.getxray.app/api-keys
  • For Server: Verify your token or username/password. Ensure the user has proper permissions.

Connection Errors

Error: Network error: Unable to reach Xray API

Solution:

  • Check your XRAY_JIRA_BASE_URL is correct (for Server deployment)
  • Verify network connectivity to Xray
  • Check if a proxy or firewall is blocking the connection

Invalid Test Key Format

Error: Invalid test key format

Solution: Test keys must follow the format PROJECT-123 where PROJECT is the project key and 123 is the issue number.

Import Failures

Error: Import fails with validation errors

Solution:

  • Verify the XML/JSON format is correct for the specified format type
  • Check that the project key exists in Jira
  • Ensure test keys referenced in results exist (or use autoCreateTests: true for Cloud)

Missing Dependencies

Error: TypeScript errors or missing modules

Solution: Run npm install to ensure all dependencies are installed.

Contributing

Contributions are welcome! Please ensure:

  • Code follows the existing style
  • TypeScript types are properly defined
  • Error handling is comprehensive
  • Documentation is updated for new features

License

MIT

Resources

Support

For issues and questions:

  • Check the troubleshooting section above
  • Review Xray API documentation
  • Open an issue in the repository

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选