enableFlag
Activate a specific feature flag in a designated environment using the Unleash MCP server. Requires project ID, feature name, and environment details for precise control.
Instructions
Enables 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/enable-flag.ts:28-81 (handler)The handleEnableFlag function that executes the tool's logic: logs the action, calls enableFeatureFlag from Unleash, returns success/error responses in MCP format.export async function handleEnableFlag({ projectId, featureName, environment }: { projectId: string; featureName: string; environment: string; }) { logger.info(`Enabling feature flag '${featureName}' in environment '${environment}'`, { projectId, featureName, environment }); try { const result = await enableFeatureFlag(projectId, featureName, environment); return { content: [{ type: "text", text: JSON.stringify({ success: true, message: `Successfully enabled 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 enable feature flag: ${errorMessage}`, { status, projectId, featureName, environment }); // Return a structured error response return { content: [{ type: "text", text: JSON.stringify({ success: false, message: `Failed to enable feature flag: ${errorMessage}`, status: status || 500 }, null, 2) }], isError: true }; } }
- src/tools/enable-flag.ts:8-23 (schema)Zod schema defining the input parameters for the enableFlag tool: projectId, featureName, and environment.export const EnableFlagParamsSchema = { /** * The ID of the project containing the feature flag */ projectId: z.string().min(1), /** * The name of the feature flag to enable */ featureName: z.string().min(1), /** * The environment in which to enable the feature flag */ environment: z.string().min(1) };
- src/tools/enable-flag.ts:86-91 (registration)Exports the enableFlagTool object containing name, description, schema, and handler references.export const enableFlagTool = { name: "enableFlag", description: "Enables a feature flag in the specified environment", paramsSchema: EnableFlagParamsSchema, handler: handleEnableFlag };
- src/server.ts:209-214 (registration)Registers the enableFlag tool with the MCP server using server.tool().server.tool( enableFlagTool.name, enableFlagTool.description, enableFlagTool.paramsSchema as any, enableFlagTool.handler as any );