Skip to main content
Glama
MikelA92
by MikelA92
segmentMetricHandlers.js1.42 kB
import { logger } from '../../shared/utils/logger.js'; /** * Handlers for segment and metric operations */ export class SegmentMetricHandlers { constructor(apiClient) { this.apiClient = apiClient; this.logger = logger.child('SegmentMetricHandlers'); } /** * List all segments */ async listSegments() { this.logger.debug('Listing segments'); const segments = await this.apiClient.makeRequest('/api/segment'); return { content: [ { type: 'text', text: `Segments: ${segments.map(s => `- ID: ${s.id} | Name: ${s.name} | Table: ${s.table?.name}${s.description ? ` | ${s.description}` : ''}` ).join('\n')}`, }, ], }; } /** * List all metrics */ async listMetrics() { this.logger.debug('Listing metrics'); try { const metrics = await this.apiClient.makeRequest('/api/metric'); return { content: [ { type: 'text', text: `Metrics: ${metrics.map(m => `- ID: ${m.id} | Name: ${m.name} | Table: ${m.table?.name}${m.description ? ` | ${m.description}` : ''}` ).join('\n')}`, }, ], }; } catch (error) { if (error.message.includes('404')) { return { content: [{ type: 'text', text: 'Metrics endpoint not available in this Metabase version' }], }; } throw error; } } }

Implementation Reference

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