Skip to main content
Glama
cuongtl1992

Unleash MCP (Feature Toggle)

getProjectFeature

Retrieve detailed information about a specific feature flag within a project using the Unleash MCP Server, enabling precise management of feature toggles.

Instructions

Get detailed information about a feature flag in a specific project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
featureNameYesName of the feature flag
projectIdYesID of the project

Implementation Reference

  • Handler function that executes the getProjectFeature tool logic: calls the Unleash helper, handles errors, and formats the response as MCP content.
    export async function handleGetProjectFeature({ projectId, featureName }: { projectId: string, featureName: string }) {
      try {
        // Get the feature flag from the project
        const feature = await getProjectFeature(projectId, featureName);
        
        if (!feature) {
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify({ 
                success: false,
                projectId,
                featureName,
                error: `Feature '${featureName}' not found in project '${projectId}'` 
              }, null, 2)
            }],
            isError: true
          };
        }
        
        const statusInfo = feature.enabled !== undefined 
          ? `The ${featureName} flag is currently ${feature.enabled ? 'enabled' : 'disabled'}.` 
          : '';
        
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify({ 
              success: true,
              feature,
              summary: `Feature '${featureName}' in project '${projectId}' retrieved successfully. ${statusInfo}`
            }, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify({ 
              success: false,
              projectId,
              featureName,
              error: error.message || 'An unknown error occurred'
            }, null, 2)
          }],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for the getProjectFeature tool: projectId and featureName.
    export const GetProjectFeatureParamsSchema = {
      projectId: z.string().describe('ID of the project'),
      featureName: z.string().describe('Name of the feature flag')
    };
  • src/server.ts:151-155 (registration)
    Registration of the getProjectFeature tool on the MCP server using server.tool().
      getProjectFeatureTool.name,
      getProjectFeatureTool.description,
      getProjectFeatureTool.paramsSchema as any,
      getProjectFeatureTool.handler as any
    );
  • Supporting function that performs the actual API request to retrieve a specific feature flag from Unleash.
    export async function getProjectFeature(projectId: string, featureName: string): Promise<any | null> {
      try {
        const response = await client.get(`/api/admin/projects/${projectId}/features/${featureName}`);
        logger.info(`Successfully fetched feature ${featureName} from project ${projectId}`);
        return response.data;
      } catch (error: any) {
        logger.error(`Error fetching feature ${featureName} from project ${projectId}:`, error);
        if (error.response && error.response.status === 404) {
          logger.info(`Feature ${featureName} not found in project ${projectId}`);
          return null;
        }
        throw error;
      }
    } 

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cuongtl1992/unleash-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server