Skip to main content
Glama

bruno_discover_collections

Search directory trees to find Bruno API collections for testing, specifying path and depth to locate files.

Instructions

Discover Bruno collections in a directory tree

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchPathYesDirectory path to search for Bruno collections
maxDepthNoMaximum directory depth to search (default: 5)

Implementation Reference

  • The DiscoverCollectionsHandler class implements IToolHandler for 'bruno_discover_collections'. It validates input, calls BrunoCLI to discover collections, formats the output as text, and handles errors.
    export class DiscoverCollectionsHandler implements IToolHandler {
      private readonly brunoCLI: IBrunoCLI;
    
      constructor(brunoCLI: IBrunoCLI) {
        this.brunoCLI = brunoCLI;
      }
    
      getName(): string {
        return 'bruno_discover_collections';
      }
    
      async handle(args: unknown): Promise<ToolResponse> {
        const params = DiscoverCollectionsSchema.parse(args);
    
        // Validate search path
        const validation = await validateToolParameters({
          collectionPath: params.searchPath
        });
    
        if (!validation.valid) {
          throw new McpError(
            ErrorCode.InvalidParams,
            `Invalid search path: ${validation.errors.join(', ')}`
          );
        }
    
        try {
          const collections = await this.brunoCLI.discoverCollections(
            params.searchPath,
            params.maxDepth || 5
          );
    
          const output: string[] = [];
    
          if (collections.length === 0) {
            output.push(`No Bruno collections found in: ${params.searchPath}`);
            output.push('');
            output.push('A Bruno collection is a directory containing a bruno.json file.');
          } else {
            output.push(`Found ${collections.length} Bruno collection(s):\n`);
    
            collections.forEach((collectionPath, index) => {
              output.push(`${index + 1}. ${collectionPath}`);
            });
          }
    
          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 discover collections: ${maskedError}`
          );
        }
      }
    }
  • Input schema and metadata for the bruno_discover_collections tool, registered in the TOOLS array for the listTools MCP request.
    {
      name: 'bruno_discover_collections',
      description: 'Discover Bruno collections in a directory tree',
      inputSchema: {
        type: 'object',
        properties: {
          searchPath: {
            type: 'string',
            description: 'Directory path to search for Bruno collections'
          },
          maxDepth: {
            type: 'number',
            description: 'Maximum directory depth to search (default: 5)'
          }
        },
        required: ['searchPath']
      }
    },
  • src/index.ts:293-293 (registration)
    Instantiation and registration of the DiscoverCollectionsHandler with the ToolRegistry in the BrunoMCPServer setup.
    this.toolRegistry.register(new DiscoverCollectionsHandler(this.brunoCLI));
  • Zod schema used within the handler for parsing and validating tool input parameters.
    const DiscoverCollectionsSchema = z.object({
      searchPath: z.string().describe('Directory path to search for Bruno collections'),
      maxDepth: z.number().optional().describe('Maximum directory depth to search (default: 5)')
    });

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