Skip to main content
Glama
cuongtl1992

Unleash MCP (Feature Toggle)

getFlag

Retrieve detailed information about a specific feature flag in the Unleash MCP server to manage and understand feature toggle configurations.

Instructions

Get detailed information about a feature flag

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
flagNameYes

Implementation Reference

  • The main handler function that implements the core logic of the 'getFlag' tool. It retrieves feature flag details using getFeatureFlag, handles errors, and returns a structured JSON response.
    export async function handleGetFlag({ flagName }: { flagName: string }) {
      try {
        // Get the feature flag
        const flag = await getFeatureFlag(flagName);
        
        if (!flag) {
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify({ 
                success: false,
                flagName,
                error: `Feature flag '${flagName}' not found` 
              }, null, 2)
            }],
            isError: true
          };
        }
        
        const summary = `The ${flagName} flag is currently ${flag.enabled ? 'enabled' : 'disabled'}.`;
        
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify({ 
              flag,
              summary
            }, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify({ 
              success: false,
              flagName,
              error: error.message 
            }, null, 2)
          }],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for the getFlag tool, specifically the required 'flagName' string parameter.
    export const GetFlagParamsSchema = {
      flagName: z.string()
    };
  • src/server.ts:87-92 (registration)
    The registration of the getFlag tool on the MCP server instance using server.tool(), referencing the tool's name, description, schema, and handler.
    server.tool(
      getFlagTool.name,
      getFlagTool.description,
      getFlagTool.paramsSchema as any,
      getFlagTool.handler as any
    );
  • The tool definition object that bundles the name, description, schema, and handler for easy import and registration.
    export const getFlagTool = {
      name: "getFlag",
      description: "Get detailed information about a feature flag",
      paramsSchema: GetFlagParamsSchema,
      handler: handleGetFlag
    }; 

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