Skip to main content
Glama

bruno_list_environments

Retrieve all available environments from a Bruno API collection to manage configuration variables for testing different endpoints and scenarios.

Instructions

List all environments in a Bruno collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionPathYesPath to the Bruno collection

Implementation Reference

  • Core handler logic for bruno_list_environments: parses input, validates collection path, lists environments via BrunoCLI, formats output with previews (secrets masked), handles errors.
    async handle(args: unknown): Promise<ToolResponse> { const params = ListEnvironmentsSchema.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 environments = await this.brunoCLI.listEnvironments(params.collectionPath); const output: string[] = []; if (environments.length === 0) { output.push('No environments found in this collection.'); output.push(''); output.push('Environments are stored in the "environments" directory with .bru extension.'); } else { output.push(`Found ${environments.length} environment(s):\n`); environments.forEach((env) => { output.push(`• ${env.name}`); output.push(` Path: ${env.path}`); if (env.variables && Object.keys(env.variables).length > 0) { output.push(` Variables: ${Object.keys(env.variables).length}`); // Show first few variables as preview const varEntries = Object.entries(env.variables).slice(0, 3); varEntries.forEach(([key, value]) => { // Mask potential secrets in output const displayValue = key.toLowerCase().includes('password') || key.toLowerCase().includes('secret') || key.toLowerCase().includes('token') || key.toLowerCase().includes('key') ? '***' : value.length > 50 ? value.substring(0, 47) + '...' : value; output.push(` - ${key}: ${displayValue}`); }); if (Object.keys(env.variables).length > 3) { output.push(` ... and ${Object.keys(env.variables).length - 3} more`); } } output.push(''); }); } 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 list environments: ${maskedError}` ); } }
  • Zod schema for input validation in the handler.
    const ListEnvironmentsSchema = z.object({ collectionPath: z.string().describe('Path to the Bruno collection') });
  • MCP tool inputSchema definition provided in ListTools response.
    inputSchema: { type: 'object', properties: { collectionPath: { type: 'string', description: 'Path to the Bruno collection' } }, required: ['collectionPath'] }
  • src/index.ts:294-294 (registration)
    Registers the ListEnvironmentsHandler instance with the ToolRegistry for execution.
    this.toolRegistry.register(new ListEnvironmentsHandler(this.brunoCLI));
  • src/index.ts:173-186 (registration)
    Tool definition registered in the TOOLS array for ListTools request.
    { name: 'bruno_list_environments', description: 'List all environments in a Bruno collection', inputSchema: { type: 'object', properties: { collectionPath: { type: 'string', description: 'Path to the Bruno collection' } }, required: ['collectionPath'] } },

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