Skip to main content
Glama
growthbook

GrowthBook MCP Server

Official
by growthbook

generate_flag_types

Create and manage type definitions for feature flags to improve consistency and organization in flag-based development workflows.

Instructions

Generate types for feature flags

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the generate_flag_types tool. It runs 'npx growthbook auth login' followed by 'npx growthbook features generate-types' in the specified currentWorkingDirectory to generate TypeScript type definitions for feature flags.
      async ({ currentWorkingDirectory }) => {
        function runCommand(command: string, cwd: string): Promise<string> {
          return new Promise((resolve, reject) => {
            exec(command, { cwd }, (error, stdout, stderr) => {
              if (error) {
                reject(stderr || error.message);
              } else {
                resolve(stdout);
              }
            });
          });
        }
        try {
          // Login command
          await runCommand(
            `npx -y growthbook@latest auth login -k ${apiKey} -u ${baseApiUrl} -p default`,
            currentWorkingDirectory
          );
          // Generate types command
          const output = await runCommand(
            `npx -y growthbook@latest features generate-types -u ${baseApiUrl}`,
            currentWorkingDirectory
          );
          return {
            content: [
              {
                type: "text",
                text: `✅ Types generated successfully:\n${output}`,
              },
            ],
          };
        } catch (error: any) {
          throw new Error(`Error generating types: ${error}`);
        }
      }
    );
  • Zod schema for the tool input, defining the currentWorkingDirectory parameter.
    {
      currentWorkingDirectory: z
        .string()
        .describe("The current working directory of the user's project"),
    },
  • Registration of the generate_flag_types tool using server.tool, including description, schema, hints, and handler.
    server.tool(
      "generate_flag_types",
      "Generate types for feature flags",
      {
        currentWorkingDirectory: z
          .string()
          .describe("The current working directory of the user's project"),
      },
      {
        readOnlyHint: false,
        idempotentHint: true,
      },
      async ({ currentWorkingDirectory }) => {
        function runCommand(command: string, cwd: string): Promise<string> {
          return new Promise((resolve, reject) => {
            exec(command, { cwd }, (error, stdout, stderr) => {
              if (error) {
                reject(stderr || error.message);
              } else {
                resolve(stdout);
              }
            });
          });
        }
        try {
          // Login command
          await runCommand(
            `npx -y growthbook@latest auth login -k ${apiKey} -u ${baseApiUrl} -p default`,
            currentWorkingDirectory
          );
          // Generate types command
          const output = await runCommand(
            `npx -y growthbook@latest features generate-types -u ${baseApiUrl}`,
            currentWorkingDirectory
          );
          return {
            content: [
              {
                type: "text",
                text: `✅ Types generated successfully:\n${output}`,
              },
            ],
          };
        } catch (error: any) {
          throw new Error(`Error generating types: ${error}`);
        }
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries full burden. 'Generate types' implies a creation or output operation, but the description doesn't disclose what 'types' refer to (e.g., TypeScript interfaces, JSON schemas), whether this is a read-only or mutating operation, what permissions are needed, or what the output format is. It lacks behavioral context beyond the basic action.

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 with no wasted words. It's front-loaded with the core action and resource, making it easy to parse. Every word earns its place by conveying the essential purpose.

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 no annotations, no output schema, and the description's vagueness about what 'types' are and the tool's behavior, this is incomplete. The agent lacks sufficient information to understand what the tool produces or how to use it effectively in context with sibling tools. It should clarify output format and usage scenarios.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate. A baseline of 4 is applied since the schema fully covers the absence of parameters, and the description doesn't need to compensate.

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 'Generate types for feature flags' clearly states the action (generate) and target resource (types for feature flags). It's specific enough to understand the tool's function, though it doesn't explicitly differentiate from sibling tools like 'get_feature_flags' or 'get_single_feature_flag' which retrieve rather than generate.

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 prerequisites, context, or relationships to sibling tools like 'create_feature_flag' or 'get_feature_flags'. The agent must infer usage from the tool name alone.

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