Skip to main content
Glama
Atakan-Emre

QA-MCP: Test Standardization & Orchestration Server

by Atakan-Emre

testcase.to_xray

Convert test cases to Xray import format for Jira integration, supporting manual, automated, or generic test types with customizable field mappings.

Instructions

Standart test case'i Xray import formatına dönüştürür

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
testcaseYesDönüştürülecek test case
project_keyYesJira proje anahtarı (örn: PROJ)
test_typeNoXray test tipi (default: Manual)
include_custom_fieldsNoCustom field'ları dahil et (default: true)
custom_field_mappingsNoCustom field ID eşlemeleri

Implementation Reference

  • The primary handler function that performs the conversion from QA-MCP testcase format to Xray import JSON, handling field mappings, steps, custom fields, priority, labels, and generating reports/warnings.
    def convert_to_xray(
        testcase: dict,
        project_key: str,
        test_type: str = "Manual",
        include_custom_fields: bool = True,
        custom_field_mappings: dict[str, str] | None = None,
    ) -> dict:
        """
        Convert a QA-MCP test case to Xray import format.
    
        Args:
            testcase: Test case in QA-MCP standard format
            project_key: Jira project key (e.g., 'PROJ')
            test_type: Xray test type - 'Manual', 'Automated', 'Generic'
            include_custom_fields: Whether to include custom field mappings
            custom_field_mappings: Custom field ID mappings (e.g., {'risk_level': 'customfield_10001'})
    
        Returns:
            Dictionary containing:
            - xray_payload: Ready-to-import Xray JSON
            - field_mapping_report: Which fields were mapped
            - warnings: Any conversion warnings
        """
        warnings = []
        field_mapping_report = {
            "mapped_fields": [],
            "unmapped_fields": [],
            "custom_fields_used": [],
        }
    
        # Parse test case
        try:
            tc = TestCase(**testcase)
        except Exception as e:
            return {
                "xray_payload": None,
                "field_mapping_report": field_mapping_report,
                "warnings": [f"Test case parse hatası: {str(e)}"],
                "error": str(e),
            }
    
        # Build Xray payload
        xray_payload = {
            "testtype": XRAY_TEST_TYPE_MAP.get(test_type, "Manual"),
            "fields": {
                "project": {"key": project_key},
                "summary": tc.title,
                "description": _build_xray_description(tc),
                "issuetype": {"name": "Test"},
            },
        }
        field_mapping_report["mapped_fields"].extend(["title", "description"])
    
        # Priority mapping
        if tc.priority:
            xray_payload["fields"]["priority"] = {"name": XRAY_PRIORITY_MAP.get(tc.priority, "Medium")}
            field_mapping_report["mapped_fields"].append("priority")
    
        # Labels
        labels = list(tc.labels) + list(tc.tags)
        if labels:
            xray_payload["fields"]["labels"] = labels
            field_mapping_report["mapped_fields"].append("labels")
    
        # Components (from module)
        if tc.module:
            xray_payload["fields"]["components"] = [{"name": tc.module}]
            field_mapping_report["mapped_fields"].append("module->components")
    
        # Test steps (Xray specific format)
        xray_steps = _build_xray_steps(tc)
        if xray_steps:
            xray_payload["steps"] = xray_steps
            field_mapping_report["mapped_fields"].append("steps")
    
        # Preconditions
        if tc.preconditions:
            xray_payload["preconditions"] = "\n".join(f"• {p}" for p in tc.preconditions)
            field_mapping_report["mapped_fields"].append("preconditions")
    
        # Custom fields
        if include_custom_fields:
            custom_fields = _build_custom_fields(tc, custom_field_mappings)
            if custom_fields:
                xray_payload["fields"].update(custom_fields)
                field_mapping_report["custom_fields_used"] = list(custom_fields.keys())
    
        # Track unmapped fields
        all_tc_fields = set(TestCase.model_fields.keys())
        mapped_base_fields = {
            "title",
            "description",
            "priority",
            "labels",
            "tags",
            "module",
            "steps",
            "preconditions",
        }
        unmapped = all_tc_fields - mapped_base_fields - {"id", "created_at", "updated_at", "author"}
    
        for field in unmapped:
            value = getattr(tc, field, None)
            if value and (not isinstance(value, list) or value):
                field_mapping_report["unmapped_fields"].append(field)
                warnings.append(
                    f"'{field}' alanı Xray'e map edilemedi - custom field ekleyin veya description'a dahil edildi"
                )
    
        return {
            "xray_payload": xray_payload,
            "field_mapping_report": field_mapping_report,
            "warnings": warnings,
        }
  • MCP tool registration defining the 'testcase.to_xray' tool name, description, and input schema.
    Tool(
        name="testcase.to_xray",
        description="Standart test case'i Xray import formatına dönüştürür",
        inputSchema={
            "type": "object",
            "properties": {
                "testcase": {
                    "type": "object",
                    "description": "Dönüştürülecek test case",
                },
                "project_key": {
                    "type": "string",
                    "description": "Jira proje anahtarı (örn: PROJ)",
                },
                "test_type": {
                    "type": "string",
                    "enum": ["Manual", "Automated", "Generic"],
                    "description": "Xray test tipi (default: Manual)",
                },
                "include_custom_fields": {
                    "type": "boolean",
                    "description": "Custom field'ları dahil et (default: true)",
                },
                "custom_field_mappings": {
                    "type": "object",
                    "description": "Custom field ID eşlemeleri",
                },
            },
            "required": ["testcase", "project_key"],
        },
    ),
  • Server-side tool dispatch handler that extracts arguments and invokes the convert_to_xray implementation.
    elif name == "testcase.to_xray":
        result = convert_to_xray(
            testcase=arguments["testcase"],
            project_key=arguments["project_key"],
            test_type=arguments.get("test_type", "Manual"),
            include_custom_fields=arguments.get("include_custom_fields", True),
            custom_field_mappings=arguments.get("custom_field_mappings"),
        )
        audit_log(name, arguments, f"Converted to Xray for {arguments['project_key']}")
  • Constant mappings for priority and test type conversion between QA-MCP and Xray formats.
    XRAY_PRIORITY_MAP = {
        Priority.P0: "Highest",
        Priority.P1: "High",
        Priority.P2: "Medium",
        Priority.P3: "Low",
    }
    
    XRAY_TEST_TYPE_MAP = {
        "Manual": "Manual",
        "Automated": "Generic",
        "Generic": "Generic",
    }
    
    
    def convert_to_xray(
        testcase: dict,
        project_key: str,
        test_type: str = "Manual",
        include_custom_fields: bool = True,
        custom_field_mappings: dict[str, str] | None = None,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It only states what the tool does (conversion) without mentioning any behavioral traits like whether it's read-only vs. mutating, whether it requires authentication, rate limits, error handling, or what the output looks like. For a tool with 5 parameters and no annotations, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single sentence that directly states the tool's purpose without any fluff. It's front-loaded with the core function and wastes no words, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 5 parameters, no annotations, and no output schema, the description is incomplete. It doesn't address what the conversion output looks like, error conditions, authentication requirements, or how it differs from the batch version. For a data transformation tool with multiple configuration options, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly with descriptions and defaults. The description adds no additional parameter information beyond what's in the schema, maintaining the baseline score of 3. It doesn't explain relationships between parameters or provide usage examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: converting a test case to Xray import format. It specifies the verb ('dönüştürür' - converts) and the resource ('test case'), making the function understandable. However, it doesn't differentiate from its sibling 'testcase.to_xray_batch', which likely performs batch conversion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention the sibling 'testcase.to_xray_batch' for batch processing or other tools like 'testcase.normalize' that might be prerequisites. There's no context about when this conversion is needed or what scenarios it's designed for.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Atakan-Emre/McpTestGenerator'

If you have feedback or need assistance with the MCP directory API, please join our Discord server