get_sdk_connections
Retrieve SDK connections to enable apps to fetch features and experiments via a public client key. Specify project, limit, and offset for targeted results.
Instructions
Get all SDK connections, which are how GrowthBook connects to an app. Importantly, users need the key, which is a public client key that allows the app to fetch features and experiments the API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No | ||
| project | No |
Implementation Reference
- src/tools/sdk-connections.ts:30-61 (handler)The handler function that executes the get_sdk_connections tool logic: constructs query params with optional project filter and pagination, fetches from GrowthBook API, handles response, and returns JSON data.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/sdk-connections?${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 sdk connections: ${error}`); } }
- src/tools/sdk-connections.ts:20-26 (schema)Input schema using Zod: optional project ID and pagination parameters (limit, offset).{ project: z .string() .describe("The ID of the project to filter SDK connections by") .optional(), ...paginationSchema, },
- src/tools/sdk-connections.ts:17-62 (registration)Direct registration of the get_sdk_connections tool on the MCP server, including description, input schema, options, and inline handler function.server.tool( "get_sdk_connections", "Get all SDK connections. SDK connections are how GrowthBook connects to an app. Users need the client key to fetch features and experiments from the API.", { project: z .string() .describe("The ID of the project to filter SDK connections by") .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/sdk-connections?${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 sdk connections: ${error}`); } } );
- src/index.ts:75-79 (registration)Top-level call to registerSdkConnectionTools in the main index.ts, which registers the get_sdk_connections tool among others.registerSdkConnectionTools({ server, baseApiUrl, apiKey, });