Skip to main content
Glama
growthbook

GrowthBook MCP Server

Official
by growthbook

get_feature_flags

Retrieve all feature flags from the GrowthBook API, sorted by creation date. Configure limit, offset, and project filters to tailor the fetched data to your needs.

Instructions

Fetches all feature flags from the GrowthBook API. Flags are returned in the order they were created, from oldest to newest.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
offsetNo
projectNo

Implementation Reference

  • The handler function that implements the logic for fetching feature flags from the GrowthBook API, supporting pagination (limit, offset) and project filtering.
    async ({ limit, offset, project }) => { try { const queryParams = new URLSearchParams({ limit: limit?.toString(), offset: offset?.toString(), }); if (project) { queryParams.append("projectId", project); } 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(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { throw new Error(`Error fetching flags: ${error}`); } }
  • The server.tool call that registers the 'get_feature_flags' tool, specifying its name, description, input schema, read-only hint, and handler function.
    server.tool( "get_feature_flags", "Fetches all feature flags from the GrowthBook API, with optional limit, offset, and project filtering.", { project: featureFlagSchema.project.optional(), ...paginationSchema, }, { readOnlyHint: true, }, async ({ limit, offset, project }) => { try { const queryParams = new URLSearchParams({ limit: limit?.toString(), offset: offset?.toString(), }); if (project) { queryParams.append("projectId", project); } 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(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { throw new Error(`Error fetching flags: ${error}`); } } );
  • The paginationSchema defining limit, offset, and mostRecent parameters used in the get_feature_flags tool schema.
    export const paginationSchema = { limit: z .number() .min(1) .max(100) .default(100) .describe("The number of items to fetch (1-100)"), offset: z .number() .min(0) .default(0) .describe( "The number of items to skip. For example, set to 100 to fetch the second page with default limit. Note: The API returns items in chronological order (oldest first) by default." ), mostRecent: z .boolean() .default(false) .describe( "When true, fetches the most recent items and returns them newest-first. When false (default), returns oldest items first." ), } as const;
  • The 'project' field from featureFlagSchema used optionally in the get_feature_flags tool input schema.
    project: z .string() .describe("The ID of the project to which the feature flag belongs"), // Contextual info
  • src/index.ts:81-87 (registration)
    High-level registration of feature tools (including get_feature_flags) via registerFeatureTools in the main MCP server setup.
    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