wait_for_test_run
Waits for a BugBug test run to complete by polling its status, then returns the full test run results. Specify the run ID and optional timeout/polling intervals to monitor automated test execution.
Instructions
Waits until test run finished, returns full test run data as result
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pollIntervalSeconds | No | Polling interval in seconds (default: 10) | |
| runId | Yes | Test run UUID to wait for | |
| timeoutMinutes | No | Maximum time to wait in minutes (default: 30) |
Implementation Reference
- src/tools/advanced.ts:18-71 (handler)The handler function polls the bugbugClient for test run status at intervals until the run finishes (via isFinishedRunStatus check), retrieves full details including screenshots, or times out. Returns appropriate content (text summary/images or error/timeout messages).handler: async ({ runId, timeoutMinutes = 30, pollIntervalSeconds = 10 }) => { try { const startTime = Date.now(); const timeoutMs = timeoutMinutes * 60 * 1000; const pollIntervalMs = pollIntervalSeconds * 1000; while (Date.now() - startTime < timeoutMs) { const statusResponse = await bugbugClient.getTestRunStatus(runId); if (statusResponse.status !== 200) { return { content: [ { type: 'text', text: `Error checking test run status: ${statusResponse.status} ${statusResponse.statusText}`, }, ], }; } if (isFinishedRunStatus(statusResponse.data.status)) { const runDetails = await bugbugClient.getTestRun(runId); const summary: CallToolResult['content'] = [ { type: 'text', text: createTestRunSummary(runDetails.data), }, ]; const screenshotMessages: CallToolResult['content'] = runDetails.data.screenshots?.map(screenshot => ({ type: 'image', data: screenshot, mimeType: 'image/png', })) || []; return { content: [...summary, ...screenshotMessages], }; } await new Promise(resolve => setTimeout(resolve, pollIntervalMs)); } return { content: [ { type: 'text', text: `Test run ${runId} did not finish within ${timeoutMinutes} minutes`, }, ], }; } catch (error) { return createToolError(error, 'Error waiting for test run'); } },
- src/tools/advanced.ts:13-17 (schema)Zod schema for tool inputs: required runId (UUID string), optional timeoutMinutes (default 30), optional pollIntervalSeconds (default 10).inputSchema: z.object({ runId: z.string().describe('Test run UUID to wait for'), timeoutMinutes: z.number().optional().default(30).describe('Maximum time to wait in minutes (default: 30)'), pollIntervalSeconds: z.number().optional().default(10).describe('Polling interval in seconds (default: 10)'), }).shape,
- src/tools/index.ts:11-33 (registration)Registers all tools (including waitForTestRunTool from advancedTools namespace) with the MCP server using their name, description, inputSchema, title, and handler functions.export function registerAllTools(server: McpServer): void { const tools: Record<string, Tool> = { ...configTools, ...testsTools, ...testRunsTools, ...suitesTools, ...suiteRunsTools, ...profilesTools, ...advancedTools, }; for (const t in tools) { server.registerTool( tools[t].name, { description: tools[t].description, inputSchema: tools[t].inputSchema, annotations: { title: tools[t].title }, }, (args: unknown) => tools[t].handler(args as unknown) ); } }