Skip to main content
Glama

bruno_validate_collection

Validate the structure and configuration of API collections to ensure they are correctly formatted and ready for testing.

Instructions

Validate a Bruno collection's structure and configuration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionPathYesPath to the Bruno collection to validate

Implementation Reference

  • Core handler function that parses input parameters, validates the collection path, executes brunoCLI.validateCollection, processes results, and returns formatted text output with summary, errors, and warnings.
    async handle(args: unknown): Promise<ToolResponse> {
      const params = ValidateCollectionSchema.parse(args);
    
      // Validate collection path
      const validation = await validateToolParameters({
        collectionPath: params.collectionPath
      });
    
      if (!validation.valid) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Invalid collection path: ${validation.errors.join(', ')}`
        );
      }
    
      try {
        const result = await this.brunoCLI.validateCollection(params.collectionPath);
    
        const output: string[] = [];
        output.push('=== Collection Validation ===');
        output.push('');
    
        if (result.valid) {
          output.push('✅ Collection is valid');
        } else {
          output.push('❌ Collection has errors');
        }
        output.push('');
    
        // Summary
        output.push('Summary:');
        output.push(`  bruno.json: ${result.summary.hasBrunoJson ? '✓ Found' : '✗ Missing'}`);
        output.push(`  Total Requests: ${result.summary.totalRequests}`);
        output.push(`  Valid Requests: ${result.summary.validRequests}`);
        output.push(`  Invalid Requests: ${result.summary.invalidRequests}`);
        output.push(`  Environments: ${result.summary.environments}`);
        output.push('');
    
        // Errors
        if (result.errors.length > 0) {
          output.push('Errors:');
          result.errors.forEach((err: string) => output.push(`  ✗ ${err}`));
          output.push('');
        }
    
        // Warnings
        if (result.warnings.length > 0) {
          output.push('Warnings:');
          result.warnings.forEach((warn: string) => output.push(`  ⚠️  ${warn}`));
          output.push('');
        }
    
        if (result.valid && result.warnings.length === 0) {
          output.push('🎉 Collection is ready to use!');
        }
    
        return {
          content: [
            {
              type: 'text',
              text: output.join('\n')
            } as TextContent
          ]
        };
      } catch (error) {
        const maskedError = error instanceof Error ? maskSecretsInError(error) : error;
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to validate collection: ${maskedError}`
        );
      }
    }
  • Zod schema for input validation used within the handler to parse and validate the collectionPath parameter.
    const ValidateCollectionSchema = z.object({
      collectionPath: z.string().describe('Path to the Bruno collection to validate')
    });
  • src/index.ts:223-236 (registration)
    Tool registration in the TOOLS array, defining name, description, and inputSchema for the MCP protocol.
    {
      name: 'bruno_validate_collection',
      description: "Validate a Bruno collection's structure and configuration",
      inputSchema: {
        type: 'object',
        properties: {
          collectionPath: {
            type: 'string',
            description: 'Path to the Bruno collection to validate'
          }
        },
        required: ['collectionPath']
      }
    }
  • src/index.ts:297-297 (registration)
    Instantiation and registration of the ValidateCollectionHandler instance in the ToolRegistry.
    this.toolRegistry.register(new ValidateCollectionHandler(this.brunoCLI));

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

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