Skip to main content
Glama
bucketeer-io

Bucketeer MCP Server

Official
by bucketeer-io

createFeatureFlag

Create a new feature flag with custom variations and targeting rules to enable controlled feature rollouts and A/B testing in your application.

Instructions

Create a new feature flag in the specified environment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
defaultOffVariationIndexYesIndex of the variation to serve when flag is off (0-based)
defaultOnVariationIndexYesIndex of the variation to serve when flag is on (0-based)
descriptionNoDescription of the feature flag
environmentIdNoEnvironment ID (uses default if not provided)
idYesUnique identifier for the feature flag (alphanumeric, hyphens, underscores)
nameYesHuman-readable name for the feature flag
tagsNoTags for the feature flag
variationTypeNoType of the variation values (default: STRING)
variationsYesList of variations (at least 2 required)

Implementation Reference

  • Zod input schema for validating parameters to create a feature flag, including ID, name, variations, indices, etc.
    export const createFlagSchema = z.object({ id: z .string() .min(1, "Feature flag ID is required") .regex( /^[a-zA-Z0-9-_]+$/, "ID must contain only alphanumeric characters, hyphens, and underscores", ), name: z.string().min(1, "Feature flag name is required"), description: z.string().optional().default(""), environmentId: z.string().optional(), variations: z .array(variationSchema) .min(2, "At least 2 variations are required"), tags: z.array(z.string()).optional(), defaultOnVariationIndex: z.number().min(0), defaultOffVariationIndex: z.number().min(0), variationType: z .nativeEnum(VariationType) .optional() .default(VariationType.STRING), });
  • The handler function that parses and validates input, prepares the CreateFeatureRequest, calls BucketeerClient.createFeature, and returns formatted response or error.
    handler: async (input: unknown) => { try { // Validate input const params = createFlagSchema.parse(input); // Validate variation indices if (params.defaultOnVariationIndex >= params.variations.length) { throw new Error( `defaultOnVariationIndex ${params.defaultOnVariationIndex} is out of bounds. Must be less than ${params.variations.length}`, ); } if (params.defaultOffVariationIndex >= params.variations.length) { throw new Error( `defaultOffVariationIndex ${params.defaultOffVariationIndex} is out of bounds. Must be less than ${params.variations.length}`, ); } logger.debug("Creating feature flag", params); // Create API client const client = new BucketeerClient( config.bucketeerHost, config.bucketeerApiKey, ); // Prepare request const request: CreateFeatureRequest = { id: params.id, name: params.name, description: params.description, environmentId: getEnvironmentId(params.environmentId), variations: params.variations, tags: params.tags, defaultOnVariationIndex: params.defaultOnVariationIndex, defaultOffVariationIndex: params.defaultOffVariationIndex, variationType: params.variationType, }; // Make API call const response = await client.createFeature(request); logger.info(`Successfully created feature flag: ${response.feature.id}`); return { content: [ { type: "text", text: JSON.stringify( { success: true, feature: response.feature, }, null, 2, ), }, ], }; } catch (error) { logger.error("Failed to create feature flag", error); if (error instanceof z.ZodError) { return { content: [ { type: "text", text: JSON.stringify( { success: false, error: "Invalid input parameters", details: error.issues, }, null, 2, ), }, ], isError: true, }; } return { content: [ { type: "text", text: JSON.stringify( { success: false, error: error instanceof Error ? error.message : "Unknown error", }, null, 2, ), }, ], isError: true, }; } },
  • The createFlagTool is imported and included in the exported 'tools' array, which is likely used to register all tools with the MCP server.
    export const tools = [ listFlagsTool, createFlagTool, getFlagTool, updateFlagTool, archiveFlagTool, ];
  • JSON schema definition for the tool's input, used by MCP for validation and documentation.
    inputSchema: { type: "object" as const, properties: { id: { type: "string", description: "Unique identifier for the feature flag (alphanumeric, hyphens, underscores)", }, name: { type: "string", description: "Human-readable name for the feature flag", }, description: { type: "string", description: "Description of the feature flag", }, environmentId: { type: "string", description: "Environment ID (uses default if not provided)", }, variations: { type: "array", description: "List of variations (at least 2 required)", items: { type: "object", properties: { value: { type: "string", description: "The value returned when this variation is served", }, name: { type: "string", description: "Name of the variation", }, description: { type: "string", description: "Description of the variation", }, }, required: ["value", "name"], }, }, tags: { type: "array", items: { type: "string" }, description: "Tags for the feature flag", }, defaultOnVariationIndex: { type: "number", description: "Index of the variation to serve when flag is on (0-based)", }, defaultOffVariationIndex: { type: "number", description: "Index of the variation to serve when flag is off (0-based)", }, variationType: { type: "string", enum: ["STRING", "BOOLEAN", "NUMBER", "JSON"], description: "Type of the variation values (default: STRING)", }, }, required: [ "id", "name", "variations", "defaultOnVariationIndex", "defaultOffVariationIndex", ], },
  • Zod schema for individual variations used within the createFlagSchema.
    const variationSchema = z.object({ value: z.string().min(1, "Variation value is required"), name: z.string().min(1, "Variation name is required"), description: z.string().optional().default(""), });

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

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