Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(experiments/mcp): Trim write-tool responses to relevant fields for mcp efficiency (#62795)

Marcel Poelkerb095e914995d
diff --git a/products/experiments/mcp/tools.yaml b/products/experiments/mcp/tools.yaml
index 66072051f77f..9a6cf3d6dd5a 100644
--- a/products/experiments/mcp/tools.yaml
+++ b/products/experiments/mcp/tools.yaml
@@ -107,6 +107,21 @@ tools:
"A", "Control", "old", "original", or "baseline". Other variants can use any key (`test`,
`variant_a`, etc.).
ui_app: experiment
+ response:
+ include:
+ - id
+ - name
+ - description
+ - type
+ - feature_flag_key
+ - status
+ - archived
+ - start_date
+ - end_date
+ - created_at
+ - parameters
+ - conclusion
+ - conclusion_comment
experiment-delete:
operation: experiments_destroy
enabled: true
@@ -264,6 +279,21 @@ tools:
id:
cast: string-int
ui_app: experiment
+ response:
+ include:
+ - id
+ - name
+ - description
+ - type
+ - feature_flag_key
+ - status
+ - archived
+ - start_date
+ - end_date
+ - created_at
+ - parameters
+ - conclusion
+ - conclusion_comment
experiment-list:
operation: experiments_list
enabled: true
@@ -713,6 +743,23 @@ tools:
id:
cast: string-int
ui_app: experiment
+ response:
+ include:
+ - id
+ - name
+ - description
+ - type
+ - feature_flag_key
+ - status
+ - archived
+ - start_date
+ - end_date
+ - created_at
+ - parameters
+ - metrics
+ - metrics_secondary
+ - conclusion
+ - conclusion_comment
experiments-copy-to-project-create:
operation: experiments_copy_to_project_create
enabled: false
diff --git a/services/mcp/src/tools/generated/experiments.ts b/services/mcp/src/tools/generated/experiments.ts
index 4d0cdef151b1..eafb33ee333a 100644
--- a/services/mcp/src/tools/generated/experiments.ts
+++ b/services/mcp/src/tools/generated/experiments.ts
@@ -114,7 +114,22 @@ const experimentCreate = (): ToolBase<typeof ExperimentCreateSchema, WithPostHog
path: `/api/projects/${encodeURIComponent(String(projectId))}/experiments/`,
body,
})
- return await withPostHogUrl(context, result, `/experiments/${result.id}`)
+ const filtered = pickResponseFields(result, [
+ 'id',
+ 'name',
+ 'description',
+ 'type',
+ 'feature_flag_key',
+ 'status',
+ 'archived',
+ 'start_date',
+ 'end_date',
+ 'created_at',
+ 'parameters',
+ 'conclusion',
+ 'conclusion_comment',
+ ]) as typeof result
+ return await withPostHogUrl(context, filtered, `/experiments/${filtered.id}`)
},
})
@@ -289,7 +304,22 @@ const experimentLaunch = (): ToolBase<typeof ExperimentLaunchSchema, WithPostHog
method: 'POST',
path: `/api/projects/${encodeURIComponent(String(projectId))}/experiments/${encodeURIComponent(String(params.id))}/launch/`,
})
- return await withPostHogUrl(context, result, `/experiments/${result.id}`)
+ const filtered = pickResponseFields(result, [
+ 'id',
+ 'name',
+ 'description',
+ 'type',
+ 'feature_flag_key',
+ 'status',
+ 'archived',
+ 'start_date',
+ 'end_date',
+ 'created_at',
+ 'parameters',
+ 'conclusion',
+ 'conclusion_comment',
+ ]) as typeof result
+ return await withPostHogUrl(context, filtered, `/experiments/${filtered.id}`)
},
})
@@ -704,7 +734,24 @@ const experimentUpdate = (): ToolBase<typeof ExperimentUpdateSchema, WithPostHog
path: `/api/projects/${encodeURIComponent(String(projectId))}/experiments/${encodeURIComponent(String(params.id))}/`,
body,
})
- return await withPostHogUrl(context, result, `/experiments/${result.id}`)
+ const filtered = pickResponseFields(result, [
+ 'id',
+ 'name',
+ 'description',
+ 'type',
+ 'feature_flag_key',
+ 'status',
+ 'archived',
+ 'start_date',
+ 'end_date',
+ 'created_at',
+ 'parameters',
+ 'metrics',
+ 'metrics_secondary',
+ 'conclusion',
+ 'conclusion_comment',
+ ]) as typeof result
+ return await withPostHogUrl(context, filtered, `/experiments/${filtered.id}`)
},
})