delete_test_case
Permanently delete a specific version of a test case. If it is the only version, the test case is removed entirely. Returns success when complete.
Instructions
Permanently delete a specific version of a test case. If it is the only version, the test case is removed entirely. Returns 204 on success.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Test case ID | |
| versionNo | Yes | Version number to delete |
Implementation Reference
- src/index.ts:268-279 (handler)The 'delete_test_case' tool handler: calls qtmFetch with DELETE method on /testcases/{id}/versions/{versionNo} to permanently delete a specific test case version. If it is the only version, the test case is removed entirely. Returns 204 on success.
tool( "delete_test_case", "Permanently delete a specific version of a test case. If it is the only version, the test case is removed entirely. Returns 204 on success.", { id: ID.describe("Test case ID"), versionNo: z.number().int().describe("Version number to delete"), }, async ({ id, versionNo }) => { await qtmFetch(`/testcases/${id}/versions/${versionNo}`, { method: "DELETE" }); return ok({ message: `Test case ${id} version ${versionNo} deleted` }); } ); - src/index.ts:271-274 (schema)Input schema for delete_test_case: accepts id (string or number via ID union type) and versionNo (integer).
{ id: ID.describe("Test case ID"), versionNo: z.number().int().describe("Version number to delete"), }, - src/index.ts:172-184 (registration)The 'tool' helper function wraps server.registerTool to register each tool with name, description, schema, and callback. 'delete_test_case' is registered via this wrapper at lines 268-279.
const tool = <Shape extends z.ZodRawShape>( name: string, description: string, inputSchema: Shape, // eslint-disable-next-line @typescript-eslint/no-explicit-any callback: (args: z.infer<z.ZodObject<Shape>>) => Promise<any> ) => server.registerTool( name, { description, inputSchema }, // eslint-disable-next-line @typescript-eslint/no-explicit-any callback as any ); - src/index.ts:68-73 (helper)The 'ok' helper function wraps successful API responses into MCP tool content format, used by the delete_test_case handler.
/** Wrap a successful API response as MCP tool content. */ function ok(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } - src/index.ts:25-66 (helper)The 'qtmFetch' HTTP helper used by delete_test_case to make the DELETE request to the QMetry API.
async function qtmFetch( path: string, options: RequestInit = {}, attempt = 1 ): Promise<unknown> { const url = `${BASE_URL}${path}`; const headers: Record<string, string> = { apiKey: API_KEY ?? "", "Content-Type": "application/json", Accept: "application/json", ...(options.headers as Record<string, string> | undefined), }; const response = await fetch(url, { ...options, headers }); // Exponential back-off for rate limiting (max 3 attempts) if (response.status === 429 && attempt < 3) { const retryAfter = Number.parseInt( response.headers.get("Retry-After") ?? "1", 10 ); const delay = Math.max(retryAfter * 1000, 1000) * attempt; await new Promise((r) => setTimeout(r, delay)); return qtmFetch(path, options, attempt + 1); } const text = await response.text(); let body: unknown; try { body = text ? JSON.parse(text) : null; } catch { body = text; } if (!response.ok) { throw new Error( `HTTP ${response.status} ${response.statusText}: ${JSON.stringify(body)}` ); } return body; }