Skip to main content
Glama
flipt-io

Flipt MCP Server

Official
by flipt-io

get_segment

Retrieve detailed information about a specific segment within a namespace using Flipt MCP Server, enabling AI assistants and LLMs to interact with feature flag data directly.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceKeyYes
segmentKeyYes

Implementation Reference

  • Registers and implements the 'get_segment' MCP tool. Validates input with Zod schema (namespaceKey and segmentKey), fetches the segment using fliptClient.getSegment, returns JSON stringified response or error.
    server.tool(
      'get_segment',
      {
        namespaceKey: z.string().min(1),
        segmentKey: z.string().min(1),
      },
      async args => {
        try {
          const segment = await fliptClient.getSegment(args.namespaceKey, args.segmentKey);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(segment, null, 2),
              },
            ],
            _meta: {
              uri: `flipt://namespaces/${args.namespaceKey}/segments/${args.segmentKey}`,
            },
          };
        } catch (error: any) {
          console.error(
            `Error getting segment ${args.segmentKey} in namespace ${args.namespaceKey}:`,
            error
          );
          return {
            content: [
              {
                type: 'text',
                text: `Failed to get segment: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Zod input schema for the 'get_segment' tool requiring namespaceKey and segmentKey strings.
    {
      namespaceKey: z.string().min(1),
      segmentKey: z.string().min(1),
    },
  • Helper method in FliptClient class that wraps the generated SegmentsServiceApi.getSegment call to retrieve a specific segment.
    async getSegment(namespaceKey: string, key: string) {
      try {
        const response = await this.segmentsApi.getSegment(namespaceKey, key);
        return response;
      } catch (error) {
        console.error(`Error getting segment ${key} in namespace ${namespaceKey}:`, error);
        throw error;
      }
    }

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