Skip to main content
Glama
simplypixi

BugBug MCP Server

by simplypixi

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
NameRequiredDescriptionDefault
runIdYesTest run UUID

Implementation Reference

  • 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'}`,
                },
              ],
            };
          }
        },
    };
  • Zod input schema defining the required 'runId' parameter for the tool.
    inputSchema: z.object({
      runId: z.string().describe('Test run UUID'),
    }).shape,
  • 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)
        );
      }
    }
  • 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}/`);
    }
  • 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>

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/simplypixi/bugbug-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server