delete-test-cycle
Delete a test cycle by numeric ID. Automatically removes all child test cycles, test suites, and test runs.
Instructions
Test Execution — delete a qTest test cycle by numeric id. Cascades to all child test cycles, test suites, and test runs automatically.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Numeric project ID as string | |
| id | Yes | Test cycle numeric ID to delete |
Implementation Reference
- The main handler function `deleteTestCycle` that fetches the cycle info, calls `deleteRecursive` to recursively delete child suites/runs/cycles, then deletes the cycle itself.
export async function deleteTestCycle( args: DeleteTestCycleArgs ): Promise<DeleteTestCycleResult> { const { projectId, id } = args const raw = await qtestFetch(config, projectId, `/test-cycles/${id}`, 'GET') const cycleInfo = raw as QTestTestCycle await deleteRecursive(projectId, id) return { deleted: true, cycle: cycleInfo } - Recursive helper that deletes test suites (and their test runs), then child cycles, then the cycle itself.
async function deleteRecursive(projectId: string, id: number): Promise<void> { const suitesRaw = await qtestFetch( config, projectId, `/test-suites?parentId=${id}&parentType=test-cycle`, 'GET' ) const suites = extractArray<QTestTestSuite>(suitesRaw) for (const suite of suites) { const runsRaw = await qtestFetch( config, projectId, `/test-runs?parentId=${suite.id}&parentType=test-suite`, 'GET' ) const runs = extractArray<QTestTestRun>(runsRaw) for (const run of runs) { await qtestFetch(config, projectId, `/test-runs/${run.id}`, 'DELETE') } await qtestFetch(config, projectId, `/test-suites/${suite.id}`, 'DELETE') } const childrenRaw = await qtestFetch( config, projectId, `/test-cycles?parentId=${id}&parentType=test-cycle`, 'GET' ) const children = extractArray<QTestTestCycle>(childrenRaw) for (const child of children) { await deleteRecursive(projectId, child.id) } await qtestFetch(config, projectId, `/test-cycles/${id}`, 'DELETE') } - Input type definition for the delete operation (projectId and id).
export interface DeleteTestCycleArgs { projectId: string id: number } - Return type definition for the delete operation.
export interface DeleteTestCycleResult { deleted: true cycle: QTestTestCycle } - src/server.ts:153-167 (registration)Registration of the 'delete-test-cycle' tool on the MCP server, with Zod input schema and handler that calls deleteTestCycle.
server.registerTool( 'delete-test-cycle', { description: 'Test Execution — delete a qTest test cycle by numeric id. Cascades to all child test cycles, test suites, and test runs automatically.', inputSchema: { projectId: z.string().describe('Numeric project ID as string'), id: z.number().int().describe('Test cycle numeric ID to delete'), }, }, async ({ projectId, id }) => { const result = await deleteTestCycle({ projectId, id }) return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] } } )