disableFlag
Disables a specific feature flag in a given environment using the Unleash MCP server, ensuring precise control over feature toggles within a project.
Instructions
Disables a feature flag in the specified environment
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| environment | Yes | ||
| featureName | Yes | ||
| projectId | Yes |
Implementation Reference
- src/tools/disable-flag.ts:28-81 (handler)The handler function that performs the disable flag operation, logs activity, calls the Unleash disable function, and formats success/error responses.export async function handleDisableFlag({ projectId, featureName, environment }: { projectId: string; featureName: string; environment: string; }) { logger.info(`Disabling feature flag '${featureName}' in environment '${environment}'`, { projectId, featureName, environment }); try { const result = await disableFeatureFlag(projectId, featureName, environment); return { content: [{ type: "text", text: JSON.stringify({ success: true, message: `Successfully disabled feature flag '${featureName}' in environment '${environment}'`, data: result }, null, 2) }] }; } catch (error: any) { // Handle errors from the Unleash API const errorMessage = error.response?.data?.message || error.message; const status = error.response?.status; logger.error(`Failed to disable feature flag: ${errorMessage}`, { status, projectId, featureName, environment }); // Return a structured error response return { content: [{ type: "text", text: JSON.stringify({ success: false, message: `Failed to disable feature flag: ${errorMessage}`, status: status || 500 }, null, 2) }], isError: true }; } }
- src/tools/disable-flag.ts:8-23 (schema)Zod schema defining the input parameters for the disableFlag tool: projectId, featureName, and environment.export const DisableFlagParamsSchema = { /** * The ID of the project containing the feature flag */ projectId: z.string().min(1), /** * The name of the feature flag to disable */ featureName: z.string().min(1), /** * The environment in which to disable the feature flag */ environment: z.string().min(1) };
- src/tools/disable-flag.ts:86-91 (registration)Defines the disableFlagTool object with name, description, paramsSchema, and handler for use in server registration.export const disableFlagTool = { name: "disableFlag", description: "Disables a feature flag in the specified environment", paramsSchema: DisableFlagParamsSchema, handler: handleDisableFlag };
- src/server.ts:216-221 (registration)Registers the disableFlag tool with the MCP server instance.server.tool( disableFlagTool.name, disableFlagTool.description, disableFlagTool.paramsSchema as any, disableFlagTool.handler as any );