get_test_run
Retrieve detailed results for a specific BugBug test run using its unique identifier to analyze test execution outcomes and performance metrics.
Instructions
Get detailed results of a BugBug test run
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| runId | Yes | Test run UUID |
Implementation Reference
- src/tools/testRuns.ts:70-120 (handler)The complete tool definition for 'get_test_run', including the handler function that fetches test run details via bugbugClient, generates a summary using createTestRunSummary, handles errors, and returns a content array with text summary and screenshot images.export const getTestRunTool: Tool = { name: 'get_test_run', title: 'Get detailed results of a BugBug test run', description: 'Get detailed results of a BugBug test run', inputSchema: z.object({ runId: z.string().describe('Test run UUID'), }).shape, handler: async ({ runId }) => { try { const response = await bugbugClient.getTestRun(runId); if (response.status !== 200) { return { content: [ { type: 'text', text: `Error: ${response.status} ${response.statusText}`, }, ], }; } 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], }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching test run: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }, };
- src/tools/testRuns.ts:74-76 (schema)Zod input schema defining the required 'runId' parameter for the tool.inputSchema: z.object({ runId: z.string().describe('Test run UUID'), }).shape,
- src/tools/index.ts:11-33 (registration)The registerAllTools function imports and registers all tools, including 'get_test_run' from testRuns.ts, with the MCP server.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) ); } }
- src/services/bugbugClient.ts:230-232 (helper)The bugbugClient.getTestRun method that makes the API request to retrieve test run data.async getTestRun(id: string): Promise<ApiResponse<BugBugTestRun>> { return this.makeRequest(`/testruns/${id}/`); }
- src/utils/responses.ts:3-33 (helper)The createTestRunSummary helper function used to format the test run summary text.export const createTestRunSummary = (run: BugBugTestRun) => { const failedStepRun = run.stepsRuns?.find(stepRun => ['failed', 'error'].includes(stepRun.status)); const createErrorDetails = () => ` ${run.errorCode ? `During run "${run.errorCode}" error occured while running step "${failedStepRun?.name}"` : ''}; ${run.errorMessage ? `Extra error data: ${run.errorMessage}` : ''}; `; return ` Test run "${run.name}" has finished with status "${run.status}". ${createErrorDetails()} <meta> <id>${run.id}</id> <name>${run.name}</name> <status>${run.status}</status> <started>${run.started}</started> <finished>${run.finished}</finished> <duration>${run.duration}</duration> <url>${run.webappUrl}</url> </meta> <variables> ${run.variables?.map(variable => `<variable>${variable.key}=${variable.value}</variable>`).join('\n')} </variables> <steps> ${run.details?.map(step => ` <step> <id>${step.id}</id> <name>${step.name}</name>