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; } }

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