validateFeatureName
Check if a feature flag name is valid and available within the Unleash MCP (Feature Toggle) system by entering the desired name and receiving confirmation.
Instructions
Validate if a feature flag name is valid and available for use
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| featureName | Yes | Name of the feature flag to validate |
Implementation Reference
- src/tools/validate-feature-name.ts:18-62 (handler)The main handler function for the validateFeatureName tool, which calls the validation logic and formats the MCP response.export async function handleValidateFeatureName({ featureName }: { featureName: string }) { try { // Validate the feature name const result = await validateFeatureName(featureName); if (!result.isValid) { return { content: [{ type: "text", text: JSON.stringify({ success: false, featureName, valid: false, error: result.error }, null, 2) }], isError: false // This is not a tool error, just a validation result }; } return { content: [{ type: "text", text: JSON.stringify({ success: true, featureName, valid: true, message: `Feature name '${featureName}' is valid and available for use` }, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: JSON.stringify({ success: false, featureName, error: error.message || 'An unknown error occurred' }, null, 2) }], isError: true }; } }
- Zod schema defining the input parameters for the validateFeatureName tool.export const ValidateFeatureNameParamsSchema = { featureName: z.string().describe('Name of the feature flag to validate') };
- src/server.ts:164-169 (registration)Registers the validateFeatureName tool with the MCP server.server.tool( validateFeatureNameTool.name, validateFeatureNameTool.description, validateFeatureNameTool.paramsSchema as any, validateFeatureNameTool.handler as any );
- Core validation logic that interacts with the Unleash API to check feature name validity, used by the tool handler.export async function validateFeatureName(featureName: string): Promise<FeatureNameValidationResult> { try { await client.post('/api/admin/features/validate', { name: featureName }); logger.info(`Feature name '${featureName}' is valid`); return { isValid: true }; } catch (error: any) { logger.error(`Error validating feature name '${featureName}':`, error); let errorMessage = 'An unknown error occurred during validation'; if (error.response) { const { status } = error.response; if (status === 400) { errorMessage = 'Feature name is not URL friendly'; } else if (status === 409) { errorMessage = 'Feature name already exists'; } else if (status === 415) { errorMessage = 'Unsupported media type'; } } return { isValid: false, error: errorMessage }; } }
- src/tools/validate-feature-name.ts:67-72 (registration)Defines and exports the validateFeatureNameTool object for use in server registration.export const validateFeatureNameTool = { name: "validateFeatureName", description: "Validate if a feature flag name is valid and available for use", paramsSchema: ValidateFeatureNameParamsSchema, handler: handleValidateFeatureName };