search_test_cases
Find test cases in Xray using JQL queries to filter by project, labels, or other criteria for test management and automation workflows.
Instructions
Search for test cases using JQL (Jira Query Language)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jql | Yes | JQL query to search test cases (e.g., "project = PROJ AND labels = automation") | |
| maxResults | No | Maximum number of results to return |
Implementation Reference
- src/xray-client.ts:365-392 (handler)Core implementation of searchTestCases: executes GraphQL query to fetch test cases matching the JQL query.async searchTestCases(jql: string, maxResults: number = 50): Promise<any> { const query = ` query SearchTests($jql: String!, $limit: Int!) { getTests(jql: $jql, limit: $limit) { total start limit results { issueId projectId jira(fields: ["key", "summary", "description", "priority", "status", "labels"]) testType { name kind } } } } `; const variables = { jql, limit: maxResults }; const result = await this.graphqlRequest<{ getTests: any }>(query, variables); return result.getTests; }
- src/index.ts:125-143 (schema)Tool schema definition including name, description, and input schema for validation.{ name: 'search_test_cases', description: 'Search for test cases using JQL (Jira Query Language)', inputSchema: { type: 'object', properties: { jql: { type: 'string', description: 'JQL query to search test cases (e.g., "project = PROJ AND labels = automation")', }, maxResults: { type: 'number', description: 'Maximum number of results to return', default: 50, }, }, required: ['jql'], }, },
- src/index.ts:596-609 (handler)MCP server tool execution handler: dispatches to xrayClient and returns JSON response.case 'search_test_cases': { const result = await xrayClient.searchTestCases( args.jql as string, args.maxResults as number | undefined ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/index.ts:519-521 (registration)Registration of tool list handler that exposes the tools array including search_test_cases.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });