: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
feat(dashboards): add delete_tile endpoint and dashboard-delete-tile MCP tool (#60520)
Sam Pennington32b9e97b757a
diff --git a/posthog/api/test/dashboards/test_dashboard_delete_tile.py b/posthog/api/test/dashboards/test_dashboard_delete_tile.pynew file mode 100644index 000000000000..8453c7f17fd6--- /dev/null+++ b/posthog/api/test/dashboards/test_dashboard_delete_tile.py@@ -0,0 +1,167 @@+from posthog.test.base import APIBaseTest++from django.test import override_settings++from parameterized import parameterized+from rest_framework import status++from posthog.api.test.dashboards import DashboardAPI++from products.dashboards.backend.models.dashboard_tile import DashboardTile+++@override_settings(IN_UNIT_TESTING=True)+class TestDashboardDeleteTile(APIBaseTest):+ def setUp(self) -> None:+ super().setUp()+ self.dashboard_api = DashboardAPI(self.client, self.team, self.assertEqual)++ def _delete_tile(self, dashboard_id: int, tile_id: int, expected_status: int = status.HTTP_204_NO_CONTENT):+ response = self.client.post(+ f"/api/projects/{self.team.id}/dashboards/{dashboard_id}/delete_tile",+ {"tile_id": tile_id},+ )+ self.assertEqual(response.status_code, expected_status, response.content)+ return response++ def test_can_delete_a_text_tile(self) -> None:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="hello world")+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="second tile")++ tile_to_delete = dashboard_json["tiles"][0]+ self._delete_tile(dashboard_id, tile_to_delete["id"])++ remaining = self.dashboard_api.get_dashboard(dashboard_id)["tiles"]+ assert len(remaining) == 1+ assert remaining[0]["id"] != tile_to_delete["id"]++ tile = DashboardTile.objects_including_soft_deleted.get(id=tile_to_delete["id"])+ assert tile.deleted is True+ assert tile.text is not None++ def test_can_delete_an_insight_tile_without_deleting_the_insight(self) -> None:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ insight_id, _ = self.dashboard_api.create_insight({"name": "insight", "dashboards": [dashboard_id]})++ dashboard_json = self.dashboard_api.get_dashboard(dashboard_id)+ assert len(dashboard_json["tiles"]) == 1+ tile_id = dashboard_json["tiles"][0]["id"]++ self._delete_tile(dashboard_id, tile_id)++ assert self.dashboard_api.get_dashboard(dashboard_id)["tiles"] == []+ insight_response = self.client.get(f"/api/projects/{self.team.id}/insights/{insight_id}")+ assert insight_response.status_code == status.HTTP_200_OK++ def _setup_unknown_tile_id(self) -> tuple[int, int]:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ return dashboard_id, 9_999_999++ def _setup_tile_from_other_dashboard(self) -> tuple[int, int]:+ dashboard_a, _ = self.dashboard_api.create_dashboard({"name": "a"})+ dashboard_b, _ = self.dashboard_api.create_dashboard({"name": "b"})+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_a, text="on a")+ tile_id = dashboard_json["tiles"][0]["id"]+ return dashboard_b, tile_id++ def _setup_parent_dashboard_soft_deleted(self) -> tuple[int, int]:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="hi")+ tile_id = dashboard_json["tiles"][0]["id"]+ self.client.patch(f"/api/projects/{self.team.id}/dashboards/{dashboard_id}", {"deleted": True})+ return dashboard_id, tile_id++ def _setup_tile_already_soft_deleted(self) -> tuple[int, int]:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="hi")+ tile_id = dashboard_json["tiles"][0]["id"]+ self._delete_tile(dashboard_id, tile_id)+ return dashboard_id, tile_id++ @parameterized.expand(+ [+ ("unknown_tile_id", _setup_unknown_tile_id),+ ("tile_belongs_to_other_dashboard", _setup_tile_from_other_dashboard),+ ("parent_dashboard_soft_deleted", _setup_parent_dashboard_soft_deleted),+ ("tile_already_soft_deleted", _setup_tile_already_soft_deleted),+ ]+ )+ def test_delete_returns_404(self, _name, setup) -> None:+ dashboard_id, tile_id = setup(self)+ self._delete_tile(dashboard_id, tile_id, expected_status=status.HTTP_404_NOT_FOUND)++ def test_delete_tile_requires_tile_id(self) -> None:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ response = self.client.post(f"/api/projects/{self.team.id}/dashboards/{dashboard_id}/delete_tile", {})+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)++ def test_delete_tile_compacts_remaining_layout(self) -> None:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="top")+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="middle")+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="bottom")++ tile_ids = [tile["id"] for tile in dashboard_json["tiles"]]+ for index, tile_id in enumerate(tile_ids):+ DashboardTile.objects.filter(id=tile_id).update(+ layouts={+ "sm": {"x": 0, "y": index * 5, "w": 6, "h": 5},+ "xs": {"x": 0, "y": index * 5, "w": 6, "h": 5},+ }+ )++ # Remove the middle tile (y=5); the bottom tile should slide up into the gap.+ self._delete_tile(dashboard_id, tile_ids[1])++ top = DashboardTile.objects.get(id=tile_ids[0])+ bottom = DashboardTile.objects.get(id=tile_ids[2])+ assert top.layouts["sm"] == {"x": 0, "y": 0, "w": 6, "h": 5}+ # Compaction preserves x/w/h and only pulls y up to close the gap (10 -> 5).+ assert bottom.layouts["sm"] == {"x": 0, "y": 5, "w": 6, "h": 5}+ assert bottom.layouts["xs"] == {"x": 0, "y": 5, "w": 6, "h": 5}++ def test_delete_tile_compacts_per_column_without_disturbing_other_columns(self) -> None:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="left top")+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="right top")+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="left middle")+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="right gapped")++ tile_ids = [tile["id"] for tile in dashboard_json["tiles"]]+ layouts = [+ {"x": 0, "y": 0, "w": 6, "h": 5}, # left top+ {"x": 6, "y": 0, "w": 6, "h": 5}, # right top+ {"x": 0, "y": 5, "w": 6, "h": 5}, # left middle (to be deleted)+ {"x": 6, "y": 10, "w": 6, "h": 5}, # right column, with a gap at rows 5-9+ ]+ for tile_id, layout in zip(tile_ids, layouts):+ DashboardTile.objects.filter(id=tile_id).update(layouts={"sm": layout, "xs": {**layout, "x": 0, "w": 1}})++ self._delete_tile(dashboard_id, tile_ids[2])++ left_top = DashboardTile.objects.get(id=tile_ids[0])+ right_top = DashboardTile.objects.get(id=tile_ids[1])+ right_gapped = DashboardTile.objects.get(id=tile_ids[3])+ # Untouched tiles keep their exact positions; the right column's gap closes (10 -> 5),+ # which is only correct if the overlap check keeps it in its own column (x stays 6).+ assert left_top.layouts["sm"] == {"x": 0, "y": 0, "w": 6, "h": 5}+ assert right_top.layouts["sm"] == {"x": 6, "y": 0, "w": 6, "h": 5}+ assert right_gapped.layouts["sm"] == {"x": 6, "y": 5, "w": 6, "h": 5}++ def test_delete_tile_leaves_tiles_without_layouts_alone(self) -> None:+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="positioned")+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="unpositioned")+ _, dashboard_json = self.dashboard_api.create_text_tile(dashboard_id, text="to delete")++ tile_ids = [tile["id"] for tile in dashboard_json["tiles"]]+ DashboardTile.objects.filter(id=tile_ids[0]).update(layouts={"sm": {"x": 0, "y": 10, "w": 6, "h": 5}})+ DashboardTile.objects.filter(id=tile_ids[1]).update(layouts={})++ self._delete_tile(dashboard_id, tile_ids[2])++ positioned = DashboardTile.objects.get(id=tile_ids[0])+ unpositioned = DashboardTile.objects.get(id=tile_ids[1])+ assert positioned.layouts["sm"] == {"x": 0, "y": 0, "w": 6, "h": 5}+ assert unpositioned.layouts == {}diff --git a/products/dashboards/backend/api/dashboard.py b/products/dashboards/backend/api/dashboard.pyindex 3081a2d559c5..1917dd98260b 100644--- a/products/dashboards/backend/api/dashboard.py+++ b/products/dashboards/backend/api/dashboard.py@@ -129,6 +129,55 @@ FILTERS_OVERRIDE_PARAM = make_filters_override_param(subject_label="dashboard")tracer = trace.get_tracer(__name__)+def _tile_rects_overlap(rect_a: dict[str, int], rect_b: dict[str, int]) -> bool:+ return not (+ rect_a["x"] + rect_a["w"] <= rect_b["x"]+ or rect_b["x"] + rect_b["w"] <= rect_a["x"]+ or rect_a["y"] + rect_a["h"] <= rect_b["y"]+ or rect_b["y"] + rect_b["h"] <= rect_a["y"]+ )+++def _compact_tile_layouts(tiles: list["DashboardTile"]) -> set[int]:+ """Vertically compact tile layouts in place, mirroring the dashboard grid's default+ react-grid-layout vertical compaction (gravity up). Each breakpoint is compacted+ independently: tiles keep their x/w/h and are pulled up to the lowest free row.+ Returns the ids of tiles whose layouts changed.+ """+ for tile in tiles:+ if isinstance(tile.layouts, str):+ tile.layouts = json.loads(tile.layouts)++ changed: set[int] = set()+ breakpoints: set[str] = set()+ for tile in tiles:+ if isinstance(tile.layouts, dict):+ breakpoints.update(tile.layouts.keys())++ for breakpoint in breakpoints:+ entries = [+ tile for tile in tiles if isinstance(tile.layouts, dict) and isinstance(tile.layouts.get(breakpoint), dict)+ ]+ placed: list[dict[str, int]] = []+ for tile in DashboardTile.sort_tiles_by_layout(entries, breakpoint):+ layout = tile.layouts[breakpoint]+ rect = {"x": layout.get("x", 0), "y": layout.get("y", 0), "w": layout.get("w", 1), "h": layout.get("h", 1)}+ # Drop the tile to the lowest free row. Jump past colliding tiles rather than+ # scanning row-by-row, so an editor-supplied giant height can't blow up the loop.+ new_y = 0+ while True:+ collisions = [pr for pr in placed if _tile_rects_overlap({**rect, "y": new_y}, pr)]+ if not collisions:+ break+ new_y = max(pr["y"] + pr["h"] for pr in collisions)+ placed.append({**rect, "y": new_y})+ if new_y != layout.get("y", 0):+ layout["y"] = new_y+ changed.add(tile.id)++ return changed++def serialize_tile_with_context(tile, order: int, context: dict) -> tuple[int, dict]:"""Serialize a single tile with error handling. Returns (order, tile_data) tuple.@@ -345,6 +394,13 @@ class UpdateTextTileRequestSerializer(serializers.Serializer):)+class DeleteTileRequestSerializer(serializers.Serializer):+ tile_id = serializers.IntegerField(+ required=True,+ help_text="ID of the dashboard tile to delete. Use dashboard-get to look up tile IDs.",+ )++class CanEditDashboard(BasePermission):message = "You don't have edit permissions for this dashboard."@@ -1903,6 +1959,51 @@ class DashboardsViewSet(tile.refresh_from_db()return Response(DashboardTileSerializer(tile, context=self.get_serializer_context()).data)+ @extend_schema(+ operation_id="dashboards_delete_tile",+ request=DeleteTileRequestSerializer,+ responses={204: None},+ )+ @action(methods=["POST"], detail=True, required_scopes=["dashboard:write"])+ def delete_tile(self, request: Request, *args: Any, **kwargs: Any) -> Response:+ """Soft-delete a single tile from a dashboard.++ Works for text, insight, and button tiles. The underlying Insight, Text, or ButtonTile+ object is preserved — only the dashboard tile is hidden. To delete the entire dashboard,+ use the dashboard delete endpoint instead.+ """+ dashboard = self.get_object()+ if dashboard.deleted:+ raise exceptions.NotFound()+ if not self.user_permissions.dashboard(dashboard).can_edit:+ raise exceptions.PermissionDenied("You don't have edit permissions for this dashboard.")++ serializer = DeleteTileRequestSerializer(data=request.data)+ serializer.is_valid(raise_exception=True)+ tile_id = serializer.validated_data["tile_id"]++ tile = get_object_or_404(+ DashboardTile,+ id=tile_id,+ dashboard=dashboard,+ dashboard__team__project_id=self.team.project_id,+ )+ # Collapse the vertical gap the removed tile leaves, matching the dashboard UI+ # (react-grid-layout compacts upward on render but never persists it).+ with transaction.atomic():+ tile.deleted = True+ tile.save(update_fields=["deleted"])++ remaining = list(DashboardTile.objects.filter(dashboard=dashboard))+ changed_ids = _compact_tile_layouts(remaining)+ if changed_ids:+ DashboardTile.objects.bulk_update(+ [remaining_tile for remaining_tile in remaining if remaining_tile.id in changed_ids],+ ["layouts"],+ )++ return Response(status=status.HTTP_204_NO_CONTENT)+@extend_schema(parameters=[OpenApiParameter(diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex d8a9a58702bb..77dd8d7b112b 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -7456,6 +7456,11 @@ export interface DashboardTileApi {readonly widget: NestedApi}+export interface DeleteTileRequestApi {+ /** ID of the dashboard tile to delete. Use dashboard-get to look up tile IDs. */+ tile_id: number+}+/*** * `preserve` - preserve* `two_column` - two_column@@ -7757,6 +7762,17 @@ export const DashboardsCreateTextTileCreateFormat = {Txt: 'txt',} as const+export type DashboardsDeleteTileParams = {+ format?: DashboardsDeleteTileFormat+}++export type DashboardsDeleteTileFormat = (typeof DashboardsDeleteTileFormat)[keyof typeof DashboardsDeleteTileFormat]++export const DashboardsDeleteTileFormat = {+ Json: 'json',+ Txt: 'txt',+} as const+export type DashboardsMoveTilePartialUpdateParams = {format?: DashboardsMoveTilePartialUpdateFormat}diff --git a/products/dashboards/frontend/generated/api.ts b/products/dashboards/frontend/generated/api.tsindex ed2dc764e5e0..4c3391c167b1 100644--- a/products/dashboards/frontend/generated/api.ts+++ b/products/dashboards/frontend/generated/api.ts@@ -26,6 +26,7 @@ import type {DashboardsCreateParams,DashboardsCreateTextTileCreateParams,DashboardsCreateUnlistedDashboardCreateParams,+ DashboardsDeleteTileParams,DashboardsDestroyParams,DashboardsListParams,DashboardsMoveTilePartialUpdateParams,@@ -39,6 +40,7 @@ import type {DashboardsUpdateTextTileCreateParams,DataColorThemeApi,DataColorThemesListParams,+ DeleteTileRequestApi,PaginatedDashboardBasicListApi,PaginatedDashboardTemplateListApi,PaginatedDataColorThemeListApi,@@ -561,6 +563,44 @@ export const dashboardsCreateTextTileCreate = async (})}+export const getDashboardsDeleteTileUrl = (projectId: string, id: number, params?: DashboardsDeleteTileParams) => {+ const normalizedParams = new URLSearchParams()++ Object.entries(params || {}).forEach(([key, value]) => {+ if (value !== undefined) {+ normalizedParams.append(key, value === null ? 'null' : value.toString())+ }+ })++ const stringifiedParams = normalizedParams.toString()++ return stringifiedParams.length > 0+ ? `/api/projects/${projectId}/dashboards/${id}/delete_tile/?${stringifiedParams}`+ : `/api/projects/${projectId}/dashboards/${id}/delete_tile/`+}++/**+ * Soft-delete a single tile from a dashboard.++Works for text, insight, and button tiles. The underlying Insight, Text, or ButtonTile+object is preserved — only the dashboard tile is hidden. To delete the entire dashboard,+use the dashboard delete endpoint instead.+ */+export const dashboardsDeleteTile = async (+ projectId: string,+ id: number,+ deleteTileRequestApi: DeleteTileRequestApi,+ params?: DashboardsDeleteTileParams,+ options?: RequestInit+): Promise<void> => {+ return apiMutator<void>(getDashboardsDeleteTileUrl(projectId, id, params), {+ ...options,+ method: 'POST',+ headers: { 'Content-Type': 'application/json', ...options?.headers },+ body: JSON.stringify(deleteTileRequestApi),+ })+}+export const getDashboardsMoveTilePartialUpdateUrl = (projectId: string,id: number,diff --git a/products/dashboards/frontend/generated/api.zod.ts b/products/dashboards/frontend/generated/api.zod.tsindex be22722ebe35..36c84f08f9eb 100644--- a/products/dashboards/frontend/generated/api.zod.ts+++ b/products/dashboards/frontend/generated/api.zod.ts@@ -346,6 +346,17 @@ export const DashboardsCreateTextTileCreateBody = /* @__PURE__ */ zod.object({.describe("Optional accent color name (e.g. 'blue', 'green', 'purple', 'black')."),})+/**+ * Soft-delete a single tile from a dashboard.++Works for text, insight, and button tiles. The underlying Insight, Text, or ButtonTile+object is preserved — only the dashboard tile is hidden. To delete the entire dashboard,+use the dashboard delete endpoint instead.+ */+export const DashboardsDeleteTileBody = /* @__PURE__ */ zod.object({+ tile_id: zod.number().describe('ID of the dashboard tile to delete. Use dashboard-get to look up tile IDs.'),+})+export const dashboardsMoveTilePartialUpdateBodyNameMax = 400export const dashboardsMoveTilePartialUpdateBodyDeleteInsightsDefault = falsediff --git a/products/dashboards/mcp/tools.yaml b/products/dashboards/mcp/tools.yamlindex 7d029dcdb1bf..e1480431608c 100644--- a/products/dashboards/mcp/tools.yaml+++ b/products/dashboards/mcp/tools.yaml@@ -111,6 +111,27 @@ tools:id:cast: string-intsoft_delete: true+ dashboard-delete-tile:+ operation: dashboards_delete_tile+ enabled: true+ scopes:+ - dashboard:write+ annotations:+ readOnly: false+ destructive: true+ idempotent: false+ enrich_url: '{params.id}'+ title: Delete dashboard tile+ description: >+ Soft-delete a single tile (text, insight, or button) from a dashboard. Behaves the same as the delete button+ in the UI — the underlying Insight, Text, or ButtonTile object is preserved (so an insight that lives on+ multiple dashboards stays on the others), and the remaining tiles are automatically compacted upward to fill+ the gap left by the deleted tile (matching the dashboard grid's layout). Pass the DashboardTile id as+ `tile_id` (use dashboard-get to look up tile IDs). To remove the whole dashboard instead, use+ dashboard-delete.+ param_overrides:+ id:+ cast: string-intdashboard-get:operation: dashboards_retrieveenabled: truediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex d0719ef1f0cd..43017901c9bc 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -1008,6 +1008,21 @@"readOnlyHint": false}},+ "dashboard-delete-tile": {+ "description": "Soft-delete a single tile (text, insight, or button) from a dashboard. Behaves the same as the delete button in the UI — the underlying Insight, Text, or ButtonTile object is preserved (so an insight that lives on multiple dashboards stays on the others), and the remaining tiles are automatically compacted upward to fill the gap left by the deleted tile (matching the dashboard grid's layout). Pass the DashboardTile id as `tile_id` (use dashboard-get to look up tile IDs). To remove the whole dashboard instead, use dashboard-delete.",+ "category": "Dashboards",+ "feature": "dashboards",+ "summary": "Delete dashboard tile",+ "title": "Delete dashboard tile",+ "required_scopes": ["dashboard:write"],+ "new_mcp": true,+ "annotations": {+ "destructiveHint": true,+ "idempotentHint": false,+ "openWorldHint": true,+ "readOnlyHint": false+ }+ },"dashboard-get": {"description": "Get a specific dashboard by ID. Returns the full dashboard including all tiles with their insights and layout information. Insight results, filters, and query metadata are omitted to save context — use dashboard-insights-run to fetch the actual data for every insight on the dashboard in one call, or insight-query for a single insight. Supports variables_override and filters_override query params; on this endpoint they affect only the merged `filters` and `variables` fields in the response (preview). To execute insights with the same overrides, pass the same query params to dashboard-insights-run.","category": "Dashboards",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex efc330f53d72..062ca9b82243 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -1024,6 +1024,21 @@"readOnlyHint": false}},+ "dashboard-delete-tile": {+ "description": "Soft-delete a single tile (text, insight, or button) from a dashboard. Behaves the same as the delete button in the UI — the underlying Insight, Text, or ButtonTile object is preserved (so an insight that lives on multiple dashboards stays on the others), and the remaining tiles are automatically compacted upward to fill the gap left by the deleted tile (matching the dashboard grid's layout). Pass the DashboardTile id as `tile_id` (use dashboard-get to look up tile IDs). To remove the whole dashboard instead, use dashboard-delete.",+ "category": "Dashboards",+ "feature": "dashboards",+ "summary": "Delete dashboard tile",+ "title": "Delete dashboard tile",+ "required_scopes": ["dashboard:write"],+ "new_mcp": true,+ "annotations": {+ "destructiveHint": true,+ "idempotentHint": false,+ "openWorldHint": true,+ "readOnlyHint": false+ }+ },"dashboard-get": {"description": "Get a specific dashboard by ID. Returns the full dashboard including all tiles with their insights and layout information. Insight results, filters, and query metadata are omitted to save context — use dashboard-insights-run to fetch the actual data for every insight on the dashboard in one call, or insight-query for a single insight. Supports variables_override and filters_override query params; on this endpoint they affect only the merged `filters` and `variables` fields in the response (preview). To execute insights with the same overrides, pass the same query params to dashboard-insights-run.","category": "Dashboards",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex ac7bd3b2cc3d..16832542d043 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -12966,6 +12966,11 @@ export namespace Schemas {Frequentist: 'frequentist',} as const;+ export interface DeleteTileRequest {+ /** ID of the dashboard tile to delete. Use dashboard-get to look up tile IDs. */+ tile_id: number;+ }+/*** * `pending` - Pending* `delivered` - Delivered@@ -40423,6 +40428,18 @@ export namespace Schemas {Txt: 'txt',} as const;+ export type EnvironmentsDashboardsDeleteTileParams = {+ format?: EnvironmentsDashboardsDeleteTileFormat;+ };++ export type EnvironmentsDashboardsDeleteTileFormat = typeof EnvironmentsDashboardsDeleteTileFormat[keyof typeof EnvironmentsDashboardsDeleteTileFormat];+++ export const EnvironmentsDashboardsDeleteTileFormat = {+ Json: 'json',+ Txt: 'txt',+ } as const;+export type EnvironmentsDashboardsMoveTilePartialUpdateParams = {format?: EnvironmentsDashboardsMoveTilePartialUpdateFormat;};@@ -45485,6 +45502,18 @@ export namespace Schemas {Txt: 'txt',} as const;+ export type DashboardsDeleteTileParams = {+ format?: DashboardsDeleteTileFormat;+ };++ export type DashboardsDeleteTileFormat = typeof DashboardsDeleteTileFormat[keyof typeof DashboardsDeleteTileFormat];+++ export const DashboardsDeleteTileFormat = {+ Json: 'json',+ Txt: 'txt',+ } as const;+export type DashboardsMoveTilePartialUpdateParams = {format?: DashboardsMoveTilePartialUpdateFormat;};diff --git a/services/mcp/src/generated/dashboards/api.ts b/services/mcp/src/generated/dashboards/api.tsindex b699a945e98e..3c77e0525f8f 100644--- a/services/mcp/src/generated/dashboards/api.ts+++ b/services/mcp/src/generated/dashboards/api.ts@@ -3,7 +3,7 @@* MCP service uses these Zod schemas for generated tool handlers.* To regenerate: hogli build:openapi*- * PostHog API - MCP 9 enabled ops+ * PostHog API - MCP 10 enabled ops* OpenAPI spec version: 1.0.0*/import * as zod from 'zod'@@ -223,6 +223,30 @@ export const DashboardsCreateTextTileCreateBody = /* @__PURE__ */ zod.object({.describe("Optional accent color name (e.g. 'blue', 'green', 'purple', 'black')."),})+/**+ * Soft-delete a single tile from a dashboard.++Works for text, insight, and button tiles. The underlying Insight, Text, or ButtonTile+object is preserved — only the dashboard tile is hidden. To delete the entire dashboard,+use the dashboard delete endpoint instead.+ */+export const DashboardsDeleteTileParams = /* @__PURE__ */ zod.object({+ id: zod.number().describe('A unique integer value identifying this dashboard.'),+ 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 DashboardsDeleteTileQueryParams = /* @__PURE__ */ zod.object({+ format: zod.enum(['json', 'txt']).optional(),+})++export const DashboardsDeleteTileBody = /* @__PURE__ */ zod.object({+ tile_id: zod.number().describe('ID of the dashboard tile to delete. Use dashboard-get to look up tile IDs.'),+})+export const DashboardsReorderTilesCreateParams = /* @__PURE__ */ zod.object({id: zod.number().describe('A unique integer value identifying this dashboard.'),project_id: zoddiff --git a/services/mcp/src/tools/generated/dashboards.ts b/services/mcp/src/tools/generated/dashboards.tsindex a17ff851367c..ce936668d1b8 100644--- a/services/mcp/src/tools/generated/dashboards.ts+++ b/services/mcp/src/tools/generated/dashboards.ts@@ -6,6 +6,8 @@ import {DashboardsCreateBody,DashboardsCreateTextTileCreateBody,DashboardsCreateTextTileCreateParams,+ DashboardsDeleteTileBody,+ DashboardsDeleteTileParams,DashboardsDestroyParams,DashboardsListQueryParams,DashboardsPartialUpdateBody,@@ -161,6 +163,28 @@ const dashboardDelete = (): ToolBase<typeof DashboardDeleteSchema, Schemas.Dashb},})+const DashboardDeleteTileSchema = DashboardsDeleteTileParams.omit({ project_id: true })+ .extend(DashboardsDeleteTileBody.shape)+ .extend({ id: z.preprocess(castStringToInt, DashboardsDeleteTileParams.shape['id']) })++const dashboardDeleteTile = (): ToolBase<typeof DashboardDeleteTileSchema, unknown> => ({+ name: 'dashboard-delete-tile',+ schema: DashboardDeleteTileSchema,+ handler: async (context: Context, params: z.infer<typeof DashboardDeleteTileSchema>) => {+ const projectId = await context.stateManager.getProjectId()+ const body: Record<string, unknown> = {}+ if (params.tile_id !== undefined) {+ body['tile_id'] = params.tile_id+ }+ const result = await context.api.request<unknown>({+ method: 'POST',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/dashboards/${encodeURIComponent(String(params.id))}/delete_tile/`,+ body,+ })+ return await withPostHogUrl(context, result, `/dashboard/${params.id}`)+ },+})+const DashboardGetSchema = DashboardsRetrieveParams.omit({ project_id: true }).extend(DashboardsRetrieveQueryParams.omit({ format: true }).shape).extend({ id: z.preprocess(castStringToInt, DashboardsRetrieveParams.shape['id']) })@@ -460,6 +484,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'dashboard-create': dashboardCreate,'dashboard-create-text-tile': dashboardCreateTextTile,'dashboard-delete': dashboardDelete,+ 'dashboard-delete-tile': dashboardDeleteTile,'dashboard-get': dashboardGet,'dashboard-insights-run': dashboardInsightsRun,'dashboard-reorder-tiles': dashboardReorderTiles,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/dashboard-delete-tile.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/dashboard-delete-tile.jsonnew file mode 100644index 000000000000..5214f1b5e03b--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/dashboard-delete-tile.json@@ -0,0 +1,15 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "properties": {+ "id": {+ "description": "A unique integer value identifying this dashboard.",+ "type": "number"+ },+ "tile_id": {+ "description": "ID of the dashboard tile to delete. Use dashboard-get to look up tile IDs.",+ "type": "number"+ }+ },+ "required": ["id", "tile_id"],+ "type": "object"+}