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(replay-vision): expose observation rating tools in the mcp (#68231)

Arno Hillend36eb6cc0f07
diff --git a/products/replay_vision/mcp/tools.yaml b/products/replay_vision/mcp/tools.yaml
index 421881e8ae7b..322c45101f2c 100644
--- a/products/replay_vision/mcp/tools.yaml
+++ b/products/replay_vision/mcp/tools.yaml
@@ -32,10 +32,39 @@ tools:
enabled: false
vision-observations-label-create:
operation: vision_observations_label_create
- enabled: false
+ enabled: true
+ scopes:
+ - replay_scanner:write
+ - session_recording:read
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: true
+ title: Rate a scanner observation
+ description: >
+ Set or update the shared thumbs up/down rating on a replay scanner observation: `is_correct` true means the
+ scanner got the session right (thumbs up), false means it got it wrong (thumbs down), plus optional written
+ `feedback` explaining why (applies to both directions). One shared rating per observation, team-wide, last
+ write wins; re-posting updates it in place. These ratings power the scanner's Quality tab: the
+ quality-over-time chart and the AI prompt recommendations (see
+ `vision-scanners-prompt-suggestions-generate`). Find observation IDs via `vision-scanners-observations-list`
+ (filter `labeled=false` for unrated ones) or `vision-observations-list` for a session.
+ feature_flag: replay-vision
vision-observations-label-destroy:
operation: vision_observations_label_destroy
- enabled: false
+ enabled: true
+ scopes:
+ - replay_scanner:write
+ - session_recording:read
+ annotations:
+ readOnly: false
+ destructive: true
+ idempotent: true
+ title: Remove a scanner observation rating
+ description: >
+ Remove the shared thumbs up/down rating (and its feedback) from a replay scanner observation, returning it
+ to unrated. Team-wide: this clears the rating for everyone.
+ feature_flag: replay-vision
vision-observations-list:
operation: vision_observations_list
enabled: true
@@ -247,24 +276,103 @@ tools:
vision-scanners-observations-retry-create:
operation: vision_scanners_observations_retry_create
enabled: false
- vision-scanners-observations-stats-retrieve:
+ vision-scanners-observations-stats:
operation: vision_scanners_observations_stats_retrieve
- enabled: false
+ enabled: true
+ scopes:
+ - replay_scanner:read
+ - session_recording:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ title: Get scanner observation stats
+ description: >
+ Aggregate statistics over one scanner's observations. Accepts the same filters as
+ `vision-scanners-observations-list` plus `recent_days` (default 14, clamped 1..365) for the windowed series.
+ Returns `status_counts` (totals and success rate), `coverage` (distinct sessions scanned), `labels` (thumbs
+ up/down rating totals, a per-day accuracy series bucketed by scan day, per-day rating activity, and
+ `version_markers`: each prompt version's first day, prompt text, and rating counts), plus per-type
+ distributions (`monitor` verdict counts, `classifier` tag rankings, `scorer` score summary and histogram).
+ Use it to judge scanner quality and rating coverage, e.g. before generating a prompt suggestion with
+ `vision-scanners-prompt-suggestions-generate`.
+ feature_flag: replay-vision
vision-scanners-partial-update:
operation: vision_scanners_partial_update
enabled: false
- vision-scanners-prompt-suggestions-apply-create:
+ vision-scanners-prompt-suggestions-apply:
operation: vision_scanners_prompt_suggestions_apply_create
- enabled: false
- vision-scanners-prompt-suggestions-current-retrieve:
+ enabled: true
+ scopes:
+ - replay_scanner:write
+ - session_recording:read
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: false
+ title: Apply prompt suggestion
+ description: >
+ Apply a prompt suggestion to its scanner: writes the `suggested_prompt` into the scanner's config (bumping
+ `scanner_version`) and marks the suggestion applied. Only the current (pending or dismissed) suggestion can
+ be applied, and only while the scanner's prompt is unchanged since it was generated. Otherwise the call is
+ rejected and you should generate a fresh one. This is a team-wide change: the scanner scans with the new
+ prompt from its next sweep onward.
+ feature_flag: replay-vision
+ vision-scanners-prompt-suggestions-current:
operation: vision_scanners_prompt_suggestions_current_retrieve
- enabled: false
- vision-scanners-prompt-suggestions-dismiss-create:
+ enabled: true
+ scopes:
+ - replay_scanner:read
+ - session_recording:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ title: Get current prompt suggestion
+ description: >
+ Get a scanner's newest AI prompt-rewrite suggestion, generated from the team's thumbs up/down ratings.
+ Returns `suggestion` (null when none has been generated yet) with its `suggested_prompt`, the `base_prompt`
+ it rewrote (for diffing), the `rationale`, and `status` (pending/applied/dismissed/superseded). Also returns
+ `stale` (true when ratings changed since it was generated, so regenerating may give a better rewrite) and
+ `rated_count` (rated observations available to generate from).
+ feature_flag: replay-vision
+ vision-scanners-prompt-suggestions-dismiss:
operation: vision_scanners_prompt_suggestions_dismiss_create
- enabled: false
- vision-scanners-prompt-suggestions-generate-create:
+ enabled: true
+ scopes:
+ - replay_scanner:write
+ - session_recording:read
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: true
+ title: Dismiss prompt suggestion
+ description: >
+ Dismiss a prompt suggestion without applying it. The scanner's prompt is unchanged and the suggestion stays
+ in history. A dismissed suggestion can still be applied later with
+ `vision-scanners-prompt-suggestions-apply` as long as the scanner's prompt hasn't changed since it was
+ generated.
+ feature_flag: replay-vision
+ vision-scanners-prompt-suggestions-generate:
operation: vision_scanners_prompt_suggestions_generate_create
- enabled: false
+ enabled: true
+ scopes:
+ - replay_scanner:write
+ - session_recording:read
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: false
+ title: Generate prompt suggestion from ratings
+ description: >
+ Generate a fresh AI prompt-rewrite suggestion for a scanner from the team's current thumbs up/down ratings
+ and their written feedback. Requires at least one rated observation (check `rated_count` on
+ `vision-scanners-prompt-suggestions-current`; create ratings with `vision-observations-label-create`). The
+ previous pending suggestion becomes superseded. The LLM call runs inline, so expect the request to take a
+ while. Review the returned suggestion, then apply it with `vision-scanners-prompt-suggestions-apply` or
+ dismiss it with `vision-scanners-prompt-suggestions-dismiss`.
+ requires_ai_consent: true
+ feature_flag: replay-vision
vision-scanners-prompt-suggestions-list:
operation: vision_scanners_prompt_suggestions_list
enabled: false
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 738e6e396cde..844efdf61cc0 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -8313,6 +8313,36 @@
"readOnlyHint": false
}
},
+ "vision-observations-label-create": {
+ "description": "Set or update the shared thumbs up/down rating on a replay scanner observation: `is_correct` true means the scanner got the session right (thumbs up), false means it got it wrong (thumbs down), plus optional written `feedback` explaining why (applies to both directions). One shared rating per observation, team-wide, last write wins; re-posting updates it in place. These ratings power the scanner's Quality tab: the quality-over-time chart and the AI prompt recommendations (see `vision-scanners-prompt-suggestions-generate`). Find observation IDs via `vision-scanners-observations-list` (filter `labeled=false` for unrated ones) or `vision-observations-list` for a session.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Rate a scanner observation",
+ "title": "Rate a scanner observation",
+ "required_scopes": ["replay_scanner:write", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "replay-vision"
+ },
+ "vision-observations-label-destroy": {
+ "description": "Remove the shared thumbs up/down rating (and its feedback) from a replay scanner observation, returning it to unrated. Team-wide: this clears the rating for everyone.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Remove a scanner observation rating",
+ "title": "Remove a scanner observation rating",
+ "required_scopes": ["replay_scanner:write", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "replay-vision"
+ },
"vision-observations-list": {
"description": "List every replay vision observation recorded for a single session, across all scanners the caller can read. This is the \"what has Replay Vision found about this session?\" lookup — pair it with the session-recording MCP tools or the investigating-replay skill while investigating a recording. The `session_id` query parameter is REQUIRED; without it the request is rejected. Each result includes the scanner that produced it, the observation `status` (pending/running/succeeded/failed/ineligible), the `error_reason` for terminal non-success statuses, and the `scanner_result` (LLM output) on success. To list observations for one specific scanner over time instead, use `vision-scanners-observations-list`.",
"category": "Replay vision",
@@ -8464,6 +8494,82 @@
},
"feature_flag": "replay-vision"
},
+ "vision-scanners-observations-stats": {
+ "description": "Aggregate statistics over one scanner's observations. Accepts the same filters as `vision-scanners-observations-list` plus `recent_days` (default 14, clamped 1..365) for the windowed series. Returns `status_counts` (totals and success rate), `coverage` (distinct sessions scanned), `labels` (thumbs up/down rating totals, a per-day accuracy series bucketed by scan day, per-day rating activity, and `version_markers`: each prompt version's first day, prompt text, and rating counts), plus per-type distributions (`monitor` verdict counts, `classifier` tag rankings, `scorer` score summary and histogram). Use it to judge scanner quality and rating coverage, e.g. before generating a prompt suggestion with `vision-scanners-prompt-suggestions-generate`.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Get scanner observation stats",
+ "title": "Get scanner observation stats",
+ "required_scopes": ["replay_scanner:read", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_flag": "replay-vision"
+ },
+ "vision-scanners-prompt-suggestions-apply": {
+ "description": "Apply a prompt suggestion to its scanner: writes the `suggested_prompt` into the scanner's config (bumping `scanner_version`) and marks the suggestion applied. Only the current (pending or dismissed) suggestion can be applied, and only while the scanner's prompt is unchanged since it was generated. Otherwise the call is rejected and you should generate a fresh one. This is a team-wide change: the scanner scans with the new prompt from its next sweep onward.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Apply prompt suggestion",
+ "title": "Apply prompt suggestion",
+ "required_scopes": ["replay_scanner:write", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "replay-vision"
+ },
+ "vision-scanners-prompt-suggestions-current": {
+ "description": "Get a scanner's newest AI prompt-rewrite suggestion, generated from the team's thumbs up/down ratings. Returns `suggestion` (null when none has been generated yet) with its `suggested_prompt`, the `base_prompt` it rewrote (for diffing), the `rationale`, and `status` (pending/applied/dismissed/superseded). Also returns `stale` (true when ratings changed since it was generated, so regenerating may give a better rewrite) and `rated_count` (rated observations available to generate from).",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Get current prompt suggestion",
+ "title": "Get current prompt suggestion",
+ "required_scopes": ["replay_scanner:read", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_flag": "replay-vision"
+ },
+ "vision-scanners-prompt-suggestions-dismiss": {
+ "description": "Dismiss a prompt suggestion without applying it. The scanner's prompt is unchanged and the suggestion stays in history. A dismissed suggestion can still be applied later with `vision-scanners-prompt-suggestions-apply` as long as the scanner's prompt hasn't changed since it was generated.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Dismiss prompt suggestion",
+ "title": "Dismiss prompt suggestion",
+ "required_scopes": ["replay_scanner:write", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "replay-vision"
+ },
+ "vision-scanners-prompt-suggestions-generate": {
+ "description": "Generate a fresh AI prompt-rewrite suggestion for a scanner from the team's current thumbs up/down ratings and their written feedback. Requires at least one rated observation (check `rated_count` on `vision-scanners-prompt-suggestions-current`; create ratings with `vision-observations-label-create`). The previous pending suggestion becomes superseded. The LLM call runs inline, so expect the request to take a while. Review the returned suggestion, then apply it with `vision-scanners-prompt-suggestions-apply` or dismiss it with `vision-scanners-prompt-suggestions-dismiss`.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Generate prompt suggestion from ratings",
+ "title": "Generate prompt suggestion from ratings",
+ "required_scopes": ["replay_scanner:write", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "requires_ai_consent": true,
+ "feature_flag": "replay-vision"
+ },
"vision-scanners-scan-session": {
"description": "Trigger a scanner against a specific session immediately, bypassing the sampling rate and any scheduled sweep. Returns 202 with a `workflow_id`; the resulting observation appears under `vision-scanners-observations-list` once the Temporal workflow finishes (typically several minutes — rasterising the recording into video and calling the LLM is slow). Useful for ad-hoc scanning during an investigation: pick a scanner that matches the question you want answered, and point it at the session you're examining. A scanner can observe a given session only once — re-triggering it on a session that already has an observation (even a failed or ineligible one) is a no-op and will not produce a fresh scan.",
"category": "Replay vision",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 05958c1fbf04..87561ffe74b0 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -8836,6 +8836,36 @@
"readOnlyHint": false
}
},
+ "vision-observations-label-create": {
+ "description": "Set or update the shared thumbs up/down rating on a replay scanner observation: `is_correct` true means the scanner got the session right (thumbs up), false means it got it wrong (thumbs down), plus optional written `feedback` explaining why (applies to both directions). One shared rating per observation, team-wide, last write wins; re-posting updates it in place. These ratings power the scanner's Quality tab: the quality-over-time chart and the AI prompt recommendations (see `vision-scanners-prompt-suggestions-generate`). Find observation IDs via `vision-scanners-observations-list` (filter `labeled=false` for unrated ones) or `vision-observations-list` for a session.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Rate a scanner observation",
+ "title": "Rate a scanner observation",
+ "required_scopes": ["replay_scanner:write", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "replay-vision"
+ },
+ "vision-observations-label-destroy": {
+ "description": "Remove the shared thumbs up/down rating (and its feedback) from a replay scanner observation, returning it to unrated. Team-wide: this clears the rating for everyone.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Remove a scanner observation rating",
+ "title": "Remove a scanner observation rating",
+ "required_scopes": ["replay_scanner:write", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "replay-vision"
+ },
"vision-observations-list": {
"description": "List every replay vision observation recorded for a single session, across all scanners the caller can read. This is the \"what has Replay Vision found about this session?\" lookup — pair it with the session-recording MCP tools or the investigating-replay skill while investigating a recording. The `session_id` query parameter is REQUIRED; without it the request is rejected. Each result includes the scanner that produced it, the observation `status` (pending/running/succeeded/failed/ineligible), the `error_reason` for terminal non-success statuses, and the `scanner_result` (LLM output) on success. To list observations for one specific scanner over time instead, use `vision-scanners-observations-list`.",
"category": "Replay vision",
@@ -8987,6 +9017,82 @@
},
"feature_flag": "replay-vision"
},
+ "vision-scanners-observations-stats": {
+ "description": "Aggregate statistics over one scanner's observations. Accepts the same filters as `vision-scanners-observations-list` plus `recent_days` (default 14, clamped 1..365) for the windowed series. Returns `status_counts` (totals and success rate), `coverage` (distinct sessions scanned), `labels` (thumbs up/down rating totals, a per-day accuracy series bucketed by scan day, per-day rating activity, and `version_markers`: each prompt version's first day, prompt text, and rating counts), plus per-type distributions (`monitor` verdict counts, `classifier` tag rankings, `scorer` score summary and histogram). Use it to judge scanner quality and rating coverage, e.g. before generating a prompt suggestion with `vision-scanners-prompt-suggestions-generate`.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Get scanner observation stats",
+ "title": "Get scanner observation stats",
+ "required_scopes": ["replay_scanner:read", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_flag": "replay-vision"
+ },
+ "vision-scanners-prompt-suggestions-apply": {
+ "description": "Apply a prompt suggestion to its scanner: writes the `suggested_prompt` into the scanner's config (bumping `scanner_version`) and marks the suggestion applied. Only the current (pending or dismissed) suggestion can be applied, and only while the scanner's prompt is unchanged since it was generated. Otherwise the call is rejected and you should generate a fresh one. This is a team-wide change: the scanner scans with the new prompt from its next sweep onward.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Apply prompt suggestion",
+ "title": "Apply prompt suggestion",
+ "required_scopes": ["replay_scanner:write", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "replay-vision"
+ },
+ "vision-scanners-prompt-suggestions-current": {
+ "description": "Get a scanner's newest AI prompt-rewrite suggestion, generated from the team's thumbs up/down ratings. Returns `suggestion` (null when none has been generated yet) with its `suggested_prompt`, the `base_prompt` it rewrote (for diffing), the `rationale`, and `status` (pending/applied/dismissed/superseded). Also returns `stale` (true when ratings changed since it was generated, so regenerating may give a better rewrite) and `rated_count` (rated observations available to generate from).",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Get current prompt suggestion",
+ "title": "Get current prompt suggestion",
+ "required_scopes": ["replay_scanner:read", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_flag": "replay-vision"
+ },
+ "vision-scanners-prompt-suggestions-dismiss": {
+ "description": "Dismiss a prompt suggestion without applying it. The scanner's prompt is unchanged and the suggestion stays in history. A dismissed suggestion can still be applied later with `vision-scanners-prompt-suggestions-apply` as long as the scanner's prompt hasn't changed since it was generated.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Dismiss prompt suggestion",
+ "title": "Dismiss prompt suggestion",
+ "required_scopes": ["replay_scanner:write", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "replay-vision"
+ },
+ "vision-scanners-prompt-suggestions-generate": {
+ "description": "Generate a fresh AI prompt-rewrite suggestion for a scanner from the team's current thumbs up/down ratings and their written feedback. Requires at least one rated observation (check `rated_count` on `vision-scanners-prompt-suggestions-current`; create ratings with `vision-observations-label-create`). The previous pending suggestion becomes superseded. The LLM call runs inline, so expect the request to take a while. Review the returned suggestion, then apply it with `vision-scanners-prompt-suggestions-apply` or dismiss it with `vision-scanners-prompt-suggestions-dismiss`.",
+ "category": "Replay vision",
+ "feature": "replay_vision",
+ "summary": "Generate prompt suggestion from ratings",
+ "title": "Generate prompt suggestion from ratings",
+ "required_scopes": ["replay_scanner:write", "session_recording:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "requires_ai_consent": true,
+ "feature_flag": "replay-vision"
+ },
"vision-scanners-scan-session": {
"description": "Trigger a scanner against a specific session immediately, bypassing the sampling rate and any scheduled sweep. Returns 202 with a `workflow_id`; the resulting observation appears under `vision-scanners-observations-list` once the Temporal workflow finishes (typically several minutes — rasterising the recording into video and calling the LLM is slow). Useful for ad-hoc scanning during an investigation: pick a scanner that matches the question you want answered, and point it at the session you're examining. A scanner can observe a given session only once — re-triggering it on a session that already has an observation (even a failed or ineligible one) is a no-op and will not produce a fresh scan.",
"category": "Replay vision",
diff --git a/services/mcp/src/generated/replay_vision/api.ts b/services/mcp/src/generated/replay_vision/api.ts
index 479f54b2f8b1..8105bffe06e7 100644
--- a/services/mcp/src/generated/replay_vision/api.ts
+++ b/services/mcp/src/generated/replay_vision/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 12 enabled ops
+ * PostHog API - MCP 19 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -43,6 +43,46 @@ export const VisionObservationsRetrieveParams = /* @__PURE__ */ zod.object({
),
})
+/**
+ * Set or update the observation's shared label: whether the scanner scored the session correctly, plus optional feedback on what it got wrong. One label per observation, shared across the team; these labels feed prompt improvement. Requires session recording edit access.
+ */
+export const VisionObservationsLabelCreateParams = /* @__PURE__ */ zod.object({
+ id: zod.string().describe('A UUID string identifying this replay observation.'),
+ 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 visionObservationsLabelCreateBodyFeedbackDefault = ``
+export const visionObservationsLabelCreateBodyFeedbackMax = 5000
+
+export const VisionObservationsLabelCreateBody = /* @__PURE__ */ zod
+ .object({
+ is_correct: zod.boolean().describe('True if the scanner scored this session correctly, false if not.'),
+ feedback: zod
+ .string()
+ .max(visionObservationsLabelCreateBodyFeedbackMax)
+ .default(visionObservationsLabelCreateBodyFeedbackDefault)
+ .describe(
+ 'Optional written context on the rating, for thumbs-up and thumbs-down alike: what the scanner got right or wrong, or what it should have concluded.'
+ ),
+ })
+ .describe("The team's shared judgement on whether the scanner scored this session correctly.")
+
+/**
+ * Remove the observation's shared label. Requires session recording edit access.
+ */
+export const VisionObservationsLabelDestroyParams = /* @__PURE__ */ zod.object({
+ id: zod.string().describe('A UUID string identifying this replay observation.'),
+ 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 EnvironmentVisionQuotaRetrieveParams = /* @__PURE__ */ zod.object({
project_id: zod
.string()
@@ -378,6 +418,106 @@ export const VisionScannersObservationsRetrieveParams = /* @__PURE__ */ zod.obje
scanner_id: zod.string(),
})
+/**
+ * Aggregate counts and per-scanner-type distributions over the filtered observation set. Same filters as the list endpoint apply.
+ */
+export const VisionScannersObservationsStatsRetrieveParams = /* @__PURE__ */ zod.object({
+ 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/."
+ ),
+ scanner_id: zod.string(),
+})
+
+export const VisionScannersObservationsStatsRetrieveQueryParams = /* @__PURE__ */ zod.object({
+ labeled: zod
+ .string()
+ .optional()
+ .describe(
+ 'When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.'
+ ),
+ recent_days: zod
+ .number()
+ .optional()
+ .describe(
+ 'Window size in days for the coverage `recent_sessions` count. Clamped to [1, 365]. Defaults to 14 when omitted.'
+ ),
+ recording_subject: zod
+ .string()
+ .optional()
+ .describe('Filter to observations whose recording subject email contains this value (case-insensitive).'),
+ session_id: zod
+ .string()
+ .optional()
+ .describe('Filter to observations of one or more session recordings. Accepts a comma-separated list.'),
+ status: zod.string().optional().describe('Filter by observation status. Accepts a comma-separated list.'),
+ tags: zod
+ .string()
+ .optional()
+ .describe(
+ 'Filter classifier observations whose fixed or freeform tags include any of the given values (comma-separated). Matches if the tag appears in either `tags` or `tags_freeform`.'
+ ),
+ triggered_by: zod
+ .string()
+ .optional()
+ .describe('Filter by trigger source (schedule or on_demand). Accepts a comma-separated list.'),
+ verdict: zod
+ .string()
+ .optional()
+ .describe('Filter monitor observations by verdict. Accepts a comma-separated list (e.g. `yes,inconclusive`).'),
+})
+
+/**
+ * Apply this suggestion: write its prompt to the scanner (bumping the scanner version) and mark the suggestion applied. Only the current pending suggestion can be applied. Requires session recording edit access.
+ */
+export const VisionScannersPromptSuggestionsApplyCreateParams = /* @__PURE__ */ zod.object({
+ id: zod.string().describe('A UUID string identifying this replay scanner prompt suggestion.'),
+ 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/."
+ ),
+ scanner_id: zod.string(),
+})
+
+/**
+ * Dismiss this suggestion without applying it. Only the current pending suggestion can be dismissed. Requires session recording edit access.
+ */
+export const VisionScannersPromptSuggestionsDismissCreateParams = /* @__PURE__ */ zod.object({
+ id: zod.string().describe('A UUID string identifying this replay scanner prompt suggestion.'),
+ 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/."
+ ),
+ scanner_id: zod.string(),
+})
+
+/**
+ * The scanner's newest prompt suggestion plus whether it is stale (the ratings changed since it was generated) and how many rated observations are available.
+ */
+export const VisionScannersPromptSuggestionsCurrentRetrieveParams = /* @__PURE__ */ zod.object({
+ 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/."
+ ),
+ scanner_id: zod.string(),
+})
+
+/**
+ * Generate a fresh prompt suggestion from the team's current ratings. The previous pending suggestion becomes history (superseded). Requires at least one rated observation and session recording edit access.
+ */
+export const VisionScannersPromptSuggestionsGenerateCreateParams = /* @__PURE__ */ zod.object({
+ 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/."
+ ),
+ scanner_id: zod.string(),
+})
+
/**
* Estimate the observation volume a proposed scanner would generate, for the pre-save cost preview.
*/
diff --git a/services/mcp/src/tools/generated/replay_vision.ts b/services/mcp/src/tools/generated/replay_vision.ts
index a01590661d89..4497340b79a9 100644
--- a/services/mcp/src/tools/generated/replay_vision.ts
+++ b/services/mcp/src/tools/generated/replay_vision.ts
@@ -3,6 +3,9 @@ import { z } from 'zod'
import type { Schemas } from '@/api/generated'
import {
+ VisionObservationsLabelCreateBody,
+ VisionObservationsLabelCreateParams,
+ VisionObservationsLabelDestroyParams,
VisionObservationsListQueryParams,
VisionObservationsRetrieveParams,
VisionScannersCreateBody,
@@ -12,15 +15,64 @@ import {
VisionScannersObservationsListParams,
VisionScannersObservationsListQueryParams,
VisionScannersObservationsRetrieveParams,
+ VisionScannersObservationsStatsRetrieveParams,
+ VisionScannersObservationsStatsRetrieveQueryParams,
VisionScannersObserveCreateBody,
VisionScannersObserveCreateParams,
VisionScannersPartialUpdateBody,
VisionScannersPartialUpdateParams,
+ VisionScannersPromptSuggestionsApplyCreateParams,
+ VisionScannersPromptSuggestionsCurrentRetrieveParams,
+ VisionScannersPromptSuggestionsDismissCreateParams,
+ VisionScannersPromptSuggestionsGenerateCreateParams,
VisionScannersRetrieveParams,
} from '@/generated/replay_vision/api'
import { withPostHogUrl, type WithPostHogUrl } from '@/tools/tool-utils'
import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
+const VisionObservationsLabelCreateSchema = VisionObservationsLabelCreateParams.omit({ project_id: true }).extend(
+ VisionObservationsLabelCreateBody.shape
+)
+
+const visionObservationsLabelCreate = (): ToolBase<
+ typeof VisionObservationsLabelCreateSchema,
+ Schemas.ReplayObservationLabel
+> => ({
+ name: 'vision-observations-label-create',
+ schema: VisionObservationsLabelCreateSchema,
+ handler: async (context: Context, params: z.infer<typeof VisionObservationsLabelCreateSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.is_correct !== undefined) {
+ body['is_correct'] = params.is_correct
+ }
+ if (params.feedback !== undefined) {
+ body['feedback'] = params.feedback
+ }
+ const result = await context.api.request<Schemas.ReplayObservationLabel>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/vision/observations/${encodeURIComponent(String(params.id))}/label/`,
+ body,
+ })
+ return result
+ },
+})
+
+const VisionObservationsLabelDestroySchema = VisionObservationsLabelDestroyParams.omit({ project_id: true })
+
+const visionObservationsLabelDestroy = (): ToolBase<typeof VisionObservationsLabelDestroySchema, unknown> => ({
+ name: 'vision-observations-label-destroy',
+ schema: VisionObservationsLabelDestroySchema,
+ handler: async (context: Context, params: z.infer<typeof VisionObservationsLabelDestroySchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<unknown>({
+ method: 'DELETE',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/vision/observations/${encodeURIComponent(String(params.id))}/label/`,
+ })
+ return result
+ },
+})
+
const VisionObservationsListSchema = VisionObservationsListQueryParams
const visionObservationsList = (): ToolBase<
@@ -269,6 +321,116 @@ const visionScannersObservationsList = (): ToolBase<
},
})
+const VisionScannersObservationsStatsSchema = VisionScannersObservationsStatsRetrieveParams.omit({
+ project_id: true,
+}).extend(VisionScannersObservationsStatsRetrieveQueryParams.shape)
+
+const visionScannersObservationsStats = (): ToolBase<
+ typeof VisionScannersObservationsStatsSchema,
+ Schemas.ObservationStats
+> => ({
+ name: 'vision-scanners-observations-stats',
+ schema: VisionScannersObservationsStatsSchema,
+ handler: async (context: Context, params: z.infer<typeof VisionScannersObservationsStatsSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.ObservationStats>({
+ method: 'GET',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/vision/scanners/${encodeURIComponent(String(params.scanner_id))}/observations/stats/`,
+ query: {
+ labeled: params.labeled,
+ recent_days: params.recent_days,
+ recording_subject: params.recording_subject,
+ session_id: params.session_id,
+ status: params.status,
+ tags: params.tags,
+ triggered_by: params.triggered_by,
+ verdict: params.verdict,
+ },
+ })
+ return result
+ },
+})
+
+const VisionScannersPromptSuggestionsApplySchema = VisionScannersPromptSuggestionsApplyCreateParams.omit({
+ project_id: true,
+})
+
+const visionScannersPromptSuggestionsApply = (): ToolBase<
+ typeof VisionScannersPromptSuggestionsApplySchema,
+ Schemas.ReplayScannerPromptSuggestion
+> => ({
+ name: 'vision-scanners-prompt-suggestions-apply',
+ schema: VisionScannersPromptSuggestionsApplySchema,
+ handler: async (context: Context, params: z.infer<typeof VisionScannersPromptSuggestionsApplySchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.ReplayScannerPromptSuggestion>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/vision/scanners/${encodeURIComponent(String(params.scanner_id))}/prompt_suggestions/${encodeURIComponent(String(params.id))}/apply/`,
+ })
+ return result
+ },
+})
+
+const VisionScannersPromptSuggestionsCurrentSchema = VisionScannersPromptSuggestionsCurrentRetrieveParams.omit({
+ project_id: true,
+})
+
+const visionScannersPromptSuggestionsCurrent = (): ToolBase<
+ typeof VisionScannersPromptSuggestionsCurrentSchema,
+ Schemas.CurrentPromptSuggestion
+> => ({
+ name: 'vision-scanners-prompt-suggestions-current',
+ schema: VisionScannersPromptSuggestionsCurrentSchema,
+ handler: async (context: Context, params: z.infer<typeof VisionScannersPromptSuggestionsCurrentSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.CurrentPromptSuggestion>({
+ method: 'GET',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/vision/scanners/${encodeURIComponent(String(params.scanner_id))}/prompt_suggestions/current/`,
+ })
+ return result
+ },
+})
+
+const VisionScannersPromptSuggestionsDismissSchema = VisionScannersPromptSuggestionsDismissCreateParams.omit({
+ project_id: true,
+})
+
+const visionScannersPromptSuggestionsDismiss = (): ToolBase<
+ typeof VisionScannersPromptSuggestionsDismissSchema,
+ Schemas.ReplayScannerPromptSuggestion
+> => ({
+ name: 'vision-scanners-prompt-suggestions-dismiss',
+ schema: VisionScannersPromptSuggestionsDismissSchema,
+ handler: async (context: Context, params: z.infer<typeof VisionScannersPromptSuggestionsDismissSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.ReplayScannerPromptSuggestion>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/vision/scanners/${encodeURIComponent(String(params.scanner_id))}/prompt_suggestions/${encodeURIComponent(String(params.id))}/dismiss/`,
+ })
+ return result
+ },
+})
+
+const VisionScannersPromptSuggestionsGenerateSchema = VisionScannersPromptSuggestionsGenerateCreateParams.omit({
+ project_id: true,
+})
+
+const visionScannersPromptSuggestionsGenerate = (): ToolBase<
+ typeof VisionScannersPromptSuggestionsGenerateSchema,
+ Schemas.ReplayScannerPromptSuggestion
+> => ({
+ name: 'vision-scanners-prompt-suggestions-generate',
+ schema: VisionScannersPromptSuggestionsGenerateSchema,
+ handler: async (context: Context, params: z.infer<typeof VisionScannersPromptSuggestionsGenerateSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.ReplayScannerPromptSuggestion>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/vision/scanners/${encodeURIComponent(String(params.scanner_id))}/prompt_suggestions/generate/`,
+ })
+ return result
+ },
+})
+
const VisionScannersScanSessionSchema = VisionScannersObserveCreateParams.omit({ project_id: true }).extend(
VisionScannersObserveCreateBody.shape
)
@@ -344,6 +506,8 @@ const visionScannersUpdate = (): ToolBase<typeof VisionScannersUpdateSchema, Sch
})
export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
+ 'vision-observations-label-create': visionObservationsLabelCreate,
+ 'vision-observations-label-destroy': visionObservationsLabelDestroy,
'vision-observations-list': visionObservationsList,
'vision-observations-retrieve': visionObservationsRetrieve,
'vision-quota-retrieve': visionQuotaRetrieve,
@@ -354,6 +518,11 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'vision-scanners-list': visionScannersList,
'vision-scanners-observations-get': visionScannersObservationsGet,
'vision-scanners-observations-list': visionScannersObservationsList,
+ 'vision-scanners-observations-stats': visionScannersObservationsStats,
+ 'vision-scanners-prompt-suggestions-apply': visionScannersPromptSuggestionsApply,
+ 'vision-scanners-prompt-suggestions-current': visionScannersPromptSuggestionsCurrent,
+ 'vision-scanners-prompt-suggestions-dismiss': visionScannersPromptSuggestionsDismiss,
+ 'vision-scanners-prompt-suggestions-generate': visionScannersPromptSuggestionsGenerate,
'vision-scanners-scan-session': visionScannersScanSession,
'vision-scanners-update': visionScannersUpdate,
}