bruno_discover_collections
Find Bruno API collections by scanning directories for bruno.json files. Specify a search path and optional depth limit to locate all collections automatically.
Instructions
Discover Bruno collections by recursively searching for bruno.json files in a directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| searchPath | Yes | Directory path to search for Bruno collections | |
| maxDepth | No | Maximum directory depth to search (default: 5, max: 10) |
Implementation Reference
- The DiscoverCollectionsHandler class implements IToolHandler for 'bruno_discover_collections'. It validates input, discovers collections using BrunoCLI.discoverCollections, formats output, 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}` ); } } }
- src/index.ts:155-172 (schema)MCP tool definition including name, description, and inputSchema for bruno_discover_collections in the TOOLS array used for listTools.{ 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)Registration of the DiscoverCollectionsHandler instance in the ToolRegistry during server initialization.this.toolRegistry.register(new DiscoverCollectionsHandler(this.brunoCLI));
- Zod schema for input validation used within the handler's handle method.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)') });