updateFeatureFlag
Modify an existing Unleash feature flag's properties including description, type, status, and data collection settings to control feature rollouts and behavior.
Instructions
Update an existing feature flag
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| featureData | Yes | ||
| featureId | Yes | ||
| projectId | Yes |
Implementation Reference
- src/tools/index.ts:80-101 (handler)The handler function that executes the tool logic: parses input parameters using UpdateFeatureFlagSchema and sends a PUT request to the Unleash API to update the specified feature flag.
async function updateFeatureFlag( params: z.infer<typeof UpdateFeatureFlagSchema> ) { const { projectId, featureId, featureData } = UpdateFeatureFlagSchema.parse(params); try { const response = await axios.put( `${UNLEASH_API_URL}/api/admin/projects/${projectId}/features/${featureId}`, featureData, { headers: { Authorization: `Bearer ${UNLEASH_AUTH_TOKEN}`, 'Content-Type': 'application/json', }, } ); return response.data; } catch (error) { console.error('Error updating feature flag:', error); throw error; } } - src/tools/schema.ts:24-40 (schema)Raw Zod shape definition for updateFeatureFlag input parameters, used directly in tool registration.
const RawUpdateFeatureFlagShape = { projectId: z.string(), featureId: z.string(), featureData: z.object({ description: z.string(), type: z.enum([ 'experiment', 'kill-switch', 'release', 'operational', 'permission', ]), stale: z.boolean(), archived: z.boolean(), impressionData: z.boolean(), }), }; - src/tools/schema.ts:50-50 (schema)Zod schema for updateFeatureFlag parameters, used for input validation/parsing within the handler.
const UpdateFeatureFlagSchema = z.object(RawUpdateFeatureFlagShape); - src/index.ts:51-59 (registration)Registers the 'updateFeatureFlag' tool with the MCP server, specifying name, description, raw input schema, and a thin wrapper async handler that invokes the core updateFeatureFlag function and formats the response.
server.tool( 'updateFeatureFlag', 'Update an existing feature flag', RawUpdateFeatureFlagShape, async (args) => { const data = await updateFeatureFlag(args); return { content: [{ type: 'text', text: JSON.stringify(data) }] }; } );