Skip to main content
Glama
flipt-io

Flipt MCP Server

Official
by flipt-io

toggle_flag

Manage feature flag states with precision by enabling or disabling flags in specific namespaces using the toggle tool on the Flipt MCP Server, ensuring dynamic control over application features.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
enabledYes
flagKeyYes
namespaceKeyYes

Implementation Reference

  • Primary implementation: registers the 'toggle_flag' MCP tool with Zod input schema and inline async handler. The handler gets current flag to preserve metadata, toggles enabled state via FliptClient, returns text response with URI.
    server.tool( 'toggle_flag', { namespaceKey: z.string().min(1), flagKey: z.string().min(1), enabled: z.boolean(), }, async args => { try { const currentFlag = await fliptClient.getFlag(args.namespaceKey, args.flagKey); await fliptClient.updateFlag( args.namespaceKey, args.flagKey, currentFlag.name!, currentFlag.description, args.enabled ); return { content: [ { type: 'text', text: `Flag ${args.flagKey} in namespace ${args.namespaceKey} is now ${args.enabled ? 'enabled' : 'disabled'}`, }, ], _meta: { uri: `flipt://namespaces/${args.namespaceKey}/flags/${args.flagKey}`, }, }; } catch (error: any) { console.error('Error toggling flag:', error); return { content: [ { type: 'text', text: `Failed to toggle flag: ${error.message}`, }, ], isError: true, }; } } );
  • Zod schema defining input parameters for toggle_flag tool: namespaceKey (required string), flagKey (required string), enabled (required boolean). Handles input validation.
    { namespaceKey: z.string().min(1), flagKey: z.string().min(1), enabled: z.boolean(), },
  • FliptClient.updateFlag helper invoked by the tool handler to perform the actual flag update via generated FlagsServiceApi.updateFlag.
    async updateFlag( namespaceKey: string, key: string, name: string, description?: string, enabled?: boolean ) { try { const response = await this.flagsApi.updateFlag(namespaceKey, key, { name, description, enabled, }); return response; } catch (error) { console.error('Error updating flag:', error); throw error; } }
  • FliptClient.getFlag helper used by the tool handler to fetch current flag details before updating.
    async getFlag(namespaceKey: string, key: string) { try { const response = await this.flagsApi.getFlag(namespaceKey, key); return response; } catch (error) { console.error(`Error getting flag ${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