Skip to main content
Glama
growthbook

GrowthBook MCP Server

Official
by growthbook

get_environments

Retrieve all environments from the GrowthBook API to manage feature flags, set default feature states, and scope environments for specific projects.

Instructions

Fetches all environments from the GrowthBook API. GrowthBook comes with one environment by default (production), but you can add as many as you need. Feature flags can be enabled and disabled on a per-environment basis. You can also set the default feature state for any new environment. Additionally, you can scope environments to only be available in specific projects, allowing for further control and segmentation over feature delivery.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that performs the actual work of fetching all environments from the GrowthBook API using fetch and returns the JSON response formatted as text.
      async () => {
        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();
          return {
            content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
          };
        } catch (error) {
          throw new Error(`Error fetching environments: ${error}`);
        }
      }
    );
  • Registers the "get_environments" tool on the MCP server, including name, detailed description, empty input schema, read-only hint, and inline handler function.
    server.tool(
      "get_environments",
      "Fetches all environments from the GrowthBook API. GrowthBook comes with one environment by default (production), but you can add as many as you need. Feature flags can be enabled and disabled on a per-environment basis. You can also set the default feature state for any new environment. Additionally, you can scope environments to only be available in specific projects, allowing for further control and segmentation over feature delivery.",
      {},
      {
        readOnlyHint: true,
      },
      async () => {
        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();
          return {
            content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
          };
        } catch (error) {
          throw new Error(`Error fetching environments: ${error}`);
        }
      }
    );
  • src/index.ts:63-67 (registration)
    Invokes registerEnvironmentTools to perform the tool registration for get_environments (and possibly others) in the main application entry point.
    registerEnvironmentTools({
      server,
      baseApiUrl,
      apiKey,
    });
  • Empty input schema (no parameters required) for the get_environments tool.
    {},
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'fetches all environments,' implying a read-only operation, but doesn't clarify key behaviors such as authentication requirements, rate limits, error handling, or the format of the returned data. The additional context about GrowthBook environments is informative but doesn't address operational traits needed for reliable tool invocation.

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

Conciseness3/5

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

The description is moderately concise but could be more front-loaded. The first sentence clearly states the purpose, but the following sentences provide general background about GrowthBook environments that, while informative, may not be essential for tool selection. This extra context adds length without directly aiding in tool invocation, reducing efficiency.

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 the tool's simplicity (0 parameters, no annotations, no output schema), the description is somewhat complete but has gaps. It explains what the tool does and provides context about environments, which helps understanding. However, it lacks details on behavioral aspects like response format or error conditions, which are important for a tool with no structured output schema, leaving room for improvement.

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

Parameters4/5

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

The tool has 0 parameters, and the schema description coverage is 100%, so there's no need for parameter documentation in the description. The description appropriately avoids discussing parameters, focusing instead on the tool's purpose and context. This meets the baseline for tools with no parameters, though it doesn't add value beyond the schema.

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 tool's purpose: 'Fetches all environments from the GrowthBook API.' It uses a specific verb ('fetches') and resource ('environments'), making the action explicit. However, it doesn't distinguish this tool from potential siblings like 'get_projects' or 'get_feature_flags' beyond the resource name, which keeps it from a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. It explains what environments are in GrowthBook (e.g., default production environment, per-environment flag control, project scoping), but this is background information rather than usage instructions. There's no mention of prerequisites, when this tool is appropriate, or what other tools might be better for related tasks.

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