Skip to main content
Glama

create_test_case

Create new test cases in Xray Cloud for manual, Cucumber, or generic testing with project keys, summaries, descriptions, and labels.

Instructions

Create a new test case in Xray Cloud

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectKeyYesThe Jira project key (e.g., "PROJ")
summaryYesThe test case summary/title
descriptionNoThe test case description
testTypeNoThe type of test caseManual
labelsNoLabels to attach to the test case
priorityNoPriority of the test case (e.g., "High", "Medium", "Low")

Implementation Reference

  • Core handler function implementing the create_test_case tool logic by executing GraphQL mutation to create a test case in Xray Cloud.
    async createTestCase(testCase: TestCase): Promise<TestCaseResponse> {
      const mutation = `
        mutation CreateTest($jira: JSON!, $testType: UpdateTestTypeInput, $unstructured: String) {
          createTest(jira: $jira, testType: $testType, unstructured: $unstructured) {
            test {
              issueId
              jira(fields: ["key"])
            }
            warnings
          }
        }
      `;
    
      const jiraFields: any = {
        fields: {
          project: {
            key: testCase.projectKey
          },
          summary: testCase.summary,
          issuetype: {
            name: 'Test'
          }
        }
      };
    
      if (testCase.description) {
        jiraFields.fields.description = testCase.description;
      }
    
      if (testCase.labels && testCase.labels.length > 0) {
        jiraFields.fields.labels = testCase.labels;
      }
    
      if (testCase.priority) {
        jiraFields.fields.priority = { name: testCase.priority };
      }
    
      const variables: any = {
        jira: jiraFields,
        unstructured: testCase.description || ''
      };
    
      if (testCase.testType) {
        variables.testType = {
          name: testCase.testType
        };
      }
    
      const result = await this.graphqlRequest<{ createTest: any }>(mutation, variables);
    
      return {
        id: result.createTest.test.issueId,
        key: result.createTest.test.jira.key,
        self: `https://your-jira-instance.atlassian.net/browse/${result.createTest.test.jira.key}`
      };
    }
  • src/index.ts:29-65 (registration)
    MCP tool registration defining the 'create_test_case' tool with name, description, and input schema.
    {
      name: 'create_test_case',
      description: 'Create a new test case in Xray Cloud',
      inputSchema: {
        type: 'object',
        properties: {
          projectKey: {
            type: 'string',
            description: 'The Jira project key (e.g., "PROJ")',
          },
          summary: {
            type: 'string',
            description: 'The test case summary/title',
          },
          description: {
            type: 'string',
            description: 'The test case description',
          },
          testType: {
            type: 'string',
            enum: ['Manual', 'Cucumber', 'Generic'],
            description: 'The type of test case',
            default: 'Manual',
          },
          labels: {
            type: 'array',
            items: { type: 'string' },
            description: 'Labels to attach to the test case',
          },
          priority: {
            type: 'string',
            description: 'Priority of the test case (e.g., "High", "Medium", "Low")',
          },
        },
        required: ['projectKey', 'summary'],
      },
    },
  • TypeScript interface defining the TestCase input structure used by the handler.
    export interface TestCase {
      id?: string;
      key?: string;
      summary: string;
      description?: string;
      testType?: 'Manual' | 'Cucumber' | 'Generic';
      projectKey: string;
      labels?: string[];
      components?: string[];
      priority?: string;
      status?: string;
    }
  • TypeScript interface defining the TestCaseResponse output structure returned by the handler.
    export interface TestCaseResponse {
      id: string;
      key: string;
      self: string;
    }
  • Dispatch helper in MCP server that constructs TestCase from tool arguments and calls the handler.
    case 'create_test_case': {
      const testCase: TestCase = {
        projectKey: args.projectKey as string,
        summary: args.summary as string,
        description: args.description as string | undefined,
        testType: args.testType as 'Manual' | 'Cucumber' | 'Generic' | undefined,
        labels: args.labels as string[] | undefined,
        priority: args.priority as string | undefined,
      };
    
      const result = await xrayClient.createTestCase(testCase);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }

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/c4m3lblue-star/xray-mcp'

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