create_test_case
Create new test cases in Xray Cloud with project key, summary, description, test type, labels, and priority to manage testing workflows.
Instructions
Create a new test case in Xray Cloud
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | The test case description | |
| labels | No | Labels to attach to the test case | |
| priority | No | Priority of the test case (e.g., "High", "Medium", "Low") | |
| projectKey | Yes | The Jira project key (e.g., "PROJ") | |
| summary | Yes | The test case summary/title | |
| testType | No | The type of test case | Manual |
Implementation Reference
- src/xray-client.ts:218-273 (handler)Core implementation of createTestCase tool: executes GraphQL mutation to create test 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/xray-client.ts:14-25 (schema)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; }
- src/index.ts:32-64 (schema)MCP tool input schema for create_test_case validation.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'], },
- src/index.ts:29-65 (registration)Tool registration in the tools array returned by listTools.{ 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'], }, },
- src/index.ts:533-552 (handler)MCP callTool dispatcher case that invokes the Xray client 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), }, ], }; }