Skip to main content
Glama
cuongtl1992

Unleash MCP (Feature Toggle)

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
NameRequiredDescriptionDefault
environmentYes
featureNameYes
projectIdYes

Implementation Reference

  • 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
        };
      }
    }
  • 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)
    };
  • 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
    );

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/cuongtl1992/unleash-mcp'

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