get_test_plan
Retrieve a test plan by its key or internal ID. Returns the test plan's ID, key, project ID, and archived status. Use the internal ID for linking, unlinking, or getting linked test cycles.
Instructions
Get a test plan by its key (e.g. FS-TP-43) or internal id. Returns id, key, projectId, archived flag. Use the internal 'id' when calling link/unlink/get_linked_test_cycles.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Test plan ID or key |
Implementation Reference
- src/index.ts:523-528 (handler)Handler function for get_test_plan tool. Accepts an id (string or number) and fetches the test plan from the QMetry API via a GET request to /testplans/:id. Returns the API response wrapped in MCP content format.
tool( "get_test_plan", "Get a test plan by its key (e.g. FS-TP-43) or internal id. Returns id, key, projectId, archived flag. Use the internal 'id' when calling link/unlink/get_linked_test_cycles.", { id: ID.describe("Test plan ID or key") }, async ({ id }) => ok(await qtmFetch(`/testplans/${id}`)) ); - src/index.ts:165-165 (schema)The input schema for get_test_plan consists of a single parameter 'id' typed as ID, which is a Zod union of string and number.
const ID = z.union([z.string(), z.number()]); - src/index.ts:171-184 (registration)The tool registration helper. 'get_test_plan' is registered via the 'tool()' wrapper which calls server.registerTool with the tool name, description, input schema, and callback handler.
/** Thin wrapper around registerTool for concise, non-deprecated tool registration. */ 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:66-68 (helper)The 'ok' helper wraps the API response data into the MCP content format (array of text content blocks) used by the handler.
} /** Wrap a successful API response as MCP tool content. */ - src/index.ts:25-66 (helper)The qtmFetch HTTP helper used by the handler to make the GET request to /testplans/:id with API key authentication and rate-limit retry logic.
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; }