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.

feat(visual-review): enable the toleration pile-ups MCP tool (#105753)

Julian Bez9ca73d068ff1
diff --git a/products/visual_review/mcp/tools.yaml b/products/visual_review/mcp/tools.yaml
index 99e16e2b0afc..a6ae81a46a73 100644
--- a/products/visual_review/mcp/tools.yaml
+++ b/products/visual_review/mcp/tools.yaml
@@ -216,7 +216,7 @@ tools:
enabled: false
visual-review-repos-toleration-pileups-retrieve:
operation: visual_review_repos_toleration_pileups_retrieve
- enabled: false
+ enabled: true
scopes:
- visual_review:read
annotations:
@@ -228,8 +228,8 @@ tools:
Snapshots in a repo that keep getting tolerated, counted across baselines, most manual tolerations first. A
toleration accepts one exact rendering, so a snapshot that keeps needing them renders differently from run
to run, and the fix belongs in the story (a pinned date, a disabled animation, a wait for a loader). Called
- with no parameters it applies the weekly debt digest's rule and keeps quarantined snapshots, marked with
- `is_quarantined`. Tune it with `min_tolerations`, `min_automatic_tolerations`, `window_days`,
+ with only the repo `id` it applies the weekly debt digest's rule and keeps quarantined snapshots, marked
+ with `is_quarantined`. Tune it with `min_tolerations`, `min_automatic_tolerations`, `window_days`,
`include_quarantined`, `run_type` and `limit`; the response echoes the rule it applied. The list is short
and returns quickly, so use it instead of the flakiness overview to find flaky stories worth fixing, then
read one snapshot's history with `visual-review-runs-snapshot-history-list` or its tolerations with
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 21acea70e537..17ccfde9b42c 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -12858,6 +12858,21 @@
},
"feature_flag": "visual-review"
},
+ "visual-review-repos-toleration-pileups-retrieve": {
+ "description": "Snapshots in a repo that keep getting tolerated, counted across baselines, most manual tolerations first. A toleration accepts one exact rendering, so a snapshot that keeps needing them renders differently from run to run, and the fix belongs in the story (a pinned date, a disabled animation, a wait for a loader). Called with only the repo `id` it applies the weekly debt digest's rule and keeps quarantined snapshots, marked with `is_quarantined`. Tune it with `min_tolerations`, `min_automatic_tolerations`, `window_days`, `include_quarantined`, `run_type` and `limit`; the response echoes the rule it applied. The list is short and returns quickly, so use it instead of the flakiness overview to find flaky stories worth fixing, then read one snapshot's history with `visual-review-runs-snapshot-history-list` or its tolerations with `visual-review-runs-tolerated-hashes-list`.",
+ "category": "Visual review",
+ "feature": "visual_review",
+ "summary": "Visual review toleration pile-ups",
+ "title": "Visual review toleration pile-ups",
+ "required_scopes": ["visual_review:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_flag": "visual-review"
+ },
"visual-review-runs-approve-create": {
"description": "Mark specific snapshots as reviewed (approved) in a run. Pass a `snapshots` list, each entry being `{identifier, new_hash}` — `new_hash` is the `content_hash` of the snapshot's `current_artifact`. This only records the review in the database (the per-snapshot \"Accept change\" action) — it does NOT update the baseline, push a commit, or change the GitHub gate, and it can be re-run safely. To actually ship the visual change (commit the baseline + green the gate), use `visual-review-runs-finalize-create`. Approving a quarantined `new` snapshot here makes finalize commit its baseline entry while the quarantine stays in place — the way to give a quarantined story an entry without failing other runs.",
"category": "Visual review",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index ea4fc6df5f25..b49ef3725b64 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -13503,6 +13503,21 @@
},
"feature_flag": "visual-review"
},
+ "visual-review-repos-toleration-pileups-retrieve": {
+ "description": "Snapshots in a repo that keep getting tolerated, counted across baselines, most manual tolerations first. A toleration accepts one exact rendering, so a snapshot that keeps needing them renders differently from run to run, and the fix belongs in the story (a pinned date, a disabled animation, a wait for a loader). Called with only the repo `id` it applies the weekly debt digest's rule and keeps quarantined snapshots, marked with `is_quarantined`. Tune it with `min_tolerations`, `min_automatic_tolerations`, `window_days`, `include_quarantined`, `run_type` and `limit`; the response echoes the rule it applied. The list is short and returns quickly, so use it instead of the flakiness overview to find flaky stories worth fixing, then read one snapshot's history with `visual-review-runs-snapshot-history-list` or its tolerations with `visual-review-runs-tolerated-hashes-list`.",
+ "category": "Visual review",
+ "feature": "visual_review",
+ "summary": "Visual review toleration pile-ups",
+ "title": "Visual review toleration pile-ups",
+ "required_scopes": ["visual_review:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_flag": "visual-review"
+ },
"visual-review-runs-approve-create": {
"description": "Mark specific snapshots as reviewed (approved) in a run. Pass a `snapshots` list, each entry being `{identifier, new_hash}` — `new_hash` is the `content_hash` of the snapshot's `current_artifact`. This only records the review in the database (the per-snapshot \"Accept change\" action) — it does NOT update the baseline, push a commit, or change the GitHub gate, and it can be re-run safely. To actually ship the visual change (commit the baseline + green the gate), use `visual-review-runs-finalize-create`. Approving a quarantined `new` snapshot here makes finalize commit its baseline entry while the quarantine stays in place — the way to give a quarantined story an entry without failing other runs.",
"category": "Visual review",
diff --git a/services/mcp/src/generated/visual_review/api.ts b/services/mcp/src/generated/visual_review/api.ts
index 6f81688361c7..4ba1e49f99d4 100644
--- a/services/mcp/src/generated/visual_review/api.ts
+++ b/services/mcp/src/generated/visual_review/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 16 enabled ops
+ * PostHog API - MCP 17 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -93,6 +93,75 @@ export const VisualReviewReposQuarantineListQueryParams = () => zod.object({
run_type: zod.string().optional().describe('Filter by run type'),
})
+/**
+ * Snapshots that keep getting tolerated, counted across baselines, most manual tolerations first. A toleration accepts one exact rendering, so a snapshot that keeps needing them renders differently from run to run, and the fix belongs in the story. With no parameters this is the weekly debt digest's rule (3 or more tolerations by a person or agent in 30 days), except that quarantined snapshots are kept and marked with `is_quarantined`. The list is small and returns fast; start here to find flaky stories worth fixing, then read one snapshot's history with the per-snapshot tools.
+ */
+export const VisualReviewReposTolerationPileupsRetrieveParams = () => zod.object({
+ id: zod.string(),
+ project_id: zod
+ .string()
+ .describe(
+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
+ ),
+})
+
+export const visualReviewReposTolerationPileupsRetrieveQueryIncludeQuarantinedDefault = true
+export const visualReviewReposTolerationPileupsRetrieveQueryLimitDefault = 100
+export const visualReviewReposTolerationPileupsRetrieveQueryLimitMax = 500
+
+export const visualReviewReposTolerationPileupsRetrieveQueryMinAutomaticTolerationsMax = 10000
+
+export const visualReviewReposTolerationPileupsRetrieveQueryMinTolerationsDefault = 3
+export const visualReviewReposTolerationPileupsRetrieveQueryMinTolerationsMax = 100
+
+export const visualReviewReposTolerationPileupsRetrieveQueryRunTypeMax = 64
+
+export const visualReviewReposTolerationPileupsRetrieveQueryWindowDaysDefault = 30
+export const visualReviewReposTolerationPileupsRetrieveQueryWindowDaysMax = 90
+
+export const VisualReviewReposTolerationPileupsRetrieveQueryParams = () => zod.object({
+ include_quarantined: zod
+ .boolean()
+ .default(visualReviewReposTolerationPileupsRetrieveQueryIncludeQuarantinedDefault)
+ .describe(
+ 'Keep snapshots that an active quarantine already covers. They are marked with `is_quarantined`. Set to false to see only piles nobody has acted on yet.'
+ ),
+ limit: zod
+ .number()
+ .min(1)
+ .max(visualReviewReposTolerationPileupsRetrieveQueryLimitMax)
+ .default(visualReviewReposTolerationPileupsRetrieveQueryLimitDefault)
+ .describe('Maximum number of snapshots to return. `total` and `truncated` say whether more matched.'),
+ min_automatic_tolerations: zod
+ .number()
+ .min(1)
+ .max(visualReviewReposTolerationPileupsRetrieveQueryMinAutomaticTolerationsMax)
+ .optional()
+ .describe(
+ "Also list a snapshot when it collected at least this many automatic tolerations in the window. An automatic toleration is a rendering under both diff thresholds, so it never blocked anybody; many of them still mean the story is unstable. Omit to ignore automatic tolerations when deciding what to list. With 10, the list matches the Tolerate dialog's quarantine suggestion."
+ ),
+ min_tolerations: zod
+ .number()
+ .min(1)
+ .max(visualReviewReposTolerationPileupsRetrieveQueryMinTolerationsMax)
+ .default(visualReviewReposTolerationPileupsRetrieveQueryMinTolerationsDefault)
+ .describe(
+ "List a snapshot when a person or agent tolerated it at least this many times in the window. The default, 3, is the weekly debt digest's rule. Lower it to see snapshots that are starting to pile up, raise it to see only the worst ones."
+ ),
+ run_type: zod
+ .string()
+ .min(1)
+ .max(visualReviewReposTolerationPileupsRetrieveQueryRunTypeMax)
+ .optional()
+ .describe('Only list snapshots of this run type, for example `storybook` or `playwright`.'),
+ window_days: zod
+ .number()
+ .min(1)
+ .max(visualReviewReposTolerationPileupsRetrieveQueryWindowDaysMax)
+ .default(visualReviewReposTolerationPileupsRetrieveQueryWindowDaysDefault)
+ .describe('How many days back to count tolerations. Defaults to 30.'),
+})
+
/**
* List runs in this repo, optionally filtered by review state and free-text search.
*/
diff --git a/services/mcp/src/tools/generated/visual_review.ts b/services/mcp/src/tools/generated/visual_review.ts
index 648c425f8c89..ff0c0b697e5b 100644
--- a/services/mcp/src/tools/generated/visual_review.ts
+++ b/services/mcp/src/tools/generated/visual_review.ts
@@ -313,6 +313,50 @@ const visualReviewReposRunsList = (): ToolBase<
},
})
+const VisualReviewReposTolerationPileupsRetrieveSchema = () => {
+ const VisualReviewReposTolerationPileupsRetrieveParams =
+ orvalSchemas.VisualReviewReposTolerationPileupsRetrieveParams()
+ const VisualReviewReposTolerationPileupsRetrieveQueryParams =
+ orvalSchemas.VisualReviewReposTolerationPileupsRetrieveQueryParams()
+ return z.preprocess(
+ normalizeParamAliases({ id: ['repo_id'] }),
+ VisualReviewReposTolerationPileupsRetrieveParams.omit({ project_id: true })
+ .extend(VisualReviewReposTolerationPileupsRetrieveQueryParams.shape)
+ .extend({
+ id: VisualReviewReposTolerationPileupsRetrieveParams.shape['id'].describe(
+ "The repo's UUID, from `visual-review-repos-list`."
+ ),
+ })
+ )
+}
+
+const visualReviewReposTolerationPileupsRetrieve = (): ToolBase<
+ ReturnType<typeof VisualReviewReposTolerationPileupsRetrieveSchema>,
+ Schemas.TolerationPileups
+> => ({
+ name: 'visual-review-repos-toleration-pileups-retrieve',
+ schema: VisualReviewReposTolerationPileupsRetrieveSchema(),
+ handler: async (
+ context: Context,
+ params: z.infer<ReturnType<typeof VisualReviewReposTolerationPileupsRetrieveSchema>>
+ ) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.TolerationPileups>({
+ method: 'GET',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/visual_review/repos/${encodeURIComponent(String(params.id))}/toleration-pileups/`,
+ query: {
+ include_quarantined: params.include_quarantined,
+ limit: params.limit,
+ min_automatic_tolerations: params.min_automatic_tolerations,
+ min_tolerations: params.min_tolerations,
+ run_type: params.run_type,
+ window_days: params.window_days,
+ },
+ })
+ return result
+ },
+})
+
const VisualReviewRunsApproveCreateSchema = () => {
const VisualReviewRunsApproveCreateBody = orvalSchemas.VisualReviewRunsApproveCreateBody()
const VisualReviewRunsApproveCreateParams = orvalSchemas.VisualReviewRunsApproveCreateParams()
@@ -608,6 +652,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'visual-review-repos-retrieve': visualReviewReposRetrieve,
'visual-review-repos-runs-counts-retrieve': visualReviewReposRunsCountsRetrieve,
'visual-review-repos-runs-list': visualReviewReposRunsList,
+ 'visual-review-repos-toleration-pileups-retrieve': visualReviewReposTolerationPileupsRetrieve,
'visual-review-runs-approve-create': visualReviewRunsApproveCreate,
'visual-review-runs-counts-retrieve': visualReviewRunsCountsRetrieve,
'visual-review-runs-finalize-create': visualReviewRunsFinalizeCreate,