list_metrics
Retrieve all saved metrics from Metabase, including reusable aggregations like total revenue and average order value, for data analysis.
Instructions
📊 [SAFE] List all metrics (saved aggregations) in Metabase. Metrics are reusable calculations like "Total Revenue" or "Average Order Value". Risk: None - read-only operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The core handler function in SegmentMetricHandlers class that fetches metrics from Metabase API (/api/metric), formats them into a readable text list, and handles cases where the endpoint is unavailable (e.g., older Metabase versions).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; } }
- Tool definition including name, description, and input schema (no parameters required). This is part of the TOOL_DEFINITIONS array used for tool discovery.{ name: 'list_metrics', description: '📊 [SAFE] List all metrics (saved aggregations) in Metabase. Metrics are reusable calculations like "Total Revenue" or "Average Order Value". Risk: None - read-only operation.', inputSchema: { type: 'object', properties: {}, }, },
- src/server/MetabaseMCPServer.js:218-219 (registration)Registration in the main server switch statement that dispatches 'list_metrics' tool calls to the segmentMetricHandlers.listMetrics() method.case 'list_metrics': return await this.segmentMetricHandlers.listMetrics();
- src/server/MetabaseMCPServer.js:131-132 (registration)Tool list registration: returns TOOL_DEFINITIONS (including list_metrics) when listing available tools.return { tools: TOOL_DEFINITIONS,
- src/server/MetabaseMCPServer.js:43-43 (registration)Instantiation of the SegmentMetricHandlers class instance used by the list_metrics tool.this.segmentMetricHandlers = new SegmentMetricHandlers(this.apiClient);