getFeatureFlag
Retrieve a specific feature flag from an Unleash project to check its status and configuration. Provide the project ID and feature ID to get current flag details.
Instructions
Retrieve a specific feature flag from a project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| featureId | Yes | ||
| projectId | Yes |
Implementation Reference
- src/tools/index.ts:104-120 (handler)Executes the getFeatureFlag tool by parsing parameters with GetFeatureFlagSchema, querying the Unleash API endpoint for the specific feature flag using projectId and featureId, and returning the response data or throwing an error.async function getFeatureFlag(params: z.infer<typeof GetFeatureFlagSchema>) { const { projectId, featureId } = GetFeatureFlagSchema.parse(params); try { const response = await axios.get( `${UNLEASH_API_URL}/api/admin/projects/${projectId}/features/${featureId}`, { headers: { Authorization: `Bearer ${UNLEASH_AUTH_TOKEN}`, }, } ); return response.data; } catch (error) { console.error('Error fetching feature flag:', error); throw error; } }
- src/tools/schema.ts:42-45 (schema)Raw Zod object shape defining the input parameters for getFeatureFlag: projectId and featureId as strings. Used in MCP tool registration.const RawGetFeatureFlagShape = { projectId: z.string(), featureId: z.string(), };
- src/tools/schema.ts:51-51 (schema)Full Zod schema for validating getFeatureFlag input parameters, based on the raw shape. Used in the handler function.const GetFeatureFlagSchema = z.object(RawGetFeatureFlagShape);
- src/index.ts:61-69 (registration)Registers the getFeatureFlag tool on the MCP server with name, description, input schema (RawGetFeatureFlagShape), and an async handler that invokes the core getFeatureFlag function and formats the JSON response.server.tool( 'getFeatureFlag', 'Retrieve a specific feature flag from a project', RawGetFeatureFlagShape, async (args) => { const data = await getFeatureFlag(args); return { content: [{ type: 'text', text: JSON.stringify(data) }] }; } );