Skip to main content
Glama
MikelA92
by MikelA92

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
NameRequiredDescriptionDefault
collectionIdYesThe ID of the collection (use "root" for root collection)
modelsNoFilter 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'], }, },
  • 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);
  • 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, }; }

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/MikelA92/metabase-mcp-mab'

If you have feedback or need assistance with the MCP directory API, please join our Discord server