Skip to main content
Glama
MikelA92

Metabase MCP Server

by MikelA92

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
NameRequiredDescriptionDefault

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: {},
      },
    },
  • 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();
  • Tool list registration: returns TOOL_DEFINITIONS (including list_metrics) when listing available tools.
    return {
      tools: TOOL_DEFINITIONS,
  • Instantiation of the SegmentMetricHandlers class instance used by the list_metrics tool.
    this.segmentMetricHandlers = new SegmentMetricHandlers(this.apiClient);

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