getFeatureFlag
Retrieve a specific feature flag by ID from the Bucketeer MCP Server to manage feature configurations and enable/disable functionality.
Instructions
Get a specific feature flag by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the feature flag to retrieve | |
| environmentId | No | Environment ID (uses default if not provided) | |
| featureVersion | No | Specific version of the feature to retrieve |
Implementation Reference
- src/tools/get-flag.ts:37-119 (handler)The core handler function for the 'getFeatureFlag' tool. It validates the input using Zod schema, initializes the BucketeerClient, makes an API request to retrieve the feature flag, logs the operation, and returns a structured MCP response (success or error).handler: async (input: unknown) => { try { // Validate input const params = getFlagSchema.parse(input); logger.debug("Getting feature flag", params); // Create API client const client = new BucketeerClient( config.bucketeerHost, config.bucketeerApiKey, ); // Prepare request const request: GetFeatureRequest = { id: params.id, environmentId: getEnvironmentId(params.environmentId), featureVersion: params.featureVersion, }; // Make API call const response = await client.getFeature(request); logger.info( `Successfully retrieved feature flag: ${response.feature.id}`, ); return { content: [ { type: "text", text: JSON.stringify( { success: true, feature: response.feature, }, null, 2, ), }, ], }; } catch (error) { logger.error("Failed to get feature flag", error); if (error instanceof z.ZodError) { return { content: [ { type: "text", text: JSON.stringify( { success: false, error: "Invalid input parameters", details: error.issues, }, null, 2, ), }, ], isError: true, }; } return { content: [ { type: "text", text: JSON.stringify( { success: false, error: error instanceof Error ? error.message : "Unknown error", }, null, 2, ), }, ], isError: true, }; } },
- src/tools/get-flag.ts:8-12 (schema)Zod input schema used for validating the parameters in the getFeatureFlag handler.export const getFlagSchema = z.object({ id: z.string().min(1, "Feature flag ID is required"), environmentId: z.string().optional(), featureVersion: z.number().optional(), });
- src/tools/get-flag.ts:19-36 (schema)JSON schema definition for the input of the getFeatureFlag tool, used by MCP for tool listing and validation.inputSchema: { type: "object" as const, properties: { id: { type: "string", description: "The ID of the feature flag to retrieve", }, environmentId: { type: "string", description: "Environment ID (uses default if not provided)", }, featureVersion: { type: "number", description: "Specific version of the feature to retrieve", }, }, required: ["id"], },
- src/tools/index.ts:7-13 (registration)The getFlagTool (containing getFeatureFlag) is registered in the central tools array exported for use by the MCP server.export const tools = [ listFlagsTool, createFlagTool, getFlagTool, updateFlagTool, archiveFlagTool, ];
- src/server.ts:8-8 (registration)Import of the tools array (including getFeatureFlag) into the MCP server for handling listTools and callTool requests.import { tools } from "./tools/index.js";