Skip to main content
Glama
by MikelA92
collectionHandlers.js•1.67 kB
import { Validators } from '../../shared/utils/validators.js'; import { logger } from '../../shared/utils/logger.js'; /** * Handlers for collection-related operations */ export class CollectionHandlers { constructor(apiClient) { this.apiClient = apiClient; this.logger = logger.child('CollectionHandlers'); } /** * List all collections */ async listCollections(namespace = null) { this.logger.debug('Listing collections', { namespace }); const params = namespace ? new URLSearchParams({ namespace }) : ''; const collections = await this.apiClient.makeRequest(`/api/collection/${params ? '?' + params : ''}`); return { content: [ { type: 'text', text: `Collections: ${collections.map(c => `- ID: ${c.id} | Name: ${c.name}${c.description ? ` | ${c.description}` : ''}` ).join('\n')}`, }, ], }; } /** * Get collection items */ 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')}`, }, ], }; } }

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