updateFlag
Modify feature flags in Unleash projects to control enabled features. Update properties like status, type, or description to manage feature toggles effectively.
Instructions
Update an existing feature flag in an Unleash project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| archived | No | ||
| description | No | ||
| featureName | Yes | ||
| impressionData | No | ||
| projectId | Yes | ||
| stale | No | ||
| type | No |
Implementation Reference
- src/tools/update-flag.ts:26-82 (handler)Handler function that executes the updateFlag tool logic: calls updateFeatureFlag helper and formats MCP response.export async function handleUpdateFlag(params: { projectId: string; featureName: string; description?: string; type?: string; impressionData?: boolean; archived?: boolean; stale?: boolean; }) { try { // Update the feature flag const result = await updateFeatureFlag({ projectId: params.projectId, featureName: params.featureName, description: params.description, type: params.type, impressionData: params.impressionData, archived: params.archived, stale: params.stale }); if (!result) { return { content: [{ type: "text", text: JSON.stringify({ success: false, error: `Failed to update feature flag '${params.featureName}'` }, null, 2) }], isError: true }; } return { content: [{ type: "text", text: JSON.stringify({ success: true, message: `Successfully updated feature flag '${params.featureName}' in project '${params.projectId}'`, flag: result }, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: JSON.stringify({ success: false, error: error.message }, null, 2) }], isError: true }; } }
- src/tools/update-flag.ts:11-21 (schema)Zod schema defining input parameters for the updateFlag tool.export const UpdateFlagParamsSchema = { projectId: z.string().min(1), featureName: z.string().min(1).max(100).regex(/^[a-z0-9-_.]+$/, { message: "Name must be URL-friendly: use only lowercase, numbers, hyphens, underscores, and periods" }), description: z.string().optional(), type: z.enum(['release', 'experiment', 'operational', 'permission', 'kill-switch']).optional(), impressionData: z.boolean().optional(), archived: z.boolean().optional(), stale: z.boolean().optional() };
- src/server.ts:101-106 (registration)Registration of the updateFlag tool with the MCP server using server.tool().server.tool( updateFlagTool.name, updateFlagTool.description, updateFlagTool.paramsSchema as any, updateFlagTool.handler as any );
- src/tools/update-flag.ts:87-92 (registration)Tool object definition exporting the updateFlag tool with name, description, schema, and handler.export const updateFlagTool = { name: "updateFlag", description: "Update an existing feature flag in an Unleash project", paramsSchema: UpdateFlagParamsSchema, handler: handleUpdateFlag };