@growthbook/mcp 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@ Use the following env variables to configure the MCP server.
13
13
 
14
14
  | Variable Name | Status | Description |
15
15
  | ------------- | -------- | ----------------------------------------------------------------- |
16
- | GB_API_KEY | Required | A GrowthBook API key. |
16
+ | GB_API_KEY | Required | A GrowthBook API key or PAT. When using a PAT, MCP server capabilities are limited by its permissions. E.g., if the user can't create an experiment in the app, they also won't be able to create one with the MCP server. |
17
17
  | GB_EMAIL | Required | Your email address used with GrowthBook. Used when creating feature flags and experiments.|
18
18
  | GB_API_URL | Optional | Your GrowthBook API URL. Defaults to `https://api.growthbook.io`. |
19
19
  | GB_APP_ORIGIN | Optional | Your GrowthBook app URL Defaults to `https://app.growthbook.io`. |
package/build/index.js CHANGED
@@ -6,17 +6,20 @@ import { registerExperimentTools } from "./tools/experiments.js";
6
6
  import { registerFeatureTools } from "./tools/features.js";
7
7
  import { registerProjectTools } from "./tools/projects.js";
8
8
  import { registerSdkConnectionTools } from "./tools/sdk-connections.js";
9
- import { getApiKey, getApiUrl, getAppOrigin, getUser } from "./utils.js";
9
+ import { getApiKey, getApiUrl, getAppOrigin } from "./utils.js";
10
10
  import { registerSearchTools } from "./tools/search.js";
11
11
  import { registerDefaultsTools } from "./tools/defaults.js";
12
12
  export const baseApiUrl = getApiUrl();
13
13
  export const apiKey = getApiKey();
14
14
  export const appOrigin = getAppOrigin();
15
- export const user = await getUser(baseApiUrl, apiKey);
15
+ export const user = process.env.GB_EMAIL;
16
+ if (!user) {
17
+ throw new Error("GB_EMAIL is not set in the environment variables");
18
+ }
16
19
  // Create an MCP server
17
20
  const server = new McpServer({
18
21
  name: "GrowthBook MCP",
19
- version: "1.0.0",
22
+ version: "1.0.2",
20
23
  }, {
21
24
  instructions: `You are a helpful assistant that interacts with GrowthBook, an open source feature flagging and experimentation platform. You can create and manage feature flags, experiments (A/B tests), and other resources associated with GrowthBook.
22
25
 
@@ -208,7 +208,7 @@ export function registerExperimentTools({ server, baseApiUrl, apiKey, appOrigin,
208
208
  name,
209
209
  description,
210
210
  hypothesis,
211
- owner: user.email,
211
+ owner: user,
212
212
  trackingKey: name.toLowerCase().replace(/[^a-z0-9]/g, "-"),
213
213
  tags: ["mcp"],
214
214
  assignmentQueryId: experimentDefaults?.assignmentQuery,
@@ -232,7 +232,7 @@ export function registerExperimentTools({ server, baseApiUrl, apiKey, appOrigin,
232
232
  const flagId = `flag_${name.toLowerCase().replace(/[^a-z0-9]/g, "_")}`;
233
233
  const flagPayload = {
234
234
  id: flagId,
235
- owner: user.name,
235
+ owner: user,
236
236
  defaultValue: variations[0].value,
237
237
  valueType: typeof variations[0].value === "string"
238
238
  ? "string"
@@ -46,7 +46,7 @@ export function registerFeatureTools({ server, baseApiUrl, apiKey, appOrigin, us
46
46
  const payload = {
47
47
  id,
48
48
  description,
49
- owner: user.name,
49
+ owner: user,
50
50
  valueType,
51
51
  defaultValue,
52
52
  tags: ["mcp"],
package/build/utils.js CHANGED
@@ -1,4 +1,3 @@
1
- import { z } from "zod";
2
1
  import { getFeatureFlagDocs } from "./docs.js";
3
2
  // Shared file extension enum for all MCP tools
4
3
  export const SUPPORTED_FILE_EXTENSIONS = [
@@ -53,40 +52,6 @@ export function getAppOrigin() {
53
52
  const userAppOrigin = process.env.GB_APP_ORIGIN;
54
53
  return `${userAppOrigin || defaultAppOrigin}`;
55
54
  }
56
- export async function getUser(baseApiUrl, apiKey) {
57
- const user = process.env.GB_EMAIL || process.env.GB_USER;
58
- if (!user) {
59
- throw new Error("GB_EMAIL environment variable is required");
60
- }
61
- // Show deprecation warning if using the old variable
62
- if (process.env.GB_USER && !process.env.GB_EMAIL) {
63
- console.error("⚠️ GB_USER is deprecated. Use GB_EMAIL instead.");
64
- }
65
- const emailSchema = z.string().email();
66
- if (!emailSchema.safeParse(user).success) {
67
- throw new Error("GB_EMAIL is not a valid email");
68
- }
69
- try {
70
- const users = await fetch(`${baseApiUrl}/api/v1/members?userEmail=${user}`, {
71
- headers: {
72
- Authorization: `Bearer ${apiKey}`,
73
- },
74
- });
75
- await handleResNotOk(users);
76
- const usersData = await users.json();
77
- if (usersData.members.length === 0) {
78
- throw new Error(`Email not found in GrowthBook. Update GB_EMAIL environment variable to your email address in GrowthBook.`);
79
- }
80
- const userFromGrowthBook = {
81
- email: usersData.members[0].email,
82
- name: usersData.members[0].name,
83
- };
84
- return userFromGrowthBook;
85
- }
86
- catch (error) {
87
- throw new Error(`Error fetching user from GrowthBook. Please check your GB_EMAIL and GB_API_KEY environment variables.`);
88
- }
89
- }
90
55
  export function getDocsMetadata(extension) {
91
56
  switch (extension) {
92
57
  case ".tsx":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growthbook/mcp",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "homepage": "https://github.com/growthbook/growthbook-mcp",