Skip to main content
Glama
simplypixi

BugBug MCP Server

by simplypixi

show_run_from_last_24

Display test and suite execution results from the past 24 hours to monitor recent automation runs and track performance trends.

Instructions

Shows tests/suites runs from last 24 hours

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageSizeNoNumber of results per page (default: 50)
runTypeNoType of runs to show - test, suite, or bothboth

Implementation Reference

  • The asynchronous handler function that fetches test and suite runs from the last 24 hours using the BugBug client, filters by type, summarizes them, and returns a formatted text response with summary and list of recent runs.
    handler: async ({ runType = 'both', pageSize = 50 }) => {
      try {
        const now = new Date();
        const yesterday = new Date(now.getTime() - 24 * 60 * 60 * 1000);
        const startedAfter = yesterday.toISOString();
    
        let testRuns: BugBugTestRun[] = [];
        let suiteRuns: BugBugSuiteRun[] = [];
    
        // Fetch test runs if requested
        if (runType === 'test') {
          const testRunsResponse = await bugbugClient.getTestRuns(1, pageSize, '-started', startedAfter);
          if (testRunsResponse.status === 200 && testRunsResponse.data.results) {
            testRuns = testRunsResponse.data.results;
          }
        }
    
        // Fetch suite runs if requested (we'll need to get all recent suite runs and filter)
        if (runType === 'suite') {
          // Note: BugBug API might not have a direct suite runs endpoint with date filtering
          // We'll try to get recent suite runs by checking individual suites
          // This is a limitation that might need API enhancement
          try {
            const suitesResponse = await bugbugClient.getSuites(1, 20, undefined, '-created');
            if (suitesResponse.status === 200 && suitesResponse.data.results) {
              // For each suite, we could check recent runs, but this would be expensive
              // For now, we'll note this limitation
              suiteRuns = [];
            }
          } catch (suiteError) {
            // Suite runs fetching failed, continue with test runs only
          }
        }
    
        // Combine and sort results
        const allRuns = [
          ...testRuns.map((run: BugBugTestRun) => ({ ...run, type: 'test' as const })),
          ...suiteRuns.map((run: BugBugSuiteRun) => ({ ...run, type: 'suite' as const }))
        ].sort((a, b) => new Date(b.started || b.modified || 0).getTime() - new Date(a.started || a.modified || 0).getTime());
    
        if (allRuns.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: `**No runs found in the last 24 hours**\n\nSearched for: ${runType} runs\nTime range: ${yesterday.toISOString()} to ${now.toISOString()}\n\n*Note: Suite run history might have limited API support.*`,
              },
            ],
          };
        }
    
        const runsList = allRuns.slice(0, pageSize).map((run: (BugBugTestRun | BugBugSuiteRun) & { type: 'test' | 'suite' }) => {
          const startTime = run.started || run.modified || 'N/A';
          const duration = run.duration || 'N/A';
          const status = run.status || 'Unknown';
          const runTypeLabel = run.type === 'test' ? '🧪 Test' : '📦 Suite';
          const errorInfo = run.errorCode && run.errorCode !== 'None' ? ` - Error: ${run.errorCode}` : '';
          
          return `- **${runTypeLabel}** ${run.name || run.id} - **${status}** (${startTime}) - Duration: ${duration}${errorInfo}`;
        }).join('\n');
    
        const summary = {
          total: allRuns.length,
          completed: allRuns.filter(r => r.status?.toLowerCase() === 'completed').length,
          failed: allRuns.filter(r => r.status?.toLowerCase() === 'failed').length,
          running: allRuns.filter(r => ['running', 'queued'].includes(r.status?.toLowerCase())).length,
        };
    
        return {
          content: [
            {
              type: 'text',
              text: `**Runs from Last 24 Hours** (${runType} runs)\n\n**Summary:**\n- Total: ${summary.total}\n- Completed: ${summary.completed}\n- Failed: ${summary.failed}\n- Running/Queued: ${summary.running}\n\n**Recent Runs:**\n${runsList}\n\n*Showing up to ${pageSize} most recent runs*`,
            },
          ],
        };
    
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error fetching runs from last 24 hours: ${error instanceof Error ? error.message : 'Unknown error'}`,
            },
          ],
        };
      }
    },
  • Zod schema defining the input parameters for the tool: runType (enum: 'test', 'suite', 'both', default 'both') and pageSize (number, default 50).
    inputSchema: z.object({
      runType: z.enum(['test', 'suite', 'both']).optional().default('both').describe('Type of runs to show - test, suite, or both'),
      pageSize: z.number().optional().default(50).describe('Number of results per page (default: 50)'),
    }).shape,
  • The registerAllTools function imports advancedTools (which includes showRunFromLast24Tool) and registers all tools with the MCP server by spreading the tool objects and calling server.registerTool for each in a loop, using the tool's name, description, inputSchema, title, and handler.
    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)
        );
      }
    }

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