get_collection_items
Retrieve all cards, dashboards, and models from a specific Metabase collection to view organized content within folders using collection ID.
Instructions
📁 [SAFE] Get all items (cards, dashboards, models) in a specific collection. Use this to see what content is organized in a folder. Risk: None - read-only operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collectionId | Yes | The ID of the collection (use "root" for root collection) | |
| models | No | Filter by item type (optional) |
Implementation Reference
- The server-side handler that implements the core logic for the 'get_collection_items' tool. Validates input, calls the Metabase API via apiClient, processes the response, and returns formatted MCP content.async getCollectionItems(collectionId, models = null) { Validators.validateCollectionId(collectionId); this.logger.debug('Getting collection items', { collectionId, models }); const params = models && models.length > 0 ? new URLSearchParams({ models: models.join(',') }) : ''; const items = await this.apiClient.makeRequest(`/api/collection/${collectionId}/items${params ? '?' + params : ''}`); return { content: [ { type: 'text', text: `Items in Collection ${collectionId}: Found ${items.data?.length || 0} items ${(items.data || []).map(item => `- [${item.model}] ID: ${item.id} | Name: ${item.name}` ).join('\n')}`, }, ], }; }
- The input schema, description, and metadata definition for the 'get_collection_items' tool, used for validation and tool listing.{ name: 'get_collection_items', description: '📁 [SAFE] Get all items (cards, dashboards, models) in a specific collection. Use this to see what content is organized in a folder. Risk: None - read-only operation.', inputSchema: { type: 'object', properties: { collectionId: { type: 'string', description: 'The ID of the collection (use "root" for root collection)', }, models: { type: 'array', description: 'Filter by item type (optional)', items: { type: 'string', enum: ['card', 'dashboard', 'dataset'], }, }, }, required: ['collectionId'], }, },
- src/server/MetabaseMCPServer.js:202-203 (registration)Registration of the tool handler in the MCP server's executeTool switch statement, mapping the tool name to the collectionHandlers.getCollectionItems method.case 'get_collection_items': return await this.collectionHandlers.getCollectionItems(args.collectionId, args.models);
- src/client/MetabaseClient.js:350-365 (helper)Helper method in the MetabaseClient class that performs the actual API request to fetch collection items, used by the server handler.async getCollectionItems(collectionId, models = null) { Validators.validateCollectionId(collectionId); const params = models && models.length > 0 ? new URLSearchParams({ models: models.join(',') }) : ''; const items = await this.makeRequest(`/api/collection/${collectionId}/items${params ? '?' + params : ''}`); return { data: items.data?.map(item => ({ id: item.id, name: item.name, description: item.description, model: item.model, })) || [], total: items.total || 0, }; }