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
| Name | Required | Description | Default |
|---|---|---|---|
| projectKey | Yes | The Jira project key (e.g., "PROJ") | |
| summary | Yes | The test case summary/title | |
| description | No | The test case description | |
| testType | No | The type of test case | Manual |
| labels | No | Labels to attach to the test case | |
| priority | No | Priority of the test case (e.g., "High", "Medium", "Low") |
Implementation Reference
- src/xray-client.ts:218-273 (handler)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'], }, },
- 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/xray-client.ts:27-31 (schema)TypeScript interface defining the TestCaseResponse output structure returned by the handler.export interface TestCaseResponse { id: string; key: string; self: string; }
- src/index.ts:533-552 (helper)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), }, ], }; }