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
| Name | Required | Description | Default |
|---|---|---|---|
| flagName | Yes |
Implementation Reference
- src/tools/get-flag.ts:18-61 (handler)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 }; } }
- src/tools/get-flag.ts:11-13 (schema)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 );
- src/tools/get-flag.ts:66-71 (helper)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 };