list-modules
List qTest Test Design modules. Use query to search by name, parentId to see children, or omit both for root-level modules.
Instructions
Test Design — list qTest Test Design modules. Pass query to search by name, parentId to list children, or neither for root-level listing
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | ||
| parentId | No | List children of this module ID | |
| query | No | Search modules by name |
Implementation Reference
- src/server.ts:44-59 (registration)Registration of the 'list-modules' tool on the MCP server, defining its input schema (projectId, parentId, query) and wire-up to the listModules handler.
server.registerTool( 'list-modules', { description: 'Test Design — list qTest Test Design modules. Pass query to search by name, parentId to list children, or neither for root-level listing', inputSchema: { projectId: z.string(), parentId: z.number().int().optional().describe('List children of this module ID'), query: z.string().optional().describe('Search modules by name'), }, }, async ({ projectId, parentId, query }) => { const result = await listModules({ projectId, parentId, query }) return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] } } ) - Handler function 'listModules' that constructs the qTest API endpoint based on optional parentId/query parameters and fetches module data.
export async function listModules(args: ListModulesArgs): Promise<QTestFolder[]> { const { projectId, parentId, query } = args let endpoint: string if (query !== undefined) { endpoint = `/modules?search=${encodeURIComponent(query)}&size=50` } else if (parentId !== undefined) { endpoint = `/modules?parentId=${parentId}&size=100` } else { endpoint = `/modules?size=100` } const raw = await qtestFetch(config, projectId, endpoint, 'GET') return extractArray<QTestFolder>(raw) } - TypeScript interface 'ListModulesArgs' defining the input shape for the list-modules handler.
export interface ListModulesArgs { projectId: string parentId?: number query?: string } - src/types.ts:10-17 (helper)Type definitions: QTestModule (with id, name, pid, parentId) and alias type QTestFolder used as the return type for listModules.
export interface QTestModule { id: number name: string pid?: string parentId?: number } export type QTestFolder = QTestModule - src/client.ts:58-67 (helper)Utility function 'extractArray' used to normalize the API response into an array (handles items/data/object wrapping).
export function extractArray<T>(raw: unknown): T[] { if (Array.isArray(raw)) return raw as T[] if (raw && typeof raw === 'object') { for (const key of ['items', 'data', 'object'] as const) { const val = (raw as Record<string, unknown>)[key] if (Array.isArray(val)) return val as T[] } } return [] }