get_collection_items
Retrieve all cards, dashboards, and models from a specific Metabase collection to view organized content. Use collection ID or 'root' for root folder.
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
- Core handler function that executes the get_collection_items tool logic: validates input, calls Metabase API to fetch items, formats and returns the response in MCP content format.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')}`, }, ], }; }
- Tool schema definition: specifies name, description, input schema with collectionId (required) and optional models filter.{ 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)Tool registration in the main server switch statement: dispatches get_collection_items calls to the collectionHandlers instance.case 'get_collection_items': return await this.collectionHandlers.getCollectionItems(args.collectionId, args.models);
- src/client/MetabaseClient.js:350-365 (helper)Shared API client method getCollectionItems used by the handler to make the actual Metabase API request and parse response.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, }; }