Skip to main content
Glama
flipt-io

Flipt MCP Server

Official
by flipt-io

list_segments

Retrieve all segments within a specified namespace to manage and evaluate feature flag targeting and user groupings effectively.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceKeyYes

Implementation Reference

  • The MCP tool handler function for 'list_segments' that fetches segments via fliptClient.listSegments, formats the response as JSON text content with metadata URI, or returns an error response.
    try { const segments = await fliptClient.listSegments(args.namespaceKey); return { content: [ { type: 'text', text: JSON.stringify(segments, null, 2), }, ], _meta: { uri: `flipt://namespaces/${args.namespaceKey}/segments`, }, }; } catch (error: any) { console.error(`Error listing segments for namespace ${args.namespaceKey}:`, error); return { content: [ { type: 'text', text: `Failed to list segments: ${error.message}`, }, ], isError: true, }; } }
  • Zod input schema for the 'list_segments' tool, requiring a non-empty namespaceKey string.
    namespaceKey: z.string().min(1), }, async args => {
  • src/index.ts:423-454 (registration)
    Registration of the 'list_segments' MCP tool using server.tool, including name, schema, and handler.
    'list_segments', { namespaceKey: z.string().min(1), }, async args => { try { const segments = await fliptClient.listSegments(args.namespaceKey); return { content: [ { type: 'text', text: JSON.stringify(segments, null, 2), }, ], _meta: { uri: `flipt://namespaces/${args.namespaceKey}/segments`, }, }; } catch (error: any) { console.error(`Error listing segments for namespace ${args.namespaceKey}:`, error); return { content: [ { type: 'text', text: `Failed to list segments: ${error.message}`, }, ], isError: true, }; } } );
  • Helper method in FliptClient class that invokes the generated SegmentsServiceApi.listSegments, extracts segments from response, and handles errors by returning empty array.
    async listSegments(namespaceKey: string) { try { const response = await this.segmentsApi.listSegments(namespaceKey); if (response && response.segments) { return response.segments; } else { console.error('Unexpected response structure:', response); return []; } } catch (error) { console.error(`Error getting segments for namespace ${namespaceKey}:`, error); return []; } }

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/flipt-io/mcp-server-flipt'

If you have feedback or need assistance with the MCP directory API, please join our Discord server