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

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {}, "type": "object" }

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}`); } } );

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