Skip to main content
Glama

bruno_validate_environment

Validate environment file structure and variables in Bruno collections to ensure proper configuration and prevent API testing errors.

Instructions

Validate an environment file structure and variables

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionPathYesPath to the Bruno collection
environmentNameYesName of the environment to validate (e.g., "dev", "staging", "production")

Implementation Reference

  • ValidateEnvironmentHandler class: implements IToolHandler with getName() returning 'bruno_validate_environment' and handle() method that parses args with Zod schema, validates parameters, calls brunoCLI.validateEnvironment, formats output with status, variables (masked secrets), errors/warnings, and returns TextContent response.
    export class ValidateEnvironmentHandler implements IToolHandler { private readonly brunoCLI: IBrunoCLI; constructor(brunoCLI: IBrunoCLI) { this.brunoCLI = brunoCLI; } getName(): string { return 'bruno_validate_environment'; } async handle(args: unknown): Promise<ToolResponse> { const params = ValidateEnvironmentSchema.parse(args); // Validate collection path and environment name const validation = await validateToolParameters({ collectionPath: params.collectionPath, requestName: params.environmentName // Reuse request validation for env name }); if (!validation.valid) { throw new McpError( ErrorCode.InvalidParams, `Invalid parameters: ${validation.errors.join(', ')}` ); } try { const result = await this.brunoCLI.validateEnvironment( params.collectionPath, params.environmentName ); const output: string[] = []; output.push(`=== Environment Validation: ${params.environmentName} ===`); output.push(''); if (!result.exists) { output.push(`❌ Status: Not Found`); output.push(''); output.push('Errors:'); result.errors.forEach((err: string) => output.push(` • ${err}`)); } else if (!result.valid) { output.push(`❌ Status: Invalid`); output.push(''); output.push('Errors:'); result.errors.forEach((err: string) => output.push(` • ${err}`)); } else { output.push(`✅ Status: Valid`); output.push(''); if (result.variables && Object.keys(result.variables).length > 0) { output.push(`Variables: ${Object.keys(result.variables).length}`); output.push(''); Object.entries(result.variables).forEach(([key, value]) => { // Mask sensitive values const displayValue = key.toLowerCase().includes('password') || key.toLowerCase().includes('secret') || key.toLowerCase().includes('token') || key.toLowerCase().includes('key') ? '*** (masked)' : value; output.push(` ${key}: ${displayValue}`); }); output.push(''); } } if (result.warnings.length > 0) { output.push('Warnings:'); result.warnings.forEach((warn: string) => output.push(` ⚠️ ${warn}`)); } 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 environment: ${maskedError}` ); } } }
  • Zod schema for input validation: requires collectionPath and environmentName.
    const ValidateEnvironmentSchema = z.object({ collectionPath: z.string().describe('Path to the Bruno collection'), environmentName: z.string().describe('Name of the environment to validate') });
  • MCP Tool definition in TOOLS array: includes name, description, and inputSchema for bruno_validate_environment.
    { name: 'bruno_validate_environment', description: 'Validate an environment file in a Bruno collection', inputSchema: { type: 'object', properties: { collectionPath: { type: 'string', description: 'Path to the Bruno collection' }, environmentName: { type: 'string', description: 'Name of the environment to validate' } }, required: ['collectionPath', 'environmentName'] } },
  • src/index.ts:288-298 (registration)
    ToolRegistry registration: instantiates and registers ValidateEnvironmentHandler with BrunoCLI dependency (line 295).
    // Register all tool handlers this.toolRegistry.register(new RunRequestHandler(this.brunoCLI)); this.toolRegistry.register(new RunCollectionHandler(this.brunoCLI)); this.toolRegistry.register(new ListRequestsHandler(this.brunoCLI)); this.toolRegistry.register(new HealthCheckHandler(this.brunoCLI, this.configLoader, perfManager)); this.toolRegistry.register(new DiscoverCollectionsHandler(this.brunoCLI)); this.toolRegistry.register(new ListEnvironmentsHandler(this.brunoCLI)); this.toolRegistry.register(new ValidateEnvironmentHandler(this.brunoCLI)); this.toolRegistry.register(new GetRequestDetailsHandler(this.brunoCLI)); this.toolRegistry.register(new ValidateCollectionHandler(this.brunoCLI)); }
  • src/index.ts:26-26 (registration)
    Import statement for ValidateEnvironmentHandler.
    import { ValidateEnvironmentHandler } from './tools/handlers/ValidateEnvironmentHandler.js';

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