Skip to main content
Glama
flipt-io

Flipt MCP Server

Official
by flipt-io

update_segment

Modify feature flag segments in Flipt MCP Server by updating namespace, key, name, match type, and description to refine targeting and behavior for AI-driven interactions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNo
keyYes
matchTypeYes
nameYes
namespaceKeyYes

Implementation Reference

  • MCP tool handler for 'update_segment': retrieves current segment, merges provided updates (name, description, matchType), calls fliptClient.updateSegment, and returns the updated segment or error.
    async args => {
      try {
        const currentSegment = await fliptClient.getSegment(args.namespaceKey, args.key);
        if (!currentSegment) {
          return {
            content: [
              {
                type: 'text',
                text: `Segment ${args.key} in namespace ${args.namespaceKey} not found`,
              },
            ],
            isError: true,
          };
        }
    
        // update changed fields
        const updatedSegment = {
          ...currentSegment,
          name: args.name || currentSegment.name,
          description: args.description || currentSegment.description,
          matchType: args.matchType || currentSegment.matchType,
        };
    
        const segment = await fliptClient.updateSegment(
          currentSegment.namespaceKey!,
          currentSegment.key!,
          updatedSegment.name!,
          updatedSegment.description,
          updatedSegment.matchType
        );
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(segment, null, 2),
            },
          ],
          _meta: {
            uri: `flipt://namespaces/${args.namespaceKey}/segments/${args.key}`,
          },
        };
      } catch (error: any) {
        console.error('Error updating segment:', error);
        return {
          content: [
            {
              type: 'text',
              text: `Failed to update segment: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod input schema defining parameters for the update_segment tool: namespaceKey, key, name (required), description and matchType (optional with enum).
    {
      namespaceKey: z.string().min(1),
      key: z.string().min(1),
      name: z.string().min(1),
      description: z.string().optional(),
      matchType: z.enum(['ALL_MATCH_TYPE', 'ANY_MATCH_TYPE']),
    },
  • src/index.ts:538-602 (registration)
    Registration of the 'update_segment' MCP tool using server.tool, including schema and inline handler function.
    server.tool(
      'update_segment',
      {
        namespaceKey: z.string().min(1),
        key: z.string().min(1),
        name: z.string().min(1),
        description: z.string().optional(),
        matchType: z.enum(['ALL_MATCH_TYPE', 'ANY_MATCH_TYPE']),
      },
      async args => {
        try {
          const currentSegment = await fliptClient.getSegment(args.namespaceKey, args.key);
          if (!currentSegment) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Segment ${args.key} in namespace ${args.namespaceKey} not found`,
                },
              ],
              isError: true,
            };
          }
    
          // update changed fields
          const updatedSegment = {
            ...currentSegment,
            name: args.name || currentSegment.name,
            description: args.description || currentSegment.description,
            matchType: args.matchType || currentSegment.matchType,
          };
    
          const segment = await fliptClient.updateSegment(
            currentSegment.namespaceKey!,
            currentSegment.key!,
            updatedSegment.name!,
            updatedSegment.description,
            updatedSegment.matchType
          );
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(segment, null, 2),
              },
            ],
            _meta: {
              uri: `flipt://namespaces/${args.namespaceKey}/segments/${args.key}`,
            },
          };
        } catch (error: any) {
          console.error('Error updating segment:', error);
          return {
            content: [
              {
                type: 'text',
                text: `Failed to update segment: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • FliptClient service method that maps parameters to UpdateSegmentRequest and calls the generated segmentsApi.updateSegment.
    async updateSegment(
      namespaceKey: string,
      key: string,
      name: string,
      description?: string,
      matchType?: string
    ) {
      try {
        const segmentMatchType =
          matchType === 'ALL_MATCH_TYPE'
            ? UpdateSegmentRequestMatchTypeEnum.AllMatchType
            : UpdateSegmentRequestMatchTypeEnum.AnyMatchType;
    
        const response = await this.segmentsApi.updateSegment(namespaceKey, key, {
          name,
          description,
          matchType: segmentMatchType,
        });
        return response;
      } catch (error) {
        console.error('Error updating segment:', error);
        throw error;
      }
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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