Skip to main content
Glama
cuongtl1992

Unleash MCP (Feature Toggle)

getProjectFeatures

Retrieve all feature toggles for a specific project from Unleash MCP, enabling centralized management and visibility of feature configurations.

Instructions

Get all features for a specific project from the Unleash repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYes

Implementation Reference

  • The handler function that executes the tool logic: fetches project features using the helper function and returns formatted JSON response or error.
    export async function handleGetProjectFeatures(params: {
      projectId: string;
    }) {
      try {
        // Get the project features
        const features = await getProjectFeatures(params.projectId);
        
        if (!features) {
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify({ 
                success: false,
                error: `Failed to fetch features for project '${params.projectId}'` 
              }, null, 2)
            }],
            isError: true
          };
        }
        
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify({ 
              success: true,
              message: `Successfully fetched features for project '${params.projectId}'`,
              features: features
            }, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify({ 
              success: false,
              error: error.message 
            }, null, 2)
          }],
          isError: true
        };
      }
    }
  • Input schema validation using Zod for the projectId parameter.
    export const GetProjectFeaturesParamsSchema = {
      projectId: z.string().min(1)
    };
  • src/server.ts:143-148 (registration)
    Registration of the getProjectFeatures tool in the MCP server using server.tool().
    server.tool(
      getProjectFeaturesTool.name,
      getProjectFeaturesTool.description,
      getProjectFeaturesTool.paramsSchema as any,
      getProjectFeaturesTool.handler as any
    );
  • Helper function that performs the actual API call to retrieve project features from Unleash.
    export async function getProjectFeatures(projectId: string): Promise<any[] | null> {
      try {
        const response = await client.get(`/api/admin/projects/${projectId}/features`);
        logger.info(`Successfully fetched features for project ${projectId}`);
        return response.data.features || response.data;
      } catch (error) {
        logger.error(`Error fetching features for project ${projectId}:`, error);
        return null;
      }
    } 

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