Skip to main content
Glama
growthbook

GrowthBook MCP Server

Official
by growthbook

get_experiment

Retrieve a specific experiment by its ID from the GrowthBook MCP Server to access detailed information and insights.

Instructions

Gets a single experiment from GrowthBook

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
experimentIdYesThe ID of the experiment to get

Implementation Reference

  • The handler function fetches the experiment by ID from the GrowthBook API. If mode is 'analyze', it also fetches results. It generates a GrowthBook link and returns the data as formatted text.
    async ({ experimentId, mode }) => {
      try {
        const res = await fetch(
          `${baseApiUrl}/api/v1/experiments/${experimentId}`,
          {
            headers: {
              Authorization: `Bearer ${apiKey}`,
              "Content-Type": "application/json",
            },
          }
        );
    
        await handleResNotOk(res);
        const data = await res.json();
    
        // If analyze mode, fetch results
        if (mode === "analyze") {
          try {
            const resultsRes = await fetch(
              `${baseApiUrl}/api/v1/experiments/${experimentId}/results`,
              {
                headers: {
                  Authorization: `Bearer ${apiKey}`,
                },
              }
            );
            await handleResNotOk(resultsRes);
            const resultsData = await resultsRes.json();
            data.result = resultsData.result;
          } catch (error) {
            console.error(
              `Error fetching results for experiment ${experimentId}`,
              error
            );
          }
        }
    
        const linkToGrowthBook = generateLinkToGrowthBook(
          appOrigin,
          "experiment",
          experimentId
        );
        const text = `
    ${JSON.stringify(data, null, 2)}
    
    [View the experiment in GrowthBook](${linkToGrowthBook})
    `;
    
        return {
          content: [{ type: "text", text }],
        };
      } catch (error) {
        throw new Error(`Error getting experiment: ${error}`);
      }
    }
  • Zod schema defining the input parameters for the get_experiment tool: experimentId (string) and optional mode ("default" or "analyze").
    {
      experimentId: z.string().describe("The ID of the experiment to get"),
      mode: z
        .enum(["default", "analyze"])
        .default("default")
        .describe(
          "The mode to use to fetch the experiment. Default mode returns summary info about the experiment. Analyze mode will also fetch experiment results, allowing for better analysis, interpretation, and reporting."
        ),
    },
  • The server.tool call that registers the get_experiment tool, including its name, description, input schema, options, and handler function. This is called within registerExperimentTools.
    /**
     * Tool: get_experiment
     */
    server.tool(
      "get_experiment",
      "Gets a single experiment from GrowthBook",
      {
        experimentId: z.string().describe("The ID of the experiment to get"),
        mode: z
          .enum(["default", "analyze"])
          .default("default")
          .describe(
            "The mode to use to fetch the experiment. Default mode returns summary info about the experiment. Analyze mode will also fetch experiment results, allowing for better analysis, interpretation, and reporting."
          ),
      },
      {
        readOnlyHint: true,
      },
      async ({ experimentId, mode }) => {
        try {
          const res = await fetch(
            `${baseApiUrl}/api/v1/experiments/${experimentId}`,
            {
              headers: {
                Authorization: `Bearer ${apiKey}`,
                "Content-Type": "application/json",
              },
            }
          );
    
          await handleResNotOk(res);
          const data = await res.json();
    
          // If analyze mode, fetch results
          if (mode === "analyze") {
            try {
              const resultsRes = await fetch(
                `${baseApiUrl}/api/v1/experiments/${experimentId}/results`,
                {
                  headers: {
                    Authorization: `Bearer ${apiKey}`,
                  },
                }
              );
              await handleResNotOk(resultsRes);
              const resultsData = await resultsRes.json();
              data.result = resultsData.result;
            } catch (error) {
              console.error(
                `Error fetching results for experiment ${experimentId}`,
                error
              );
            }
          }
    
          const linkToGrowthBook = generateLinkToGrowthBook(
            appOrigin,
            "experiment",
            experimentId
          );
          const text = `
      ${JSON.stringify(data, null, 2)}
      
      [View the experiment in GrowthBook](${linkToGrowthBook})
      `;
    
          return {
            content: [{ type: "text", text }],
          };
        } catch (error) {
          throw new Error(`Error getting experiment: ${error}`);
        }
      }
    );
  • src/index.ts:89-95 (registration)
    Top-level call to registerExperimentTools in the main MCP server setup, which in turn registers the get_experiment tool.
    registerExperimentTools({
      server,
      baseApiUrl,
      apiKey,
      appOrigin,
      user,
    });
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a read operation ('Gets'), implying it's non-destructive, but doesn't specify permissions required, rate limits, error conditions, or what data is returned. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for a data retrieval tool. It doesn't explain what an 'experiment' entails in GrowthBook, what fields are returned, or how to interpret results. For a tool that presumably returns structured data, more context is needed to use it effectively.

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?

The input schema has 100% description coverage, with the single parameter 'experimentId' clearly documented. The description doesn't add any additional semantic context beyond what the schema provides, such as format examples or where to find experiment IDs. With high schema coverage, the baseline score of 3 is appropriate.

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 ('Gets') and resource ('a single experiment from GrowthBook'), making the purpose unambiguous. However, it doesn't distinguish this tool from its sibling 'get_experiments' (plural), which appears to retrieve multiple experiments, leaving some ambiguity about when to use each.

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 doesn't mention the sibling 'get_experiments' for retrieving multiple experiments or clarify if this is for detailed views versus list views. No prerequisites or context for usage are provided.

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