Skip to main content
Glama
growthbook

GrowthBook MCP Server

Official
by growthbook

create_sdk_connection

Generate an SDK connection for GrowthBook to fetch features and experiments. Specify the SDK language, environment, and name to create a client key.

Instructions

Create an SDK connection for a user. Returns an SDK clientKey that can be used to fetch features and experiments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentNoThe environment associated with the SDK connection.
languageYesThe language of the SDK. Either 'javascript' or 'typescript'.
nameYesName of the SDK connection in GrowthBook. Should reflect the current project.

Implementation Reference

  • Handler function for the create_sdk_connection tool. If no environment is provided, it lists available environments. Otherwise, it creates a new SDK connection by POSTing to the GrowthBook API.
    async ({ name, language, environment, projects }) => {
      if (!environment) {
        try {
          const res = await fetch(`${baseApiUrl}/api/v1/environments`, {
            headers: {
              Authorization: `Bearer ${apiKey}`,
              "Content-Type": "application/json",
            },
          });
    
          await handleResNotOk(res);
          const data = await res.json();
          const text = `${JSON.stringify(data, null, 2)}
    
        Here is the list of environments. Ask the user to select one and use the key in the create_sdk_connection tool.
        `;
    
          return {
            content: [{ type: "text", text }],
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error: ${error}` }],
          };
        }
      }
    
      const payload = {
        name,
        language,
        environment,
        ...(projects && { projects }),
      };
    
      try {
        const res = await fetch(`${baseApiUrl}/api/v1/sdk-connections`, {
          method: "POST",
          headers: {
            Authorization: `Bearer ${apiKey}`,
            "Content-Type": "application/json",
          },
          body: JSON.stringify(payload),
        });
    
        await handleResNotOk(res);
    
        const data = await res.json();
    
        return {
          content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
        };
      } catch (error) {
        throw new Error(`Error creating sdk connection: ${error}`);
      }
    }
  • Zod input schema for create_sdk_connection tool defining parameters: name (string), language (enum of platforms), environment (optional string), projects (optional array of strings).
    {
      name: z
        .string()
        .describe(
          "Name of the SDK connection in GrowthBook. Should reflect the current project."
        ),
      language: z
        .enum([
          "nocode-webflow",
          "nocode-wordpress",
          "nocode-shopify",
          "nocode-other",
          "javascript",
          "nodejs",
          "react",
          "php",
          "ruby",
          "python",
          "go",
          "java",
          "csharp",
          "android",
          "ios",
          "flutter",
          "elixir",
          "edge-cloudflare",
          "edge-fastly",
          "edge-lambda",
          "edge-other",
          "other",
        ])
        .describe("The language or platform for the SDK connection."),
      environment: z
        .string()
        .optional()
        .describe("The environment associated with the SDK connection."),
      projects: z
        .array(z.string())
        .describe("The projects to create the SDK connection in")
        .optional(),
    },
  • Direct registration of the create_sdk_connection tool using server.tool, including name, description, schema, options, and handler.
    server.tool(
      "create_sdk_connection",
      `Create an SDK connection for a user. Returns an SDK clientKey that can be used to fetch features and experiments.`,
      {
        name: z
          .string()
          .describe(
            "Name of the SDK connection in GrowthBook. Should reflect the current project."
          ),
        language: z
          .enum([
            "nocode-webflow",
            "nocode-wordpress",
            "nocode-shopify",
            "nocode-other",
            "javascript",
            "nodejs",
            "react",
            "php",
            "ruby",
            "python",
            "go",
            "java",
            "csharp",
            "android",
            "ios",
            "flutter",
            "elixir",
            "edge-cloudflare",
            "edge-fastly",
            "edge-lambda",
            "edge-other",
            "other",
          ])
          .describe("The language or platform for the SDK connection."),
        environment: z
          .string()
          .optional()
          .describe("The environment associated with the SDK connection."),
        projects: z
          .array(z.string())
          .describe("The projects to create the SDK connection in")
          .optional(),
      },
      {
        readOnlyHint: false,
        destructiveHint: false,
      },
      async ({ name, language, environment, projects }) => {
        if (!environment) {
          try {
            const res = await fetch(`${baseApiUrl}/api/v1/environments`, {
              headers: {
                Authorization: `Bearer ${apiKey}`,
                "Content-Type": "application/json",
              },
            });
    
            await handleResNotOk(res);
            const data = await res.json();
            const text = `${JSON.stringify(data, null, 2)}
      
          Here is the list of environments. Ask the user to select one and use the key in the create_sdk_connection tool.
          `;
    
            return {
              content: [{ type: "text", text }],
            };
          } catch (error) {
            return {
              content: [{ type: "text", text: `Error: ${error}` }],
            };
          }
        }
    
        const payload = {
          name,
          language,
          environment,
          ...(projects && { projects }),
        };
    
        try {
          const res = await fetch(`${baseApiUrl}/api/v1/sdk-connections`, {
            method: "POST",
            headers: {
              Authorization: `Bearer ${apiKey}`,
              "Content-Type": "application/json",
            },
            body: JSON.stringify(payload),
          });
    
          await handleResNotOk(res);
    
          const data = await res.json();
    
          return {
            content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
          };
        } catch (error) {
          throw new Error(`Error creating sdk connection: ${error}`);
        }
      }
    );
  • src/index.ts:75-79 (registration)
    Top-level registration call in main index file that invokes registerSdkConnectionTools to add the create_sdk_connection tool to the MCP server.
    registerSdkConnectionTools({
      server,
      baseApiUrl,
      apiKey,
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions the return value (clientKey) and its purpose, but lacks details on permissions, side effects, error conditions, or rate limits. For a creation tool with zero annotation coverage, this leaves significant gaps in understanding its operational behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in two sentences: one stating the action and resource, and another explaining the return value. It's front-loaded with the core purpose and avoids unnecessary elaboration, though it could be slightly more concise by integrating the return value into the first sentence.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description provides basic purpose and return value context but lacks completeness for a creation tool. It doesn't cover error handling, authentication needs, or system impacts. While it meets minimum viability, there are clear gaps in contextual information needed for reliable tool invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing clear documentation for all parameters. The description adds no additional parameter semantics beyond what's in the schema, such as explaining relationships between parameters or usage nuances. Baseline score of 3 is appropriate since the schema adequately covers parameter details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Create' and resource 'SDK connection for a user', specifying that it returns a 'clientKey' for fetching features and experiments. It distinguishes from siblings like 'get_sdk_connections' (read vs. create) but doesn't explicitly differentiate from other creation tools like 'create_feature_flag' or 'create_force_rule'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites, appropriate contexts, or comparisons with sibling tools like 'get_sdk_connections' or other creation tools. The description only states what it does, not when to choose it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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