Skip to main content
Glama
cuongtl1992

Unleash MCP (Feature Toggle)

addStrategy

Define and apply a feature flag strategy for a specific environment within the Unleash MCP server, enabling controlled feature rollouts with constraints and parameters.

Instructions

Add a strategy to a feature flag in a specific environment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
constraintsNo
environmentYes
featureNameYes
parametersNo
projectIdYes
strategyNameYes

Implementation Reference

  • The handler function for the addStrategy tool that executes the logic to add a feature strategy to a flag in Unleash by calling addFeatureStrategy and returning formatted success/error responses.
    export async function handleAddStrategy(params: { projectId: string; featureName: string; environment: string; strategyName: string; parameters?: Record<string, string>; constraints?: Array<{ contextName: string; operator: string; values: string[]; }>; }) { try { // Add the strategy to the feature flag const result = await addFeatureStrategy({ projectId: params.projectId, featureName: params.featureName, environment: params.environment, strategyName: params.strategyName, parameters: params.parameters, constraints: params.constraints }); if (!result) { return { content: [{ type: "text", text: JSON.stringify({ success: false, error: `Failed to add strategy '${params.strategyName}' to feature flag '${params.featureName}'` }, null, 2) }], isError: true }; } return { content: [{ type: "text", text: JSON.stringify({ success: true, message: `Successfully added strategy '${params.strategyName}' to feature flag '${params.featureName}' in environment '${params.environment}'`, strategy: result }, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: JSON.stringify({ success: false, error: error.message }, null, 2) }], isError: true }; } }
  • Zod schema defining the input parameters for the addStrategy tool.
    export const AddStrategyParamsSchema = { projectId: z.string().min(1), featureName: z.string().min(1), environment: z.string().min(1), strategyName: z.string().min(1), parameters: z.record(z.string()).optional(), constraints: z.array(z.object({ contextName: z.string(), operator: z.string(), values: z.array(z.string()) })).optional() };
  • src/server.ts:115-120 (registration)
    Registers the addStrategy tool with the MCP server using server.tool().
    server.tool( addStrategyTool.name, addStrategyTool.description, addStrategyTool.paramsSchema as any, addStrategyTool.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