Skip to main content
Glama
growthbook

GrowthBook MCP Server

Official
by growthbook

get_stale_safe_rollouts

Retrieve all completed safe rollouts, whether rolled back or released, from the GrowthBook API. Supports filtering by project and pagination for efficient data handling.

Instructions

Fetches all complete safe rollouts (rolled-back or released) from the GrowthBook API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
offsetNo
projectNo

Implementation Reference

  • The handler function fetches all feature flags using pagination, filters for those containing safe-rollout rules that are either 'rolled-back' or 'released', constructs a response text explaining the findings and suggesting cleanup actions, and returns it as a text content block.
    async ({ limit, offset }) => { try { const queryParams = new URLSearchParams({ limit: limit?.toString(), offset: offset?.toString(), }); const res = await fetch( `${baseApiUrl}/api/v1/features?${queryParams.toString()}`, { headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", }, } ); await handleResNotOk(res); const data = await res.json(); const filteredSafeRollouts = data.features.filter((feature: any) => { const envs: Record<string, any> = feature.environments; if (!envs) return false; return Object.values(envs).some((env: any) => { const rules = env.rules; if (!rules) return false; return rules.some((rule: any) => { return ( rule.type === "safe-rollout" && (rule.status === "rolled-back" || rule.status === "released") ); }); }); }); const text = ` ${JSON.stringify(filteredSafeRollouts, null, 2)} Share information about the rolled-back or released safe rollout rules with the user. Safe Rollout rules are stored under environmentSettings, keyed by environment and are within the rules array with a type of "safe-rollout". Ask the user if they would like to remove references to the feature associated with the rolled-back or released safe rollout rules and if they do, remove the references and associated GrowthBook code and replace the values with controlValue if the safe rollout rule is rolled-back or with the variationValue if the safe rollout is released. In addition to the current file, you may need to update other files in the codebase. `; return { content: [{ type: "text", text }], }; } catch (error) { throw new Error(`Error fetching stale safe rollouts: ${error}`); } } );
  • Input schema using Zod for optional limit (default 100) and offset (default 0) parameters for pagination.
    { limit: z.number().optional().default(100), offset: z.number().optional().default(0), },
  • Registers the tool 'get_stale_safe_rollouts' with server.tool, providing name, description, input schema, read-only hint, and the handler function. This is called within registerFeatureTools.
    server.tool( "get_stale_safe_rollouts", "Fetches all complete safe rollouts (rolled-back or released) from the GrowthBook API", { limit: z.number().optional().default(100), offset: z.number().optional().default(0), }, { readOnlyHint: true, }, async ({ limit, offset }) => { try { const queryParams = new URLSearchParams({ limit: limit?.toString(), offset: offset?.toString(), }); const res = await fetch( `${baseApiUrl}/api/v1/features?${queryParams.toString()}`, { headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", }, } ); await handleResNotOk(res); const data = await res.json(); const filteredSafeRollouts = data.features.filter((feature: any) => { const envs: Record<string, any> = feature.environments; if (!envs) return false; return Object.values(envs).some((env: any) => { const rules = env.rules; if (!rules) return false; return rules.some((rule: any) => { return ( rule.type === "safe-rollout" && (rule.status === "rolled-back" || rule.status === "released") ); }); }); }); const text = ` ${JSON.stringify(filteredSafeRollouts, null, 2)} Share information about the rolled-back or released safe rollout rules with the user. Safe Rollout rules are stored under environmentSettings, keyed by environment and are within the rules array with a type of "safe-rollout". Ask the user if they would like to remove references to the feature associated with the rolled-back or released safe rollout rules and if they do, remove the references and associated GrowthBook code and replace the values with controlValue if the safe rollout rule is rolled-back or with the variationValue if the safe rollout is released. In addition to the current file, you may need to update other files in the codebase. `; return { content: [{ type: "text", text }], }; } catch (error) { throw new Error(`Error fetching stale safe rollouts: ${error}`); } } );
  • src/index.ts:81-87 (registration)
    Calls registerFeatureTools in the main index.ts, which registers the get_stale_safe_rollouts tool among others.
    registerFeatureTools({ server, baseApiUrl, apiKey, appOrigin, user, });

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