Skip to main content
Glama
cuongtl1992

Unleash MCP (Feature Toggle)

createFlag

Add a feature flag to an Unleash project, enabling dynamic toggling of features for controlled rollouts, experiments, or operational adjustments.

Instructions

Create a new feature flag in an Unleash project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNo
impressionDataNo
nameYes
projectYes
typeNo

Implementation Reference

  • The primary handler function that implements the core logic of the createFlag tool. It processes validated parameters, invokes the Unleash API helper, handles success/error cases, and returns MCP-formatted content.
    export async function handleCreateFlag(params: {
      name: string;
      project: string;
      description?: string;
      type?: string;
      impressionData?: boolean;
    }) {
      try {
        // Create the feature flag
        const result = await createFeatureFlag({
          name: params.name,
          project: params.project,
          description: params.description,
          type: params.type,
          impressionData: params.impressionData
        });
        
        if (!result) {
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify({ 
                success: false,
                error: `Failed to create feature flag '${params.name}'` 
              }, null, 2)
            }],
            isError: true
          };
        }
        
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify({ 
              success: true,
              message: `Successfully created feature flag '${params.name}' in project '${params.project}'`,
              flag: result
            }, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify({ 
              success: false,
              error: error.message 
            }, null, 2)
          }],
          isError: true
        };
      }
    }
  • Zod-based input schema for validating parameters to the createFlag tool (name, project, description, type, impressionData).
    export const CreateFlagParamsSchema = {
      name: z.string().min(1).max(100).regex(/^[a-z0-9-_.]+$/, {
        message: "Name must be URL-friendly: use only lowercase, numbers, hyphens, underscores, and periods"
      }),
      project: z.string(),
      description: z.string().optional(),
      type: z.enum(['release', 'experiment', 'operational', 'permission', 'kill-switch']).optional(),
      impressionData: z.boolean().optional()
    };
  • src/server.ts:94-99 (registration)
    Registers the createFlag tool with the MCP server instance using server.tool(), referencing the imported tool definition.
    server.tool(
      createFlagTool.name,
      createFlagTool.description,
      createFlagTool.paramsSchema as any,
      createFlagTool.handler as any
    );
  • Supporting helper utility that performs the actual HTTP POST request to the Unleash API to create the feature flag, handling payload preparation, logging, and error recovery.
    export async function createFeatureFlag(params: CreateFeatureFlagParams): Promise<any | null> {
      try {
        const payload = {
          name: params.name,
          description: params.description || '',
          type: params.type || 'release',
          impressionData: params.impressionData !== undefined ? params.impressionData : false
        };
    
        logger.info(`Creating feature flag: ${params.name} in project: ${params.project}`);
        
        const response = await client.post(
          `/api/admin/projects/${params.project}/features`,
          payload
        );
        
        logger.info(`Successfully created feature flag: ${params.name}`);
        return response.data;
      } catch (error: any) {
        logger.error(`Error creating feature flag ${params.name}:`, error.response?.data || error.message);
        return null;
      }
    } 
  • Tool definition object exporting the createFlag metadata (name, description, schema, handler) for use in MCP server registration.
    export const createFlagTool = {
      name: "createFlag",
      description: "Create a new feature flag in an Unleash project",
      paramsSchema: CreateFlagParamsSchema,
      handler: handleCreateFlag
    }; 
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a creation operation, implying it's a write/mutation tool, but doesn't mention permission requirements, whether it's idempotent, what happens on duplicate names, or what the response looks like. For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with no wasted words. It's appropriately sized for a basic tool description, though it could benefit from additional context given the complexity of the tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with 5 parameters, 0% schema description coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain what a 'feature flag' or 'Unleash project' is in this context, doesn't document parameters, and provides no behavioral context. The agent would struggle to use this tool correctly without external knowledge.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, so all 5 parameters are undocumented in the schema. The description adds no information about what 'name', 'project', 'description', 'impressionData', or 'type' mean or how they should be used. It doesn't even mention that parameters exist, failing to compensate for the schema's lack of documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create') and resource ('new feature flag in an Unleash project'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'addFeatureTag' or 'updateFlag', but the verb 'Create' implies this is for initial creation rather than modification or tagging.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'updateFlag', 'patchFlag', or 'addFeatureTag'. It doesn't mention prerequisites, such as whether the project must exist first, or clarify that this is for creating flags from scratch rather than modifying existing ones.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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