Skip to main content
Glama
growthbook

GrowthBook MCP Server

Official
by growthbook

get_projects

Retrieve project data from the GrowthBook API using pagination controls like 'limit' and 'offset' to manage the volume of returned results.

Instructions

Fetches all projects from the GrowthBook API

Input Schema

NameRequiredDescriptionDefault
limitNo
offsetNo

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "limit": { "default": 10, "type": "number" }, "offset": { "default": 0, "type": "number" } }, "type": "object" }

Implementation Reference

  • The core handler function for the 'get_projects' tool. It accepts pagination parameters (limit, offset), fetches the list of projects from the GrowthBook API (/api/v1/projects), handles the response, and returns the data as a formatted JSON string in the expected MCP content format.
    async ({ limit, offset }) => { const queryParams = new URLSearchParams({ limit: limit.toString(), offset: offset.toString(), }); try { const res = await fetch( `${baseApiUrl}/api/v1/projects?${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 projects: ${error}`); } }
  • The direct registration of the 'get_projects' tool using server.tool(), including name, description, input schema (paginationSchema), options (readOnlyHint), and the handler function.
    server.tool( "get_projects", "Fetches all projects from the GrowthBook API", { ...paginationSchema, }, { readOnlyHint: true, }, async ({ limit, offset }) => { const queryParams = new URLSearchParams({ limit: limit.toString(), offset: offset.toString(), }); try { const res = await fetch( `${baseApiUrl}/api/v1/projects?${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 projects: ${error}`); } } );
  • src/index.ts:69-73 (registration)
    Top-level call to registerProjectTools during server initialization, which in turn registers the 'get_projects' tool.
    registerProjectTools({ server, baseApiUrl, apiKey, });
  • The Zod schema used for input validation of the 'get_projects' tool (and others), defining pagination parameters: limit, offset, mostRecent.
    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;

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