list_test_cases
Retrieve test cases from Zephyr Scale Cloud with filtering options for projects, folders, and pagination to manage testing workflows.
Instructions
List test cases with optional filtering by project and folder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectKey | No | Jira project key to filter test cases | |
| folderId | No | Folder ID to filter test cases | |
| maxResults | No | Maximum number of results to return (default: 50, max: 1000) | |
| startAt | No | Starting position for pagination (default: 0) |
Implementation Reference
- src/tools/test-case-tools.js:14-59 (handler)The handler function that executes the list_test_cases tool. It validates input parameters, fetches test cases from ZephyrClient, formats the JSON response, and handles errors appropriately.async function listTestCases(args) { try { const params = { projectKey: args.projectKey, folderId: args.folderId, maxResults: args.maxResults || config.defaultMaxResults, startAt: args.startAt || 0 }; // Validate projectKey if provided if (params.projectKey && !config.projectKeyPattern.test(params.projectKey)) { throw new Error('Invalid projectKey format. Must match pattern: [A-Z][A-Z_0-9]+'); } // Validate folderId if provided if (params.folderId && (!Number.isInteger(params.folderId) || params.folderId < 1)) { throw new Error('Invalid folderId format. Must be a positive integer.'); } const response = await client.getTestCases(params); return { content: [ { type: 'text', text: JSON.stringify({ testCases: response.values || response, total: response.total || response.length, startAt: response.startAt || 0, maxResults: response.maxResults || params.maxResults }, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text', text: formatError(error, 'fetching test cases') } ], isError: true }; } }
- src/tools/test-case-tools.js:262-289 (schema)The inputSchema defining the expected parameters for the list_test_cases tool, including types, descriptions, patterns, defaults, and constraints.inputSchema: { type: 'object', properties: { projectKey: { type: 'string', description: 'Jira project key to filter test cases', pattern: config.projectKeyPattern.source }, folderId: { type: 'integer', description: 'Folder ID to filter test cases', minimum: 1 }, maxResults: { type: 'number', description: 'Maximum number of results to return (default: 50, max: 1000)', minimum: 1, maximum: config.maxMaxResults, default: config.defaultMaxResults }, startAt: { type: 'number', description: 'Starting position for pagination (default: 0)', minimum: 0, default: 0 } } },
- src/tools/test-case-tools.js:259-291 (registration)Local registration of the tool within the testCaseTools array exported from this module.{ name: 'list_test_cases', description: 'List test cases with optional filtering by project and folder', inputSchema: { type: 'object', properties: { projectKey: { type: 'string', description: 'Jira project key to filter test cases', pattern: config.projectKeyPattern.source }, folderId: { type: 'integer', description: 'Folder ID to filter test cases', minimum: 1 }, maxResults: { type: 'number', description: 'Maximum number of results to return (default: 50, max: 1000)', minimum: 1, maximum: config.maxMaxResults, default: config.defaultMaxResults }, startAt: { type: 'number', description: 'Starting position for pagination (default: 0)', minimum: 0, default: 0 } } }, handler: listTestCases },
- src/index.js:30-37 (registration)Global registration by including testCaseTools in the allTools array, which is used for MCP tool listing and dynamic dispatch.const allTools = [ ...projectTools, ...folderTools, ...testCaseTools, ...testStepsTools, ...testScriptTools, ...referenceDataTools ];