Skip to main content
Glama
growthbook

GrowthBook MCP Server

Official
by growthbook

get_single_feature_flag

Retrieve a specific feature flag from the GrowthBook API by providing its unique ID and project details, enabling targeted feature management.

Instructions

Fetches a specific feature flag from the GrowthBook API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the feature flag
projectNo

Implementation Reference

  • Handler function that fetches a specific feature flag by ID from the GrowthBook API, processes the response, generates a GrowthBook link, and returns formatted text content including instructions for the user.
    async ({ id }) => {
      try {
        const res = await fetch(`${baseApiUrl}/api/v1/features/${id}`, {
          headers: {
            Authorization: `Bearer ${apiKey}`,
            "Content-Type": "application/json",
          },
        });
    
        await handleResNotOk(res);
    
        const data = await res.json();
        const linkToGrowthBook = generateLinkToGrowthBook(
          appOrigin,
          "features",
          id
        );
        const text = `
        ${JSON.stringify(data.feature, null, 2)}
    
        Share information about the feature flag with the user. In particular, give details about the enabled environments,
        rules for each environment, and the default value. If the feature flag is archived or doesnt exist, inform the user and
        ask if they want to remove references to the feature flag from the codebase.
    
        [View it in GrowthBook](${linkToGrowthBook})
        `;
    
        return {
          content: [{ type: "text", text }],
        };
      } catch (error) {
        throw new Error(`Error fetching flags: ${error}`);
      }
    }
  • Zod schema definition for feature flag properties, including 'id' used as input schema for the get_single_feature_flag tool.
    export const featureFlagSchema = {
      id: z
        .string()
        .regex(
          /^[a-zA-Z0-9_.:|_-]+$/,
          "Feature key can only include letters, numbers, and the characters _, -, ., :, and |"
        )
        .describe("A unique key name for the feature"),
      valueType: z
        .enum(["string", "number", "boolean", "json"])
        .describe("The value type the feature flag will return"),
      defaultValue: z.string().describe("The default value of the feature flag"),
      description: z.string().describe("A brief description of the feature flag"),
      archived: z.boolean().describe("Whether the feature flag should be archived"),
      project: z
        .string()
        .describe("The ID of the project to which the feature flag belongs"),
      // Contextual info
      fileExtension: z
        .enum(SUPPORTED_FILE_EXTENSIONS)
        .describe(
          "The extension of the current file. If it's unclear, ask the user."
        ),
    } as const;
  • Registration of the get_single_feature_flag tool using server.tool, including description, input schema, options, and handler reference.
    server.tool(
      "get_single_feature_flag",
      "Fetches a specific feature flag from the GrowthBook API",
      {
        id: featureFlagSchema.id,
      },
      {
        readOnlyHint: true,
      },
      async ({ id }) => {
        try {
          const res = await fetch(`${baseApiUrl}/api/v1/features/${id}`, {
            headers: {
              Authorization: `Bearer ${apiKey}`,
              "Content-Type": "application/json",
            },
          });
    
          await handleResNotOk(res);
    
          const data = await res.json();
          const linkToGrowthBook = generateLinkToGrowthBook(
            appOrigin,
            "features",
            id
          );
          const text = `
          ${JSON.stringify(data.feature, null, 2)}
    
          Share information about the feature flag with the user. In particular, give details about the enabled environments,
          rules for each environment, and the default value. If the feature flag is archived or doesnt exist, inform the user and
          ask if they want to remove references to the feature flag from the codebase.
    
          [View it in GrowthBook](${linkToGrowthBook})
          `;
    
          return {
            content: [{ type: "text", text }],
          };
        } catch (error) {
          throw new Error(`Error fetching flags: ${error}`);
        }
      }
    );
  • src/index.ts:81-87 (registration)
    Top-level registration call to registerFeatureTools which includes the get_single_feature_flag tool among others.
    registerFeatureTools({
      server,
      baseApiUrl,
      apiKey,
      appOrigin,
      user,
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it 'fetches' data, implying a read-only operation, but doesn't clarify authentication requirements, rate limits, error handling, or the format of the returned data. For a tool with no annotations, this leaves significant gaps in understanding how it behaves in practice.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the key action and resource, making it easy to parse. Every part of the sentence earns its place by conveying essential information succinctly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a read operation with 2 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what data is returned, how errors are handled, or dependencies like authentication. For a tool that fetches specific data, more context is needed to ensure reliable use by an agent, especially with siblings that might overlap in functionality.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 50%, with the 'id' parameter documented but 'project' lacking a description. The tool description mentions 'a specific feature flag', which aligns with the 'id' parameter, but doesn't add meaning beyond what the schema provides for 'id' or clarify the role of 'project'. Since coverage is moderate, the description doesn't fully compensate but doesn't worsen the gap, resulting in a baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('fetches') and resource ('a specific feature flag from the GrowthBook API'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_feature_flags' (plural) or 'get_experiment', which might retrieve similar data. The specificity of 'single' in the tool name helps, but the description could be more explicit about this distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_feature_flags' for listing multiple flags or 'get_experiment' for related data, nor does it specify prerequisites such as needing a project context. Without this context, an agent might struggle to choose between similar tools in the server.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/growthbook/growthbook-mcp'

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