getFeatureTypes
Retrieve a comprehensive list of feature types, including descriptions and lifetimes, for effective management within the Unleash Feature Toggle system.
Instructions
Get a list of all feature types with their descriptions and lifetimes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get-feature-types.ts:6-46 (handler)The main handler function for the getFeatureTypes tool, which fetches all feature types using getAllFeatureTypes and returns them as JSON or error.async function handleGetFeatureTypes() { try { // Get all feature types const featureTypes = await getAllFeatureTypes(); if (!featureTypes) { return { content: [{ type: "text", text: JSON.stringify({ success: false, error: "Failed to fetch feature types" }, null, 2) }], isError: true }; } return { content: [{ type: "text", text: JSON.stringify({ success: true, count: featureTypes.length, featureTypes: featureTypes }, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: JSON.stringify({ success: false, error: error.message }, null, 2) }], isError: true }; } }
- src/tools/get-feature-types.ts:51-55 (schema)Tool schema/definition exporting the name, description, and handler for getFeatureTypes (no input parameters).export const getFeatureTypes = { name: "getFeatureTypes", description: "Get a list of all feature types with their descriptions and lifetimes", handler: handleGetFeatureTypes };
- src/server.ts:183-187 (registration)Registration of the getFeatureTypes tool on the MCP server using server.tool().server.tool( getFeatureTypes.name, getFeatureTypes.description, getFeatureTypes.handler as any );
- Helper function that fetches all feature types from the Unleash API via HTTP GET request.export async function getAllFeatureTypes(): Promise<any[] | null> { try { const response = await client.get('/api/admin/feature-types'); return response.data || []; } catch (error) { logger.error('Error fetching feature types:', error); return null; } }