Skip to main content
Glama

run-collection

Execute API test collections from Bruno CLI by specifying collection paths, environment files, and variables to validate endpoints.

Instructions

Run a Bruno Collection using Bruno CLI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesPath to the Bruno collection
environmentNoOptional path to environment file
variablesNoOptional environment variables

Implementation Reference

  • Core handler implementation that constructs and executes the Bruno CLI command to run the collection, handles output via temporary JSON report, parses results, and formats the response with success status, summary, failures, and timings.
    async runCollection(params: RunCollectionParams): Promise<BrunoRunResult> {
      const startTime = new Date();
      
      return withReportFile('bruno-run-', '.json', async (outputFile) => {
        try {
          // Get collection directory and name
          const collectionDir = dirname(params.collection);
          const collectionName = basename(params.collection);
    
          // Build the command with arguments
          const args: string[] = ['cd', collectionDir, '&&', 'bru', 'run', `${collectionName}`];
    
          // Add environment if specified
          if (params.environment) {
            args.push('--env', params.environment);
          }
    
          // Add environment variables if specified
          if (params.variables && params.variables.length > 0) {
            for (const variable of params.variables) {
              args.push('--env-var', variable);
            }
          }
    
          // Add output file
          args.push('--reporter-json', outputFile);
    
          // Skip all headers
          args.push('--reporter-skip-all-headers');
    
          // Execute the command
          const command = args.join(' ');
          console.error('Running command:', command);
          
          try {
            await execAsync(command);
          } catch (error) {
            const cliError = error as { message: string; stderr: string; stdout: string };
            
            if (!cliError.stdout.match(REQUEST_SUMMARY_REGEX)) {
              throw new Error(`CLI stderr: ${cliError.stderr || 'Unknown error'}`);
            }
          }
    
          // Read the results from the output file
          const resultJson = await readFile(outputFile, 'utf-8');
          const endTime = new Date();
          const duration = endTime.getTime() - startTime.getTime();
          const jsonResult = JSON.parse(resultJson);
    
          const { summary, results = [] } = jsonResult[0];
          const isSuccess = summary.failedRequests === 0;
    
          // Transform CLI results into our standard format
          return {
            success: isSuccess,
            summary: {
              total: summary.totalRequests || 0,
              failed: summary.failedRequests || 0,
              passed: summary.passedRequests || 0
            },
            failures: isSuccess ? [] : results.filter((result: any) => result.error).map((failure: any) => ({
              name: failure.suitename || 'Unknown Test',
              message: failure.error || 'Unknown error'
            })),
            timings: {
              started: startTime.toISOString(),
              completed: endTime.toISOString(),
              duration
            }
          };
        } catch (error) {
          console.error('Error running collection:', error);
          throw error;
        }
      });
    }
  • MCP server request handler for tool calls that dispatches to BrunoRunner.runCollection for the 'run-collection' tool, including argument validation and response formatting.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
      if (name !== "run-collection") {
        throw new Error(`Unknown tool: ${request.params.name}`);
      }
      
      try {
        const result = await this.runner.runCollection(RunCollectionSchema.parse(args));
        return {
          content: [{
              type: "text",
              text: JSON.stringify(result, null, 2)
          }]
        };
      } catch (error) {
        if (error instanceof z.ZodError) {
          throw new Error(
            `Invalid arguments: ${error.errors
              .map((e) => `${e.path.join(".")}: ${e.message}`)
              .join(", ")}`
          ); 
        }
        throw error;
      }
    });
  • Zod schema for validating input parameters to the run-collection tool.
    export const RunCollectionSchema = z.object({
      collection: z.string().describe("Path to the Bruno collection"),
      environment: z.string().optional().describe("Optional path to environment file"),
      variables: z.array(z.string()).optional().describe("Optional environment variables"),
    });
  • src/server.ts:29-37 (registration)
    Registration of the 'run-collection' tool in the MCP server's listTools response.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: "run-collection",
          description: "Run a Bruno Collection using Bruno CLI",
          inputSchema: zodToJsonSchema(RunCollectionSchema)
        }
      ]
    }));
  • Helper utility used by the handler to manage temporary JSON report files for Bruno CLI output.
    export async function withReportFile<T>(
      prefix: string,
      extension: string,
      callback: (filePath: string) => Promise<T>
    ): Promise<T> {
      const buildDir = path.join(process.cwd(), 'build', 'reports');
      
      // Create reports directory if it doesn't exist
      if (!fs.existsSync(buildDir)) {
        await fsPromises.mkdir(buildDir, { recursive: true });
      }
    
      const tempFile = path.join(buildDir, `${prefix}${Date.now()}${extension}`);
      
      try {
        return await callback(tempFile);
      } finally {
        // Clean up temp file
        try {
          await fsPromises.unlink(tempFile);
        } catch (error) {
          // Ignore errors during cleanup
        }
      }
    } 
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'Run' which implies execution, but fails to describe critical behaviors like whether it's read-only/destructive, requires specific permissions, has side effects (e.g., file changes), or handles errors. This leaves significant gaps for an execution tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized and front-loaded, clearly stating the core action without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of running a collection (an execution tool with potential side effects), no annotations, and no output schema, the description is incomplete. It lacks details on behavior, output format, error handling, or dependencies, making it inadequate for safe and effective use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents all parameters (collection path, optional environment file, optional variables). The description adds no additional meaning beyond what the schema provides, such as format examples or usage context, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Run') and resource ('a Bruno Collection using Bruno CLI'), making the purpose understandable. However, it doesn't differentiate from siblings since there are none, so it can't achieve the full 5 points for sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool, such as prerequisites (e.g., Bruno CLI installation), alternatives, or specific contexts. It only states what the tool does without usage instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/hungthai1401/bruno-mcp'

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