: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(replay): remove session recording export from the API/MCP (admin-only) (#65035)
Paul D'Ambra6659f2a79e65
diff --git a/products/replay/backend/api/__init__.py b/products/replay/backend/api/__init__.pydeleted file mode 100644index 7aa48eb9a928..000000000000--- a/products/replay/backend/api/__init__.py+++ /dev/null@@ -1,5 +0,0 @@-from .session_recording_export import SessionRecordingExportViewSet--__all__ = [- "SessionRecordingExportViewSet",-]diff --git a/products/replay/backend/api/session_recording_export.py b/products/replay/backend/api/session_recording_export.pydeleted file mode 100644index a04d723be33b..000000000000--- a/products/replay/backend/api/session_recording_export.py+++ /dev/null@@ -1,109 +0,0 @@-from typing import cast--import structlog-from drf_spectacular.utils import OpenApiResponse-from loginas.utils import is_impersonated_session-from rest_framework import mixins, request, response, serializers, status, viewsets-from rest_framework.exceptions import APIException--from posthog.api.documentation import extend_schema-from posthog.api.routing import TeamAndOrgViewSetMixin-from posthog.api.shared import UserBasicSerializer-from posthog.models.user import User-from posthog.permissions import IsStaffUser--from products.replay.backend.models.exported_recording import ExportedRecording-from products.replay.backend.services.export_recording import trigger_recording_export--logger = structlog.get_logger(__name__)---class ExportTriggerFailed(APIException):- status_code = status.HTTP_502_BAD_GATEWAY- default_detail = "Failed to start the export workflow; please retry."- default_code = "export_trigger_failed"---class ExportedRecordingSerializer(serializers.ModelSerializer):- created_by = UserBasicSerializer(read_only=True, help_text="The user who triggered the export.")- is_expired = serializers.BooleanField(- read_only=True,- help_text="True when the export is older than 7 days and its downloadable data may have been purged.",- )-- class Meta:- model = ExportedRecording- fields = [- "id",- "session_id",- "reason",- "status",- "export_location",- "error_message",- "created_at",- "created_by",- "is_expired",- ]- read_only_fields = fields- extra_kwargs = {- "id": {"help_text": "Unique identifier for this export job."},- "session_id": {"help_text": "The `$session_id` of the recording being exported."},- "reason": {"help_text": "Human-provided justification for the export, kept for audit purposes."},- "status": {"help_text": "Lifecycle status of the export: pending, running, complete, or failed."},- "export_location": {- "help_text": "Storage location of the exported data once the job completes; null until status is complete."- },- "error_message": {"help_text": "Failure detail when status is failed; null otherwise."},- "created_at": {"help_text": "When the export was requested."},- }---class ExportedRecordingCreateSerializer(serializers.Serializer):- session_id = serializers.CharField(- max_length=200,- help_text="The `$session_id` of the recording to export.",- )- reason = serializers.CharField(- help_text="Why this recording is being exported. Recorded for audit purposes.",- )---@extend_schema(tags=["replay"])-class SessionRecordingExportViewSet(- TeamAndOrgViewSetMixin,- mixins.ListModelMixin,- mixins.RetrieveModelMixin,- mixins.CreateModelMixin,- viewsets.GenericViewSet,-):- scope_object = "session_recording"- permission_classes = [IsStaffUser]- queryset = ExportedRecording.objects.all().select_related("created_by")- serializer_class = ExportedRecordingSerializer-- @extend_schema(- request=ExportedRecordingCreateSerializer,- responses={- 201: ExportedRecordingSerializer,- 502: OpenApiResponse(description="The export was recorded but the export workflow failed to start."),- },- summary="Trigger a session recording export",- )- def create(self, request: request.Request, *args: object, **kwargs: object) -> response.Response:- create_serializer = ExportedRecordingCreateSerializer(data=request.data)- create_serializer.is_valid(raise_exception=True)-- try:- export_record = trigger_recording_export(- team=self.team,- session_id=create_serializer.validated_data["session_id"],- reason=create_serializer.validated_data["reason"],- user=cast(User, request.user),- was_impersonated=is_impersonated_session(request),- )- except Exception:- logger.exception("session_recording_export_trigger_failed", team_id=self.team.id)- raise ExportTriggerFailed-- output = ExportedRecordingSerializer(export_record, context=self.get_serializer_context())- return response.Response(output.data, status=status.HTTP_201_CREATED)diff --git a/products/replay/backend/routes.py b/products/replay/backend/routes.pydeleted file mode 100644index c0bfc73ca42c..000000000000--- a/products/replay/backend/routes.py+++ /dev/null@@ -1,12 +0,0 @@-from posthog.api.routing import RouterRegistry--from products.replay.backend.api import SessionRecordingExportViewSet---def register_routes(routers: RouterRegistry) -> None:- routers.projects.register(- r"session_recording_exports",- SessionRecordingExportViewSet,- "session_recording_exports",- ["team_id"],- )diff --git a/products/replay/backend/test/test_session_recording_export_api.py b/products/replay/backend/test/test_session_recording_export_api.pydeleted file mode 100644index b73b59747ac2..000000000000--- a/products/replay/backend/test/test_session_recording_export_api.py+++ /dev/null@@ -1,111 +0,0 @@-from posthog.test.base import APIBaseTest-from unittest.mock import patch--from parameterized import parameterized-from rest_framework import status--from posthog.models import Team--from products.replay.backend.models.exported_recording import ExportedRecording--VIEWSET = "products.replay.backend.api.session_recording_export"---class TestSessionRecordingExportAPI(APIBaseTest):- def _url(self, export_id: str | None = None) -> str:- base = f"/api/projects/{self.team.id}/session_recording_exports/"- return f"{base}{export_id}/" if export_id else base-- def _make_staff(self) -> None:- self.user.is_staff = True- self.user.save()-- def _export(self, team: Team | None = None, session_id: str = "session-1") -> ExportedRecording:- return ExportedRecording.objects.create(- team=team or self.team,- session_id=session_id,- reason="because",- created_by=self.user,- )-- def test_staff_create_triggers_export(self) -> None:- self._make_staff()-- def fake_trigger(*, team: Team, session_id: str, reason: str, **_: object) -> ExportedRecording:- return self._export(team=team, session_id=session_id)-- with patch(f"{VIEWSET}.trigger_recording_export", side_effect=fake_trigger) as mock_trigger:- response = self.client.post(- self._url(),- {"session_id": "session-abc", "reason": "investigating a bug"},- )-- assert response.status_code == status.HTTP_201_CREATED, response.json()- assert ExportedRecording.objects.filter(team=self.team).count() == 1- mock_trigger.assert_called_once()- kwargs = mock_trigger.call_args.kwargs- assert kwargs["team"] == self.team- assert kwargs["session_id"] == "session-abc"- assert kwargs["reason"] == "investigating a bug"- assert kwargs["user"] == self.user- assert kwargs["was_impersonated"] is False-- @parameterized.expand(["create", "list", "retrieve"])- def test_non_staff_is_forbidden(self, action: str) -> None:- export = self._export()-- if action == "create":- response = self.client.post(self._url(), {"session_id": "s", "reason": "r"})- elif action == "list":- response = self.client.get(self._url())- else:- response = self.client.get(self._url(str(export.id)))-- assert response.status_code == status.HTTP_403_FORBIDDEN-- def test_staff_can_list_and_retrieve(self) -> None:- self._make_staff()- export = self._export(session_id="session-xyz")-- list_response = self.client.get(self._url())- assert list_response.status_code == status.HTTP_200_OK- results = list_response.json()["results"]- assert len(results) == 1- assert results[0]["session_id"] == "session-xyz"- assert results[0]["status"] == ExportedRecording.Status.PENDING- assert results[0]["created_by"]["id"] == self.user.id-- detail_response = self.client.get(self._url(str(export.id)))- assert detail_response.status_code == status.HTTP_200_OK- assert detail_response.json()["id"] == str(export.id)-- def test_team_isolation(self) -> None:- self._make_staff()- other_team = Team.objects.create(organization=self.organization)- other_export = self._export(team=other_team, session_id="other-team-session")-- list_response = self.client.get(self._url())- assert list_response.status_code == status.HTTP_200_OK- assert list_response.json()["results"] == []-- detail_response = self.client.get(self._url(str(other_export.id)))- assert detail_response.status_code == status.HTTP_404_NOT_FOUND-- @parameterized.expand([("session_id", {"reason": "r"}), ("reason", {"session_id": "s"})])- def test_missing_required_field_is_rejected(self, _name: str, body: dict[str, str]) -> None:- self._make_staff()-- response = self.client.post(self._url(), body)-- assert response.status_code == status.HTTP_400_BAD_REQUEST-- def test_workflow_start_failure_surfaces_error(self) -> None:- self._make_staff()-- with patch(f"{VIEWSET}.trigger_recording_export", side_effect=RuntimeError("temporal down")):- response = self.client.post(- self._url(),- {"session_id": "session-abc", "reason": "investigating a bug"},- )-- assert response.status_code == status.HTTP_502_BAD_GATEWAYdiff --git a/products/replay/frontend/generated/api.schemas.ts b/products/replay/frontend/generated/api.schemas.tsindex 10242009c283..f5d65a1c1979 100644--- a/products/replay/frontend/generated/api.schemas.ts+++ b/products/replay/frontend/generated/api.schemas.ts@@ -7,22 +7,6 @@* PostHog API - generated* OpenAPI spec version: 1.0.0*/-/**- * * `pending` - Pending- * * `running` - Running- * * `complete` - Complete- * * `failed` - Failed- */-export type ExportedRecordingStatusEnumApi =- (typeof ExportedRecordingStatusEnumApi)[keyof typeof ExportedRecordingStatusEnumApi]--export const ExportedRecordingStatusEnumApi = {- Pending: 'pending',- Running: 'running',- Complete: 'complete',- Failed: 'failed',-} as const-/*** * `engineering` - Engineering* * `data` - Data@@ -78,57 +62,6 @@ export interface UserBasicApi {role_at_organization?: RoleAtOrganizationEnumApi | BlankEnumApi | null}-export interface ExportedRecordingApi {- /** Unique identifier for this export job. */- readonly id: string- /** The `$session_id` of the recording being exported. */- readonly session_id: string- /** Human-provided justification for the export, kept for audit purposes. */- readonly reason: string- /** Lifecycle status of the export: pending, running, complete, or failed.- *- * * `pending` - Pending- * * `running` - Running- * * `complete` - Complete- * * `failed` - Failed */- readonly status: ExportedRecordingStatusEnumApi- /**- * Storage location of the exported data once the job completes; null until status is complete.- * @nullable- */- readonly export_location: string | null- /**- * Failure detail when status is failed; null otherwise.- * @nullable- */- readonly error_message: string | null- /** When the export was requested. */- readonly created_at: string- /** The user who triggered the export. */- readonly created_by: UserBasicApi- /** True when the export is older than 7 days and its downloadable data may have been purged. */- readonly is_expired: boolean-}--export interface PaginatedExportedRecordingListApi {- count: number- /** @nullable */- next?: string | null- /** @nullable */- previous?: string | null- results: ExportedRecordingApi[]-}--export interface ExportedRecordingCreateApi {- /**- * The `$session_id` of the recording to export.- * @maxLength 200- */- session_id: string- /** Why this recording is being exported. Recorded for audit purposes. */- reason: string-}-/*** * `collection` - Collection* * `filters` - Filters@@ -524,17 +457,6 @@ export interface SingleSessionSummaryApi {readonly created_by: UserBasicApi | null}-export type SessionRecordingExportsListParams = {- /**- * Number of results to return per page.- */- limit?: number- /**- * The initial index from which to return the results.- */- offset?: number-}-export type SessionRecordingPlaylistsListParams = {created_by?: number/**diff --git a/products/replay/frontend/generated/api.ts b/products/replay/frontend/generated/api.tsindex 827f6ae64fd3..ef9a202826af 100644--- a/products/replay/frontend/generated/api.ts+++ b/products/replay/frontend/generated/api.ts@@ -9,16 +9,12 @@ import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'* OpenAPI spec version: 1.0.0*/import type {- ExportedRecordingApi,- ExportedRecordingCreateApi,- PaginatedExportedRecordingListApi,PaginatedSessionRecordingListApi,PaginatedSessionRecordingPlaylistListApi,PaginatedSingleSessionSummaryMinimalListApi,PatchedSessionRecordingApi,PatchedSessionRecordingPlaylistApi,SessionRecordingApi,- SessionRecordingExportsListParams,SessionRecordingPlaylistApi,SessionRecordingPlaylistsListParams,SessionRecordingsListParams,@@ -44,68 +40,6 @@ type NonReadonly<T> = [T] extends [UnionToIntersection<T>]}: DistributeReadOnlyOverUnions<T>-export const getSessionRecordingExportsListUrl = (projectId: string, params?: SessionRecordingExportsListParams) => {- const normalizedParams = new URLSearchParams()-- Object.entries(params || {}).forEach(([key, value]) => {- if (value !== undefined) {- normalizedParams.append(key, value === null ? 'null' : String(value))- }- })-- const stringifiedParams = normalizedParams.toString()-- return stringifiedParams.length > 0- ? `/api/projects/${projectId}/session_recording_exports/?${stringifiedParams}`- : `/api/projects/${projectId}/session_recording_exports/`-}--export const sessionRecordingExportsList = async (- projectId: string,- params?: SessionRecordingExportsListParams,- options?: RequestInit-): Promise<PaginatedExportedRecordingListApi> => {- return apiMutator<PaginatedExportedRecordingListApi>(getSessionRecordingExportsListUrl(projectId, params), {- ...options,- method: 'GET',- })-}--export const getSessionRecordingExportsCreateUrl = (projectId: string) => {- return `/api/projects/${projectId}/session_recording_exports/`-}--/**- * @summary Trigger a session recording export- */-export const sessionRecordingExportsCreate = async (- projectId: string,- exportedRecordingCreateApi: ExportedRecordingCreateApi,- options?: RequestInit-): Promise<ExportedRecordingApi> => {- return apiMutator<ExportedRecordingApi>(getSessionRecordingExportsCreateUrl(projectId), {- ...options,- method: 'POST',- headers: { 'Content-Type': 'application/json', ...options?.headers },- body: JSON.stringify(exportedRecordingCreateApi),- })-}--export const getSessionRecordingExportsRetrieveUrl = (projectId: string, id: string) => {- return `/api/projects/${projectId}/session_recording_exports/${id}/`-}--export const sessionRecordingExportsRetrieve = async (- projectId: string,- id: string,- options?: RequestInit-): Promise<ExportedRecordingApi> => {- return apiMutator<ExportedRecordingApi>(getSessionRecordingExportsRetrieveUrl(projectId, id), {- ...options,- method: 'GET',- })-}-export const getSessionRecordingPlaylistsListUrl = (projectId: string,params?: SessionRecordingPlaylistsListParamsdiff --git a/products/replay/frontend/generated/api.zod.ts b/products/replay/frontend/generated/api.zod.tsindex 4ca09f9b0195..ff22bf1e2c1e 100644--- a/products/replay/frontend/generated/api.zod.ts+++ b/products/replay/frontend/generated/api.zod.ts@@ -9,19 +9,6 @@*/import * as zod from 'zod'-/**- * @summary Trigger a session recording export- */-export const sessionRecordingExportsCreateBodySessionIdMax = 200--export const SessionRecordingExportsCreateBody = /* @__PURE__ */ zod.object({- session_id: zod- .string()- .max(sessionRecordingExportsCreateBodySessionIdMax)- .describe('The `$session_id` of the recording to export.'),- reason: zod.string().describe('Why this recording is being exported. Recorded for audit purposes.'),-})-export const sessionRecordingPlaylistsCreateBodyNameMax = 400export const sessionRecordingPlaylistsCreateBodyDerivedNameMax = 400diff --git a/products/replay/mcp/tools.yaml b/products/replay/mcp/tools.yamlindex da79be6d015b..d505e52916f2 100644--- a/products/replay/mcp/tools.yaml+++ b/products/replay/mcp/tools.yaml@@ -31,55 +31,6 @@ tools:description: >Delete a session recording by ID. This permanently removes the recording data. Use for privacy or complianceworkflows.- session-recording-export-create:- operation: session_recording_exports_create- enabled: true- scopes:- - session_recording:write- annotations:- readOnly: false- destructive: false- idempotent: false- title: Export session recording- description: >- Trigger an export of a single session recording's data to a downloadable archive. Requires staff access.- Provide the `session_id` and a `reason` (recorded for audit). Returns an export job whose `status` starts as- `pending`; poll `session-recording-export-get` with the returned `id` until `status` is `complete`, then- read `export_location` for the archive's storage path. The export gathers recording blocks plus related- ClickHouse metadata, so completion is not instant.- feature_flag: replay-admin-export- session-recording-export-get:- operation: session_recording_exports_retrieve- enabled: true- scopes:- - session_recording:read- annotations:- readOnly: true- destructive: false- idempotent: true- enrich_url: '{id}'- title: Get session recording export- description: >- Get a single session recording export job by `id`. Requires staff access. Returns its `status`- (pending/running/complete/failed), `export_location` (the archive's storage path, populated once `status` is- `complete`), any `error_message`, and `is_expired` (exports older than 7 days may have been purged). Use- after `session-recording-export-create` to poll for completion.- feature_flag: replay-admin-export- session-recording-exports-list:- operation: session_recording_exports_list- enabled: true- scopes:- - session_recording:read- annotations:- readOnly: true- destructive: false- idempotent: true- list: true- title: List session recording exports- description: >- List past session recording export jobs for the project, newest first. Requires staff access. Use to find an- export's `id` and `status` before reading its download location via `session-recording-export-get`.- feature_flag: replay-admin-exportsession-recording-get:operation: session_recordings_retrieveenabled: truediff --git a/products/replay/skills/exporting-session-recordings/SKILL.md b/products/replay/skills/exporting-session-recordings/SKILL.mdindex f4ac2daea1d1..f8c10773e6eb 100644--- a/products/replay/skills/exporting-session-recordings/SKILL.md+++ b/products/replay/skills/exporting-session-recordings/SKILL.md@@ -2,13 +2,12 @@name: exporting-session-recordingsdescription: >-Export a single session recording's raw data (recording blocks + ClickHouse- metadata) to a downloadable zip, and download it. Staff-only. Use when asked to- "export a session recording", "get the raw recording data", "download a replay- export", "pull a recording for analysis/support", or to inspect recording block /- canvas frame sizes offline. Explains why the MCP export tool only works for the- active project, how to export a recording owned by any other team via the django- admin portal (and how to build the right admin links), and how to download the- archive (there is no download API or MCP tool).+ metadata) to a downloadable zip, and download it. Staff-only, via the django+ admin portal. Use when asked to "export a session recording", "get the raw+ recording data", "download a replay export", "pull a recording for+ analysis/support", or to inspect recording block / canvas frame sizes offline.+ Explains the team-ownership rule, how to build the admin export / download links+ for the owning team, and that there is no export or download API/MCP tool.---# Exporting session recordings@@ -18,70 +17,56 @@ Exporting bundles a recording's storage blocks plus its ClickHouse metadataoffline analysis or support. It is **staff-only** and writes nothing back to therecording.-## The one rule that matters: export team must own the recording+There is **no export API or MCP tool** — a recording export is a cross-tenant,+token/agent-reachable PII export, which is too dangerous to expose on the+programmatic surface. Exporting (and downloading) is done **only** through the+django admin portal, under interactive staff auth. Your job is to hand the user+the right admin links.-The export workflow fetches recording blocks and events **filtered by the team the-export is run for**. Block storage is keyed by team, and the events query filters-`team_id`. If that team does not own the `session_id`, the job still reaches+## The one rule that matters: export from the team that owns the recording++The export workflow fetches recording blocks and events **filtered by the team you+run the export for** (block storage is keyed by team; the events query filters+`team_id`). If you run it for the wrong team, the job still reaches`status: complete` — but the zip is **empty** (zero blocks, empty `events.json`)."Complete" means "the workflow ran", not "it found data".-The owning `team_id` is visible in the recording's storage path and in-`export_location` (`session_recording_exports/<team_id>/<session_id>/<uuid>.zip`).--## Which path to use--| The recording belongs to… | Use |-| -------------------------- | --------------------------------------------------- |-| the **active MCP project** | the MCP tool `session-recording-export-create` |-| **any other team** | the **django admin portal** (build the links below) |--The MCP/API export only ever runs for the active project — there is deliberately-**no cross-team `team_id` parameter** (a token- or agent-reachable cross-tenant PII-export is too dangerous a capability to expose on the API surface). Cross-team-export stays behind interactive, staff-authenticated django admin. So: never call-the MCP tool with a `session_id` from another team — you'd just get an empty-archive. Send the user to the admin portal instead.--## Same-project recording (MCP)--1. `session-recording-export-create { session_id, reason }` — `reason` is audited;- keep it specific. Returns a job with `status: pending`.-2. Poll `session-recording-export-get { id }` until `status` is `complete` or- `failed`. Small recordings take seconds to a couple of minutes (it gathers blocks- plus ClickHouse metadata). `failed` carries an `error_message`.-3. Download via admin (see below).+So always export from the **owning team's** admin page. The owning `team_id` is+visible in the recording's storage path and in `export_location`+(`session_recording_exports/<team_id>/<session_id>/<uuid>.zip`).-## Any other team's recording (admin portal — generate these links)+## Exporting via the admin portal (generate these links)You need the **owning `team_id`** to build the links. If you only have a`session_id`, get the team from the recording's project (or ask the user). Use thecorrect region host — `us.posthog.com` or `eu.posthog.com` — matching where therecording lives.-- **Trigger the export** (form takes `session_id` + `reason`):+- **Trigger the export** (form takes `session_id` + `reason`; `reason` is audited):`https://<region>.posthog.com/admin/posthog/team/<team_id>/export-replay/`- **See exports + download buttons** for that team:`https://<region>.posthog.com/admin/posthog/team/<team_id>/export-history/`-- **Direct download** of one archive once complete:+- **Direct download** of one archive once `status` is `complete`:`https://<region>.posthog.com/admin/posthog/team/<team_id>/download-export/<export_id>/`Hand the user the export-replay link to start it, then the export-history link to-download. This is the right tool for "export a customer's recording" — present the-links rather than attempting it via MCP.+poll status and download. A small recording takes seconds to a couple of minutes+(it gathers blocks plus ClickHouse metadata); the export-history page shows+`pending` / `running` / `complete` / `failed`.## Downloading the archive-There is **no download API endpoint and no MCP download tool** — the export only-exposes a storage key. Downloads go through django admin (the links above). The-download view streams the zip straight from the replay-v2 S3 bucket as-`export-<session_id>.zip`; the admin pod holds the prod credentials, so a local dev-or agent session cannot `aws s3 cp` the key itself.+The download view (export-history / download-export links above) streams the zip+straight from the replay-v2 S3 bucket as `export-<session_id>.zip`. `export_location`+is only a storage key, not a URL. The admin pod holds the prod credentials, so a+local dev or agent session cannot `aws s3 cp` the key itself — the user downloads+from the admin page in their browser.## Gotchas- **Empty-but-complete** is the failure mode to watch for — see the team rule. If an- archive is unexpectedly tiny, the export almost certainly ran for the wrong team.+ archive is unexpectedly tiny, the export almost certainly ran from the wrong+ team's admin page.- **Expiry:** exports older than 7 days report `is_expired: true` and their data maybe purged. Re-export rather than relying on an old job.- **Stuck `running`:** a failed export used to sit in `running` forever; a new exportdiff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex cc407787e1e1..d8ac2690a310 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -5891,51 +5891,6 @@"readOnlyHint": false}},- "session-recording-export-create": {- "description": "Trigger an export of a single session recording's data to a downloadable archive. Requires staff access. Provide the `session_id` and a `reason` (recorded for audit). Returns an export job whose `status` starts as `pending`; poll `session-recording-export-get` with the returned `id` until `status` is `complete`, then read `export_location` for the archive's storage path. The export gathers recording blocks plus related ClickHouse metadata, so completion is not instant.",- "category": "Session replays",- "feature": "replay",- "summary": "Export session recording",- "title": "Export session recording",- "required_scopes": ["session_recording:write"],- "annotations": {- "destructiveHint": false,- "idempotentHint": false,- "openWorldHint": true,- "readOnlyHint": false- },- "feature_flag": "replay-admin-export"- },- "session-recording-export-get": {- "description": "Get a single session recording export job by `id`. Requires staff access. Returns its `status` (pending/running/complete/failed), `export_location` (the archive's storage path, populated once `status` is `complete`), any `error_message`, and `is_expired` (exports older than 7 days may have been purged). Use after `session-recording-export-create` to poll for completion.",- "category": "Session replays",- "feature": "replay",- "summary": "Get session recording export",- "title": "Get session recording export",- "required_scopes": ["session_recording:read"],- "annotations": {- "destructiveHint": false,- "idempotentHint": true,- "openWorldHint": true,- "readOnlyHint": true- },- "feature_flag": "replay-admin-export"- },- "session-recording-exports-list": {- "description": "List past session recording export jobs for the project, newest first. Requires staff access. Use to find an export's `id` and `status` before reading its download location via `session-recording-export-get`.",- "category": "Session replays",- "feature": "replay",- "summary": "List session recording exports",- "title": "List session recording exports",- "required_scopes": ["session_recording:read"],- "annotations": {- "destructiveHint": false,- "idempotentHint": true,- "openWorldHint": true,- "readOnlyHint": true- },- "feature_flag": "replay-admin-export"- },"session-recording-get": {"description": "Get a specific session recording by ID. Returns full recording metadata including duration, interaction counts, console log counts, person info, and viewing status. Session recordings are reachable from events, errors, and persons via the `$session_id` property on events. Any `$session_id` value from an event can be passed as the `id` parameter to this tool. Note: a `$session_id` on an event does not guarantee a recording exists — session replay may not be enabled for that project or session. A 404 means no recording was captured. If the user wants to understand what happened without watching the recording, check `vision-observations-list` for an existing Replay Vision AI summary, or run a summarizer scanner via `vision-scanners-scan-session` (see the investigating-replay skill; scanning is slow). If a recording is missing (404) or the user asks why recordings aren't being captured, diagnose with `execute-sql`: query `$recording_status`, `$session_recording_start_reason`, `$replay_sample_rate`, and `$sdk_debug_recording_script_not_loaded` from the events table (filter by `$session_id` for a specific session, or sample recent events for project-wide issues).","category": "Session replays",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 0203895ff846..c9b43843fc8e 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -6370,51 +6370,6 @@"readOnlyHint": false}},- "session-recording-export-create": {- "description": "Trigger an export of a single session recording's data to a downloadable archive. Requires staff access. Provide the `session_id` and a `reason` (recorded for audit). Returns an export job whose `status` starts as `pending`; poll `session-recording-export-get` with the returned `id` until `status` is `complete`, then read `export_location` for the archive's storage path. The export gathers recording blocks plus related ClickHouse metadata, so completion is not instant.",- "category": "Session replays",- "feature": "replay",- "summary": "Export session recording",- "title": "Export session recording",- "required_scopes": ["session_recording:write"],- "annotations": {- "destructiveHint": false,- "idempotentHint": false,- "openWorldHint": true,- "readOnlyHint": false- },- "feature_flag": "replay-admin-export"- },- "session-recording-export-get": {- "description": "Get a single session recording export job by `id`. Requires staff access. Returns its `status` (pending/running/complete/failed), `export_location` (the archive's storage path, populated once `status` is `complete`), any `error_message`, and `is_expired` (exports older than 7 days may have been purged). Use after `session-recording-export-create` to poll for completion.",- "category": "Session replays",- "feature": "replay",- "summary": "Get session recording export",- "title": "Get session recording export",- "required_scopes": ["session_recording:read"],- "annotations": {- "destructiveHint": false,- "idempotentHint": true,- "openWorldHint": true,- "readOnlyHint": true- },- "feature_flag": "replay-admin-export"- },- "session-recording-exports-list": {- "description": "List past session recording export jobs for the project, newest first. Requires staff access. Use to find an export's `id` and `status` before reading its download location via `session-recording-export-get`.",- "category": "Session replays",- "feature": "replay",- "summary": "List session recording exports",- "title": "List session recording exports",- "required_scopes": ["session_recording:read"],- "annotations": {- "destructiveHint": false,- "idempotentHint": true,- "openWorldHint": true,- "readOnlyHint": true- },- "feature_flag": "replay-admin-export"- },"session-recording-get": {"description": "Get a specific session recording by ID. Returns full recording metadata including duration, interaction counts, console log counts, person info, and viewing status. Session recordings are reachable from events, errors, and persons via the `$session_id` property on events. Any `$session_id` value from an event can be passed as the `id` parameter to this tool. Note: a `$session_id` on an event does not guarantee a recording exists — session replay may not be enabled for that project or session. A 404 means no recording was captured. If the user wants to understand what happened without watching the recording, check `vision-observations-list` for an existing Replay Vision AI summary, or run a summarizer scanner via `vision-scanners-scan-session` (see the investigating-replay skill; scanning is slow). If a recording is missing (404) or the user asks why recordings aren't being captured, diagnose with `execute-sql`: query `$recording_status`, `$session_recording_start_reason`, `$replay_sample_rate`, and `$sdk_debug_recording_script_not_loaded` from the events table (filter by `$session_id` for a specific session, or sample recent events for project-wide issues).","category": "Session replays",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 916e8b4c9a8a..c32113c6b887 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -21019,64 +21019,6 @@ export namespace Schemas {readonly exception: string | null;}- /**- * * `pending` - Pending- * * `running` - Running- * * `complete` - Complete- * * `failed` - Failed- */- export type ExportedRecordingStatusEnum = typeof ExportedRecordingStatusEnum[keyof typeof ExportedRecordingStatusEnum];--- export const ExportedRecordingStatusEnum = {- Pending: 'pending',- Running: 'running',- Complete: 'complete',- Failed: 'failed',- } as const;-- export interface ExportedRecording {- /** Unique identifier for this export job. */- readonly id: string;- /** The `$session_id` of the recording being exported. */- readonly session_id: string;- /** Human-provided justification for the export, kept for audit purposes. */- readonly reason: string;- /** Lifecycle status of the export: pending, running, complete, or failed.- *- * * `pending` - Pending- * * `running` - Running- * * `complete` - Complete- * * `failed` - Failed */- readonly status: ExportedRecordingStatusEnum;- /**- * Storage location of the exported data once the job completes; null until status is complete.- * @nullable- */- readonly export_location: string | null;- /**- * Failure detail when status is failed; null otherwise.- * @nullable- */- readonly error_message: string | null;- /** When the export was requested. */- readonly created_at: string;- /** The user who triggered the export. */- readonly created_by: UserBasic;- /** True when the export is older than 7 days and its downloadable data may have been purged. */- readonly is_expired: boolean;- }-- export interface ExportedRecordingCreate {- /**- * The `$session_id` of the recording to export.- * @maxLength 200- */- session_id: string;- /** Why this recording is being exported. Recorded for audit purposes. */- reason: string;- }-/*** @nullable*/@@ -29827,15 +29769,6 @@ export namespace Schemas {results: ExportedAsset[];}- export interface PaginatedExportedRecordingList {- count: number;- /** @nullable */- next?: string | null;- /** @nullable */- previous?: string | null;- results: ExportedRecording[];- }-export interface PaginatedExternalDataSchemaList {count: number;/** @nullable */@@ -61209,17 +61142,6 @@ export namespace Schemas {offset?: number;};- export type SessionRecordingExportsListParams = {- /**- * Number of results to return per page.- */- limit?: number;- /**- * The initial index from which to return the results.- */- offset?: number;- };-export type SessionRecordingExternalReferencesListParams = {/*** Number of results to return per page.diff --git a/services/mcp/src/generated/replay/api.ts b/services/mcp/src/generated/replay/api.tsindex da105d811839..14198c416695 100644--- a/services/mcp/src/generated/replay/api.ts+++ b/services/mcp/src/generated/replay/api.ts@@ -3,54 +3,11 @@* MCP service uses these Zod schemas for generated tool handlers.* To regenerate: hogli build:openapi*- * PostHog API - MCP 11 enabled ops+ * PostHog API - MCP 8 enabled ops* OpenAPI spec version: 1.0.0*/import * as zod from 'zod'-export const SessionRecordingExportsListParams = /* @__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/."- ),-})--export const SessionRecordingExportsListQueryParams = /* @__PURE__ */ zod.object({- limit: zod.number().optional().describe('Number of results to return per page.'),- offset: zod.number().optional().describe('The initial index from which to return the results.'),-})--/**- * @summary Trigger a session recording export- */-export const SessionRecordingExportsCreateParams = /* @__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/."- ),-})--export const sessionRecordingExportsCreateBodySessionIdMax = 200--export const SessionRecordingExportsCreateBody = /* @__PURE__ */ zod.object({- session_id: zod- .string()- .max(sessionRecordingExportsCreateBodySessionIdMax)- .describe('The `$session_id` of the recording to export.'),- reason: zod.string().describe('Why this recording is being exported. Recorded for audit purposes.'),-})--export const SessionRecordingExportsRetrieveParams = /* @__PURE__ */ zod.object({- id: zod.string().describe('A UUID string identifying this exported recording.'),- 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/."- ),-})-/*** Override list to include synthetic playlists.*diff --git a/services/mcp/src/tools/generated/replay.ts b/services/mcp/src/tools/generated/replay.tsindex aea615cbd608..798242ab3e93 100644--- a/services/mcp/src/tools/generated/replay.ts+++ b/services/mcp/src/tools/generated/replay.ts@@ -3,9 +3,6 @@ import { z } from 'zod'import type { Schemas } from '@/api/generated'import {- SessionRecordingExportsCreateBody,- SessionRecordingExportsListQueryParams,- SessionRecordingExportsRetrieveParams,SessionRecordingPlaylistsCreateBody,SessionRecordingPlaylistsListQueryParams,SessionRecordingPlaylistsPartialUpdateBody,@@ -36,72 +33,6 @@ const sessionRecordingDelete = (): ToolBase<typeof SessionRecordingDeleteSchema,},})-const SessionRecordingExportCreateSchema = SessionRecordingExportsCreateBody--const sessionRecordingExportCreate = (): ToolBase<- typeof SessionRecordingExportCreateSchema,- Schemas.ExportedRecording-> => ({- name: 'session-recording-export-create',- schema: SessionRecordingExportCreateSchema,- handler: async (context: Context, params: z.infer<typeof SessionRecordingExportCreateSchema>) => {- const projectId = await context.stateManager.getProjectId()- const body: Record<string, unknown> = {}- if (params.session_id !== undefined) {- body['session_id'] = params.session_id- }- if (params.reason !== undefined) {- body['reason'] = params.reason- }- const result = await context.api.request<Schemas.ExportedRecording>({- method: 'POST',- path: `/api/projects/${encodeURIComponent(String(projectId))}/session_recording_exports/`,- body,- })- return result- },-})--const SessionRecordingExportGetSchema = SessionRecordingExportsRetrieveParams.omit({ project_id: true })--const sessionRecordingExportGet = (): ToolBase<- typeof SessionRecordingExportGetSchema,- WithPostHogUrl<Schemas.ExportedRecording>-> => ({- name: 'session-recording-export-get',- schema: SessionRecordingExportGetSchema,- handler: async (context: Context, params: z.infer<typeof SessionRecordingExportGetSchema>) => {- const projectId = await context.stateManager.getProjectId()- const result = await context.api.request<Schemas.ExportedRecording>({- method: 'GET',- path: `/api/projects/${encodeURIComponent(String(projectId))}/session_recording_exports/${encodeURIComponent(String(params.id))}/`,- })- return await withPostHogUrl(context, result, `/replay/${result.id}`)- },-})--const SessionRecordingExportsListSchema = SessionRecordingExportsListQueryParams--const sessionRecordingExportsList = (): ToolBase<- typeof SessionRecordingExportsListSchema,- WithPostHogUrl<Schemas.PaginatedExportedRecordingList>-> => ({- name: 'session-recording-exports-list',- schema: SessionRecordingExportsListSchema,- handler: async (context: Context, params: z.infer<typeof SessionRecordingExportsListSchema>) => {- const projectId = await context.stateManager.getProjectId()- const result = await context.api.request<Schemas.PaginatedExportedRecordingList>({- method: 'GET',- path: `/api/projects/${encodeURIComponent(String(projectId))}/session_recording_exports/`,- query: {- limit: params.limit,- offset: params.offset,- },- })- return await withPostHogUrl(context, result, '/replay')- },-})-const SessionRecordingGetSchema = SessionRecordingsRetrieveParams.omit({ project_id: true })const sessionRecordingGet = (): ToolBase<typeof SessionRecordingGetSchema, WithPostHogUrl<Schemas.SessionRecording>> =>@@ -733,9 +664,6 @@ const AssistantRecordingsQuery = z.object({export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'session-recording-delete': sessionRecordingDelete,- 'session-recording-export-create': sessionRecordingExportCreate,- 'session-recording-export-get': sessionRecordingExportGet,- 'session-recording-exports-list': sessionRecordingExportsList,'session-recording-get': sessionRecordingGet,'session-recording-playlist-create': sessionRecordingPlaylistCreate,'session-recording-playlist-get': sessionRecordingPlaylistGet,diff --git a/services/mcp/tests/unit/tool-filtering.test.ts b/services/mcp/tests/unit/tool-filtering.test.tsindex 5e9077e32d31..f76b8fc37e81 100644--- a/services/mcp/tests/unit/tool-filtering.test.ts+++ b/services/mcp/tests/unit/tool-filtering.test.ts@@ -751,10 +751,9 @@ describe('Tool Filtering - Feature Flags', () => {'field-notes','mcp-analytics','metrics',- 'replay-admin-export',]))- expect(flags).toHaveLength(20)+ expect(flags).toHaveLength(19)})// Exercise the real predicate (toolPassesFlagGate) over hand-rolled entries