Skip to main content
Glama
MikelA92

Metabase MCP Server

by MikelA92

list_segments

Retrieve all saved filter segments from Metabase, such as 'Active Users' or 'Premium Customers', for reuse in queries and analysis.

Instructions

🎯 [SAFE] List all segments (saved filters) in Metabase. Segments are reusable filters like "Active Users" or "Premium Customers". Risk: None - read-only operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that implements the list_segments tool. It fetches all segments from the Metabase API endpoint '/api/segment' and formats them into a markdown-style text response listing ID, name, table, and description for each segment.
      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')}`,
            },
          ],
        };
      }
  • The tool schema definition specifying the name 'list_segments', its description, and an empty input schema (no parameters required). This is used for tool listing and validation.
      name: 'list_segments',
      description: '🎯 [SAFE] List all segments (saved filters) in Metabase. Segments are reusable filters like "Active Users" or "Premium Customers". Risk: None - read-only operation.',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • The switch case in the tool execution dispatcher that maps the 'list_segments' tool call to the SegmentMetricHandlers.listSegments() method.
    case 'list_segments':
      return await this.segmentMetricHandlers.listSegments();

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