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
| Name | Required | Description | Default |
|---|---|---|---|
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: {}, }, },
- src/server/MetabaseMCPServer.js:216-217 (registration)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();