: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(customer-analytics): manage tasks through mcp (#97739)
Arthur Moreira de Deusd75d2800c07a
diff --git a/docs/internal/customer-analytics-tasks-mcp.md b/docs/internal/customer-analytics-tasks-mcp.mdnew file mode 100644index 000000000000..0eaf23b8695b--- /dev/null+++ b/docs/internal/customer-analytics-tasks-mcp.md@@ -0,0 +1,29 @@+# Manage Customer analytics tasks through MCP++Enable `customer-analytics-customer-tasks` for the caller, then reconnect the MCP client to discover the task tools.+Read operations require `customer_task:read`; writes require `customer_task:write`.+Existing project membership, task permissions, and linked-account visibility apply.++| Tool | Operation |+| -------------------------------- | -------------------------------------------------------------------------------------------- |+| `customer-tasks-create` | Create a task with a name and optional description, account, assignee, deadline, and status. |+| `customer-tasks-list` | Search and filter tasks, with limit/offset pagination. |+| `customer-tasks-retrieve` | Retrieve a task by UUID. |+| `customer-tasks-partial-update` | Change selected fields, including assignment and status. |+| `customer-tasks-archive-create` | Remove a task from active lists while preserving its history. |+| `customer-tasks-restore-create` | Restore an archived task. |+| `customer-tasks-activities-list` | Read the task's change history. |++`account_id` is a Customer analytics account UUID. `assigned_to_id` is a PostHog project member's user ID.+`due_at` accepts an ISO 8601 timestamp. Pass null when updating to clear an account, assignee, description, or deadline.+Omitted update fields remain unchanged. Restore an archived task before editing it.+Completed and canceled tasks must return to `open` before moving to another status.++For SQL reads, query `system.customer_tasks`. It includes archived tasks; add `archived_at IS NULL` for active tasks.+Direct SQL reads enforce task permissions and linked-account visibility, but do not require the task feature flag.+Users with task-only grants can query granted tasks without account links.+Tasks linked to accounts remain hidden until the caller can read those accounts.+Data Modeling can materialize this table through its system-table allowlist.+Refreshes include the project's tasks without per-user task or account restrictions. Warehouse-view permissions protect the materialized result.+The task API and MCP tools still require the feature flag.+Task activity history remains available through the API so historical account details can be redacted.diff --git a/frontend/src/lib/agentScopes.generated.ts b/frontend/src/lib/agentScopes.generated.tsindex 5b9d0e2a69eb..df4e44d15270 100644--- a/frontend/src/lib/agentScopes.generated.ts+++ b/frontend/src/lib/agentScopes.generated.ts@@ -33,6 +33,8 @@ export const AGENT_USE_CASE_SCOPES = ['conversation:read','customer_analytics:read','customer_analytics:write',+ 'customer_task:read',+ 'customer_task:write','data_catalog:read','data_catalog:write','data_catalog_approval:write',diff --git a/posthog/hogql/ACCESS_CONTROL.md b/posthog/hogql/ACCESS_CONTROL.mdindex 9b63e1a31822..7b92b0d484e8 100644--- a/posthog/hogql/ACCESS_CONTROL.md+++ b/posthog/hogql/ACCESS_CONTROL.md@@ -231,7 +231,7 @@ The cache key is derived from `get_cache_payload()`:Two things keep cache hit rates high:1. **Feature gate:** if the organization doesn't have `AvailableFeature.ACCESS_CONTROL`, no resource/object restrictions exist, so nothing is added and the cache isn't partitioned by user at all.-2. **Scoped to queried tables:** `queried_access_controlled_resources()` (`posthog/hogql_queries/access_controlled_resources.py`) parses the query and returns only the access-controlled scopes it actually reads, so warehouse scopes are added to the payload only when the query references warehouse tables or views — a plain **events or persons query shares one cache entry across all users**+2. **Scoped to queried tables:** `queried_access_controlled_resources()` (`posthog/hogql_queries/access_controlled_resources.py`) parses the query and returns only the access-controlled scopes it actually reads. Tables whose visibility depends on another scoped table add that dependency too. For example, `system.customer_tasks` adds `account` because its row predicate reads `system.accounts`. A plain **events or persons query shares one cache entry across all users**.When a run has no user but does read access-controlled resources, the fingerprint uses `restricted_resources: ["*"]` so it can never collide with a real user's cache, and synthetic principals partition on their readable scopes so a narrow token can't reuse a broader token's cached rows.diff --git a/posthog/hogql/database/database.py b/posthog/hogql/database/database.pyindex a9cb0825c5aa..8cc0268b4b04 100644--- a/posthog/hogql/database/database.py+++ b/posthog/hogql/database/database.py@@ -404,6 +404,7 @@ _CATALOG_PICKLE_MODULE_PREFIXES = ("posthog.hogql.",)_CATALOG_PICKLE_MODULES = frozenset({"posthog.clickhouse.workload",+ "products.customer_analytics.backend.facade.customer_tasks_hogql","products.customer_analytics.backend.facade.hogql",})diff --git a/posthog/hogql/database/schema/system.py b/posthog/hogql/database/schema/system.pyindex 3e8fc0db48e4..2355cac89ea6 100644--- a/posthog/hogql/database/schema/system.py+++ b/posthog/hogql/database/schema/system.py@@ -38,6 +38,7 @@ from posthog.scopes import APIScopeObjectif TYPE_CHECKING:from posthog.models.team.team import Team+from products.customer_analytics.backend.facade.customer_tasks_hogql import customer_tasksfrom products.customer_analytics.backend.facade.hogql import (account_channel_summaries,account_custom_property_values,@@ -2997,6 +2998,7 @@ class SystemTables(TableNode):name="feature_request_product_areas", table=feature_request_product_areas),"feature_requests": TableNode(name="feature_requests", table=feature_requests),+ "customer_tasks": TableNode(name="customer_tasks", table=customer_tasks),"file_system": TableNode(name="file_system", table=file_system),"groups": TableNode(name="groups", table=groups),"group_type_mappings": TableNode(name="group_type_mappings", table=group_type_mappings),diff --git a/posthog/hogql/database/schema/test/test_system_tables.py b/posthog/hogql/database/schema/test/test_system_tables.pyindex 61491c444dfb..b899b17d4845 100644--- a/posthog/hogql/database/schema/test/test_system_tables.py+++ b/posthog/hogql/database/schema/test/test_system_tables.py@@ -48,6 +48,7 @@ from products.customer_analytics.backend.facade.testing import (create_account_relationship_definition,create_custom_property_definition,create_custom_property_value,+ create_customer_task,create_feature_request,create_feature_request_account_link,create_feature_request_evidence,@@ -237,6 +238,10 @@ def _create_custom_property_definition(team: Team, label: str):return create_custom_property_definition(team_id=team.pk, name=f"def_{label}")+def _create_customer_task(team: Team, label: str):+ return create_customer_task(team_id=team.pk, name=f"customer_task_{label}")++def _create_account_relationship(team: Team, label: str):account = create_account(team_id=team.pk, name=f"account_{label}")definition = create_account_relationship_definition(team_id=team.pk, name=f"rel_{label}")@@ -887,6 +892,7 @@ SYSTEM_TABLE_FACTORIES = [("cohorts", _create_cohort),("cohort_calculation_history", _create_cohort_calculation_history),("custom_property_definitions", _create_custom_property_definition),+ ("customer_tasks", _create_customer_task),("_account_meetings", _create_account_meeting),("_account_channel_summaries", _create_account_channel_summary),("_account_email_threads", _create_account_email_thread),diff --git a/posthog/hogql/database/test/__snapshots__/test_database.ambr b/posthog/hogql/database/test/__snapshots__/test_database.ambrindex 516f0267b1a1..d16a3e8980c0 100644--- a/posthog/hogql/database/test/__snapshots__/test_database.ambr+++ b/posthog/hogql/database/test/__snapshots__/test_database.ambr@@ -7471,6 +7471,145 @@"row_count": null,"type": "system"},+ "system.customer_tasks": {+ "certification": null,+ "fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "account_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "account_id",+ "id": null,+ "name": "account_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "name": {+ "chain": null,+ "fields": null,+ "hogql_value": "name",+ "id": null,+ "name": "name",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "description": {+ "chain": null,+ "fields": null,+ "hogql_value": "description",+ "id": null,+ "name": "description",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "status": {+ "chain": null,+ "fields": null,+ "hogql_value": "status",+ "id": null,+ "name": "status",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "assigned_to_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "assigned_to_id",+ "id": null,+ "name": "assigned_to_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "due_at": {+ "chain": null,+ "fields": null,+ "hogql_value": "due_at",+ "id": null,+ "name": "due_at",+ "schema_valid": true,+ "table": null,+ "type": "datetime"+ },+ "completed_at": {+ "chain": null,+ "fields": null,+ "hogql_value": "completed_at",+ "id": null,+ "name": "completed_at",+ "schema_valid": true,+ "table": null,+ "type": "datetime"+ },+ "completed_by_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "completed_by_id",+ "id": null,+ "name": "completed_by_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "created_by_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "created_by_id",+ "id": null,+ "name": "created_by_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "archived_at": {+ "chain": null,+ "fields": null,+ "hogql_value": "archived_at",+ "id": null,+ "name": "archived_at",+ "schema_valid": true,+ "table": null,+ "type": "datetime"+ },+ "created_at": {+ "chain": null,+ "fields": null,+ "hogql_value": "created_at",+ "id": null,+ "name": "created_at",+ "schema_valid": true,+ "table": null,+ "type": "datetime"+ },+ "updated_at": {+ "chain": null,+ "fields": null,+ "hogql_value": "updated_at",+ "id": null,+ "name": "updated_at",+ "schema_valid": true,+ "table": null,+ "type": "datetime"+ }+ },+ "id": "system.customer_tasks",+ "name": "system.customer_tasks",+ "row_count": null,+ "type": "system"+ },"system.file_system": {"certification": null,"fields": {@@ -19050,6 +19189,145 @@"row_count": null,"type": "system"},+ "system.customer_tasks": {+ "certification": null,+ "fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "account_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "account_id",+ "id": null,+ "name": "account_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "name": {+ "chain": null,+ "fields": null,+ "hogql_value": "name",+ "id": null,+ "name": "name",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "description": {+ "chain": null,+ "fields": null,+ "hogql_value": "description",+ "id": null,+ "name": "description",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "status": {+ "chain": null,+ "fields": null,+ "hogql_value": "status",+ "id": null,+ "name": "status",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "assigned_to_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "assigned_to_id",+ "id": null,+ "name": "assigned_to_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "due_at": {+ "chain": null,+ "fields": null,+ "hogql_value": "due_at",+ "id": null,+ "name": "due_at",+ "schema_valid": true,+ "table": null,+ "type": "datetime"+ },+ "completed_at": {+ "chain": null,+ "fields": null,+ "hogql_value": "completed_at",+ "id": null,+ "name": "completed_at",+ "schema_valid": true,+ "table": null,+ "type": "datetime"+ },+ "completed_by_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "completed_by_id",+ "id": null,+ "name": "completed_by_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "created_by_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "created_by_id",+ "id": null,+ "name": "created_by_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "archived_at": {+ "chain": null,+ "fields": null,+ "hogql_value": "archived_at",+ "id": null,+ "name": "archived_at",+ "schema_valid": true,+ "table": null,+ "type": "datetime"+ },+ "created_at": {+ "chain": null,+ "fields": null,+ "hogql_value": "created_at",+ "id": null,+ "name": "created_at",+ "schema_valid": true,+ "table": null,+ "type": "datetime"+ },+ "updated_at": {+ "chain": null,+ "fields": null,+ "hogql_value": "updated_at",+ "id": null,+ "name": "updated_at",+ "schema_valid": true,+ "table": null,+ "type": "datetime"+ }+ },+ "id": "system.customer_tasks",+ "name": "system.customer_tasks",+ "row_count": null,+ "type": "system"+ },"system.file_system": {"certification": null,"fields": {diff --git a/posthog/hogql/database/test/test_database.py b/posthog/hogql/database/test/test_database.pyindex 74aa3e10f63c..f7776dc9fac2 100644--- a/posthog/hogql/database/test/test_database.py+++ b/posthog/hogql/database/test/test_database.py@@ -4522,5 +4522,6 @@ class TestCreateForPosthogTables(BaseTest):system_table_names = database.get_system_table_names()assert "system.feature_flags" not in system_table_namesassert "system.activity_logs" not in system_table_names+ assert "system.customer_tasks" not in system_table_nameswith pytest.raises(TableAccessDeniedError):database.get_table("system.activity_logs")diff --git a/posthog/hogql/database/test/test_postgres_table.py b/posthog/hogql/database/test/test_postgres_table.pyindex 0669949d9eda..c6b335772e6d 100644--- a/posthog/hogql/database/test/test_postgres_table.py+++ b/posthog/hogql/database/test/test_postgres_table.py@@ -42,6 +42,7 @@ _SCOPED_SYSTEM_TABLES: dict[str, PostgresTable] = {# from the viewset. Declared by db_table so product internals stay unimported here._FACADE_OBJECT_GRANT_TABLES: dict[str, str] = {"customer_analytics_account": "account",+ "customer_analytics_customertask": "customer_task",}# Team-level definition tables gated under an object-restrictable scope for resource-level accessdiff --git a/posthog/hogql_queries/access_controlled_resources.py b/posthog/hogql_queries/access_controlled_resources.pyindex c7386faf92d0..318f2d643a70 100644--- a/posthog/hogql_queries/access_controlled_resources.py+++ b/posthog/hogql_queries/access_controlled_resources.py@@ -53,6 +53,7 @@ _ACCOUNT_COMMUNICATION_LAZY_FIELDS = frozenset({"email_threads", "support_ticket# Canvas grants share one cache key, and the narrower one is served the wider one's Canvas rows._TRANSITIVE_SYSTEM_TABLE_SCOPES: dict[str, frozenset[str]] = {"system.activity_logs": frozenset({"canvas"}),+ "system.customer_tasks": frozenset({"account"}),}diff --git a/posthog/hogql_queries/test/test_access_controlled_resources.py b/posthog/hogql_queries/test/test_access_controlled_resources.pyindex f5932cfd8eea..076df7d89932 100644--- a/posthog/hogql_queries/test/test_access_controlled_resources.py+++ b/posthog/hogql_queries/test/test_access_controlled_resources.py@@ -80,6 +80,7 @@ class TestQueriedAccessControlledResources(BaseTest):# Activity-log rows for canvases are limited to the canvases in `system.canvases`, so the# rows follow the caller's canvas grants as well as their activity-log access.("activity_logs", "select * from system.activity_logs", {"activity_log", "canvas"}),+ ("customer_tasks", "select * from system.customer_tasks", {"customer_task", "account"}),("no_access_controlled_table", "select 1", set()),("events_table", "select * from events", set()),# Catalog-enriched information_schema tables partition the cache by data_catalog access ANDdiff --git a/products/customer_analytics/backend/facade/customer_tasks_hogql.py b/products/customer_analytics/backend/facade/customer_tasks_hogql.pynew file mode 100644index 000000000000..c2fdd17c1a62--- /dev/null+++ b/products/customer_analytics/backend/facade/customer_tasks_hogql.py@@ -0,0 +1,51 @@+from posthog.hogql.base import Expr+from posthog.hogql.context import HogQLContext+from posthog.hogql.database.models import (+ DateTimeDatabaseField,+ IntegerDatabaseField,+ StringDatabaseField,+ UUIDDatabaseField,+)+from posthog.hogql.database.postgres_table import PostgresTable+from posthog.hogql.parser import parse_expr+++class _CustomerTasksTable(PostgresTable):+ def get_predicates(self, context: HogQLContext | None = None) -> list[Expr]:+ if context is None or context.database is None or not context.database.has_table("system.accounts"):+ return [parse_expr("account_id IS NULL")]+ return super().get_predicates(context)+++customer_tasks = _CustomerTasksTable(+ name="customer_tasks",+ postgres_table_name="customer_analytics_customertask",+ access_scope="customer_task",+ access_control_creator_id_field="created_by_id",+ predicates=[parse_expr("account_id IS NULL OR account_id IN (SELECT id FROM system.accounts)")],+ description="Customer analytics tasks visible to the caller. Includes archived tasks; filter archived_at IS NULL for active tasks.",+ fields={+ "id": UUIDDatabaseField(name="id", description="Task UUID."),+ "team_id": IntegerDatabaseField(name="team_id"),+ "account_id": UUIDDatabaseField(name="account_id", nullable=True, description="Linked account UUID, if any."),+ "name": StringDatabaseField(name="name", description="Task name."),+ "description": StringDatabaseField(name="description", nullable=True, description="Task description."),+ "status": StringDatabaseField(name="status", description="open, in_progress, completed, or canceled."),+ "assigned_to_id": IntegerDatabaseField(+ name="assigned_to_id", nullable=True, description="Assigned PostHog user ID."+ ),+ "due_at": DateTimeDatabaseField(name="due_at", nullable=True, description="Task deadline."),+ "completed_at": DateTimeDatabaseField(name="completed_at", nullable=True, description="Completion time."),+ "completed_by_id": IntegerDatabaseField(+ name="completed_by_id", nullable=True, description="User credited with completion."+ ),+ "created_by_id": IntegerDatabaseField(+ name="created_by_id", nullable=True, description="User who created the task."+ ),+ "archived_at": DateTimeDatabaseField(+ name="archived_at", nullable=True, description="Archive time, or NULL while active."+ ),+ "created_at": DateTimeDatabaseField(name="created_at"),+ "updated_at": DateTimeDatabaseField(name="updated_at"),+ },+)diff --git a/products/customer_analytics/backend/facade/testing.py b/products/customer_analytics/backend/facade/testing.pyindex 899bc7e2b74c..5b8566e40865 100644--- a/products/customer_analytics/backend/facade/testing.py+++ b/products/customer_analytics/backend/facade/testing.py@@ -12,6 +12,7 @@ from products.customer_analytics.backend.test.factories import (create_account_relationship_definition,create_custom_property_definition,create_custom_property_value,+ create_customer_task,create_feature_request,create_feature_request_account_link,create_feature_request_evidence,@@ -28,6 +29,7 @@ __all__ = ["create_account_relationship_definition","create_custom_property_definition","create_custom_property_value",+ "create_customer_task","create_feature_request","create_feature_request_account_link","create_feature_request_evidence",diff --git a/products/customer_analytics/backend/test/factories.py b/products/customer_analytics/backend/test/factories.pyindex 687674cf9357..e8b701afe19d 100644--- a/products/customer_analytics/backend/test/factories.py+++ b/products/customer_analytics/backend/test/factories.py@@ -10,6 +10,7 @@ from products.customer_analytics.backend.models import (AccountChannelSummary,AccountRelationship,AccountRelationshipDefinition,+ CustomerTask,CustomPropertyDefinition,CustomPropertyValue,DisplayType,@@ -55,6 +56,10 @@ def create_account_relationship()+def create_customer_task(*, team_id: int, name: str = "Review account", **kwargs: Any) -> CustomerTask:+ return CustomerTask.objects.for_team(team_id).create(team_id=team_id, name=name, **kwargs)++def create_feature_request(*, team_id: int, title: str = "Export reports", **kwargs: Any) -> FeatureRequest:return FeatureRequest.objects.for_team(team_id).create(team_id=team_id, title=title, **kwargs)diff --git a/products/customer_analytics/backend/test/test_customer_tasks_hogql.py b/products/customer_analytics/backend/test/test_customer_tasks_hogql.pynew file mode 100644index 000000000000..7cd231fb9440--- /dev/null+++ b/products/customer_analytics/backend/test/test_customer_tasks_hogql.py@@ -0,0 +1,131 @@+from posthog.test.base import NonAtomicBaseTest+from unittest.mock import patch++from django.utils import timezone++from parameterized import parameterized++from posthog.hogql.context import HogQLContext+from posthog.hogql.database.database import Database+from posthog.hogql.query import execute_hogql_query++from posthog.models import OrganizationMembership, Team, User+from posthog.models.organization import AvailableFeature++from products.access_control.backend.facade.user_access_control import UserAccessControl+from products.access_control.backend.models.access_control import AccessControl+from products.customer_analytics.backend.facade import api, contracts+from products.customer_analytics.backend.models import Account+from products.customer_analytics.backend.models.customer_task import CustomerTask+from products.data_modeling.backend.facade.system_tables import DATA_MODELING_ALLOWED_SYSTEM_TABLES+++class TestCustomerTasksHogqlAccess(NonAtomicBaseTest):+ CLASS_DATA_LEVEL_SETUP = False++ @parameterized.expand(+ [+ ("resource_access", True, {"Visible task", "Accountless task", "Creator task"}),+ ("task_grants_without_account_access", False, {"Accountless task", "Creator task"}),+ ]+ )+ @patch("posthog.permissions.posthog_feature_flag_enabled", return_value=False)+ def test_task_visibility_matches_rest_listing(+ self,+ _name: str,+ has_customer_analytics_access: bool,+ expected_active_task_names: set[str],+ _feature_flag_enabled: object,+ ) -> None:+ self.organization.available_product_features = [+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},+ {"key": AvailableFeature.ROLE_BASED_ACCESS, "name": AvailableFeature.ROLE_BASED_ACCESS},+ ]+ self.organization.save()+ viewer = User.objects.create_and_join(self.organization, "[email protected]", "testtest")+ membership = OrganizationMembership.objects.get(user=viewer, organization=self.organization)+ visible_account = Account.objects.for_team(self.team.id).create(team=self.team, name="Visible account")+ hidden_account = Account.objects.for_team(self.team.id).create(team=self.team, name="Hidden account")+ other_team = Team.objects.create(organization=self.organization)+ task_access_levels = {"Denied task": "none", "Creator task": "none"}+ if not has_customer_analytics_access:+ AccessControl.objects.create(+ team=self.team,+ resource="customer_analytics",+ resource_id=None,+ access_level="none",+ organization_member=membership,+ )+ task_access_levels.update({"Accountless task": "editor", "Hidden account task": "editor"})++ for name, account, creator, team, archived_at in [+ (+ "Visible task",+ visible_account if has_customer_analytics_access else None,+ self.user,+ self.team,+ None,+ ),+ ("Accountless task", None, self.user, self.team, None),+ ("Denied task", visible_account, self.user, self.team, None),+ ("Creator task", None, viewer, self.team, None),+ ("Hidden account task", hidden_account, self.user, self.team, None),+ ("Creator hidden account task", hidden_account, viewer, self.team, None),+ ("Other team task", None, viewer, other_team, None),+ ("Archived task", None, viewer, self.team, timezone.now()),+ ]:+ task = CustomerTask.objects.for_team(team.id).create(+ team=team, name=name, account=account, created_by=creator, archived_at=archived_at+ )+ if name in task_access_levels:+ AccessControl.objects.create(+ team=self.team,+ resource="customer_task",+ resource_id=str(task.id),+ access_level=task_access_levels[name],+ organization_member=membership,+ )++ AccessControl.objects.create(+ team=self.team,+ resource="account",+ resource_id=str(hidden_account.id),+ access_level="none",+ organization_member=membership,+ )++ rows = execute_hogql_query("SELECT name FROM system.customer_tasks", team=self.team, user=viewer).results+ assert {row[0] for row in rows} == expected_active_task_names | {"Archived task"}++ active_rows = execute_hogql_query(+ "SELECT name FROM system.customer_tasks WHERE archived_at IS NULL", team=self.team, user=viewer+ ).results+ tasks, count = api.list_customer_tasks(+ team_id=self.team.id,+ user_access_control=UserAccessControl(user=viewer, team=self.team),+ filters=contracts.CustomerTaskListFilters(),+ offset=0,+ limit=100,+ )+ assert {row[0] for row in active_rows} == {task.name for task in tasks} == expected_active_task_names+ assert count == len(expected_active_task_names)++ materialization_database = Database.create_for(+ team=self.team,+ bypass_warehouse_access_control=True,+ allowed_system_tables=DATA_MODELING_ALLOWED_SYSTEM_TABLES,+ )+ materialization_rows = execute_hogql_query(+ "SELECT name FROM system.customer_tasks",+ team=self.team,+ context=HogQLContext(team_id=self.team.id, database=materialization_database),+ ).results+ assert {row[0] for row in materialization_rows} == {+ "Visible task",+ "Accountless task",+ "Denied task",+ "Creator task",+ "Hidden account task",+ "Creator hidden account task",+ "Archived task",+ }diff --git a/products/customer_analytics/mcp/tools.yaml b/products/customer_analytics/mcp/tools.yamlindex 8e942c1e186e..0664117deffa 100644--- a/products/customer_analytics/mcp/tools.yaml+++ b/products/customer_analytics/mcp/tools.yaml@@ -837,25 +837,104 @@ tools:enabled: falsecustomer-tasks-activities-list:operation: customerTasksActivitiesList- enabled: false+ enabled: true+ scopes:+ - customer_task:read+ annotations:+ readOnly: true+ destructive: false+ idempotent: true+ list: true+ title: List customer task history+ description: >+ Read the change history of a Customer analytics task by ID. Account details the caller cannot access are+ redacted.+ feature_flag: customer-analytics-customer-taskscustomer-tasks-archive-create:operation: customer_tasks_archive_create- enabled: false+ enabled: true+ scopes:+ - customer_task:write+ annotations:+ readOnly: false+ destructive: false+ idempotent: true+ title: Archive customer task+ description: >+ Archive a Customer analytics task by ID. This removes it from active lists while preserving its history. Use+ customer-tasks-restore-create to restore it.+ feature_flag: customer-analytics-customer-taskscustomer-tasks-create:operation: customer_tasks_create- enabled: false+ enabled: true+ scopes:+ - customer_task:write+ annotations:+ readOnly: false+ destructive: false+ idempotent: false+ title: Create customer task+ description: >+ Create a Customer analytics task with a name and optional description, account UUID, project member assignee+ ID, ISO 8601 deadline, and initial status. This is a customer follow-up task, not an AI coding task.+ feature_flag: customer-analytics-customer-taskscustomer-tasks-list:operation: customer_tasks_list- enabled: false+ enabled: true+ scopes:+ - customer_task:read+ annotations:+ readOnly: true+ destructive: false+ idempotent: true+ list: true+ title: List customer tasks+ description: >+ List accessible Customer analytics tasks. Filter by search, account UUID, assignee (me, unassigned, or user+ ID), comma-separated statuses, deadline, or archive state. Active tasks are returned by default.+ feature_flag: customer-analytics-customer-taskscustomer-tasks-partial-update:operation: customer_tasks_partial_update- enabled: false+ enabled: true+ scopes:+ - customer_task:write+ annotations:+ readOnly: false+ destructive: false+ idempotent: true+ title: Update customer task+ description: >+ Update a Customer analytics task by ID. Supply only fields to change. Use null to clear the account,+ assignee, description, or deadline. Statuses are open, in_progress, completed, and canceled. Reopen a+ completed or canceled task before moving it to another status. Restore archived tasks before editing.+ feature_flag: customer-analytics-customer-taskscustomer-tasks-restore-create:operation: customer_tasks_restore_create- enabled: false+ enabled: true+ scopes:+ - customer_task:write+ annotations:+ readOnly: false+ destructive: false+ idempotent: true+ title: Restore customer task+ description: |+ Restore an archived Customer analytics task by ID so it appears in active lists and can be edited again.+ feature_flag: customer-analytics-customer-taskscustomer-tasks-retrieve:operation: customer_tasks_retrieve- enabled: false+ enabled: true+ scopes:+ - customer_task:read+ annotations:+ readOnly: true+ destructive: false+ idempotent: true+ title: Get customer task+ description: >+ Retrieve one accessible Customer analytics task by ID, including its linked account, assignee, deadline,+ status, and archive state.+ feature_flag: customer-analytics-customer-taskscustomer-tasks-update:operation: customer_tasks_updateenabled: falsediff --git a/products/data_modeling/backend/facade/system_tables.py b/products/data_modeling/backend/facade/system_tables.pyindex 222b228b6344..f8084b13afe1 100644--- a/products/data_modeling/backend/facade/system_tables.py+++ b/products/data_modeling/backend/facade/system_tables.py@@ -10,6 +10,7 @@ DATA_MODELING_ALLOWED_SYSTEM_TABLES: frozenset[str] = frozenset("account_relationships","accounts","custom_property_definitions",+ "customer_tasks","feature_request_account_links","feature_requests","support_tickets",diff --git a/products/data_modeling/backend/test/test_saved_query_dag_sync.py b/products/data_modeling/backend/test/test_saved_query_dag_sync.pyindex 0c64e1dc70d7..a0e94c897d89 100644--- a/products/data_modeling/backend/test/test_saved_query_dag_sync.py+++ b/products/data_modeling/backend/test/test_saved_query_dag_sync.py@@ -33,20 +33,22 @@ class TestGetDagId(BaseTest):@pytest.mark.django_dbclass TestSyncSavedQueryToDag(BaseTest):- def test_saved_query_resolution_requires_explicit_data_modeling_system_allowlist(self) -> None:+ @parameterized.expand(+ [+ (+ "account_summary",+ "SELECT id, feature_requests.count, email_threads.count FROM system.accounts",+ ),+ ("customer_tasks", "SELECT id, name, account_id FROM system.customer_tasks"),+ ]+ )+ def test_saved_query_resolution_requires_explicit_data_modeling_system_allowlist(+ self, name: str, query: str+ ) -> None:saved_query = DataWarehouseSavedQuery(- name="account_summary",+ name=name,team=self.team,- query={- "kind": "HogQLQuery",- "query": """- SELECT- id,- feature_requests.count,- email_threads.count- FROM system.accounts- """,- },+ query={"kind": "HogQLQuery", "query": query},)with self.assertRaises(TableAccessDeniedError):diff --git a/products/posthog_ai/skills/querying-posthog-data/SKILL.md b/products/posthog_ai/skills/querying-posthog-data/SKILL.mdindex 6a9b9d2eab0b..64390e37f3c2 100644--- a/products/posthog_ai/skills/querying-posthog-data/SKILL.md+++ b/products/posthog_ai/skills/querying-posthog-data/SKILL.md@@ -47,6 +47,8 @@ Curating the catalog — creating, approving, or retiring metrics, certifying so## Data Schema+- [Customer analytics tasks (`system.customer_tasks`)](./references/models-customer-tasks.md)+Schema reference for PostHog's core system models, organized by domain.Every column table below is generated from the live HogQL catalog, so it lists exactly what `execute-sql` resolves. `system.*` tables expose a curated subset of each Django model, so a field returned by a REST tool such as `insight-get` is not necessarily queryable — trust these tables over the REST response shape.diff --git a/products/posthog_ai/skills/querying-posthog-data/references/models-customer-tasks.md b/products/posthog_ai/skills/querying-posthog-data/references/models-customer-tasks.mdnew file mode 100644index 000000000000..67876d2d294e--- /dev/null+++ b/products/posthog_ai/skills/querying-posthog-data/references/models-customer-tasks.md@@ -0,0 +1,21 @@+# Customer analytics tasks++`system.customer_tasks` contains customer follow-up tasks, with task and linked-account access controls applied.+These are separate from AI coding tasks.++Columns: `id` (UUID), `team_id`, `account_id` (nullable UUID), `name`, `description`, `status`,+`assigned_to_id`, `due_at`, `completed_at`, `completed_by_id`, `created_by_id`, `archived_at`, `created_at`, `updated_at`.+User IDs are PostHog project members. Status is `open`, `in_progress`, `completed`, or `canceled`.++```sql+SELECT id, name, assigned_to_id, due_at+FROM system.customer_tasks+WHERE archived_at IS NULL AND status IN ('open', 'in_progress')+ORDER BY due_at ASC+LIMIT 100+```++Use `posthog:customer-tasks-create` to create a task, `posthog:customer-tasks-partial-update` to edit it,+and `posthog:customer-tasks-archive-create` or `posthog:customer-tasks-restore-create` to archive or restore it.+Use `posthog:customer-tasks-list` and `posthog:customer-tasks-retrieve` for API reads with nested account and user details.+Use `posthog:customer-tasks-activities-list` for the change history, including redacted historical account details.diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 10556e54759c..15fbcff68268 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -2497,6 +2497,111 @@},"feature_flag": "warehouse-person-properties"},+ "customer-tasks-activities-list": {+ "description": "Read the change history of a Customer analytics task by ID. Account details the caller cannot access are redacted.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "List customer task history",+ "title": "List customer task history",+ "required_scopes": ["customer_task:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-archive-create": {+ "description": "Archive a Customer analytics task by ID. This removes it from active lists while preserving its history. Use customer-tasks-restore-create to restore it.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "Archive customer task",+ "title": "Archive customer task",+ "required_scopes": ["customer_task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-create": {+ "description": "Create a Customer analytics task with a name and optional description, account UUID, project member assignee ID, ISO 8601 deadline, and initial status. This is a customer follow-up task, not an AI coding task.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "Create customer task",+ "title": "Create customer task",+ "required_scopes": ["customer_task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": false,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-list": {+ "description": "List accessible Customer analytics tasks. Filter by search, account UUID, assignee (me, unassigned, or user ID), comma-separated statuses, deadline, or archive state. Active tasks are returned by default.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "List customer tasks",+ "title": "List customer tasks",+ "required_scopes": ["customer_task:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-partial-update": {+ "description": "Update a Customer analytics task by ID. Supply only fields to change. Use null to clear the account, assignee, description, or deadline. Statuses are open, in_progress, completed, and canceled. Reopen a completed or canceled task before moving it to another status. Restore archived tasks before editing.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "Update customer task",+ "title": "Update customer task",+ "required_scopes": ["customer_task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-restore-create": {+ "description": "Restore an archived Customer analytics task by ID so it appears in active lists and can be edited again.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "Restore customer task",+ "title": "Restore customer task",+ "required_scopes": ["customer_task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-retrieve": {+ "description": "Retrieve one accessible Customer analytics task by ID, including its linked account, assignee, deadline, status, and archive state.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "Get customer task",+ "title": "Get customer task",+ "required_scopes": ["customer_task:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },"dashboard-create": {"description": "Create a new dashboard. Provide a name and optional description, tags, and pinned status. Can also create from a template or duplicate an existing dashboard. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight. To add widget tiles after creation, see dashboard-widget-catalog-list for available widget types and dashboard-widgets-batch-add to add them.\nA dashboard is the right artifact for a set of metrics someone will check repeatedly over time — monitoring, weekly or monthly tracking, team overviews, launch and health boards. It is the wrong one for a deep dive: an investigation with a narrative, intermediate steps, and a conclusion belongs in a notebook (`search notebooks-`), which interleaves prose with executable SQL and Python cells. When a deep dive turns up a few metrics worth tracking, save those as insights rather than reshaping the analysis into a dashboard.","category": "Dashboards",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 08d8d7637787..b04653279994 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -2512,6 +2512,111 @@},"feature_flag": "warehouse-person-properties"},+ "customer-tasks-activities-list": {+ "description": "Read the change history of a Customer analytics task by ID. Account details the caller cannot access are redacted.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "List customer task history",+ "title": "List customer task history",+ "required_scopes": ["customer_task:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-archive-create": {+ "description": "Archive a Customer analytics task by ID. This removes it from active lists while preserving its history. Use customer-tasks-restore-create to restore it.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "Archive customer task",+ "title": "Archive customer task",+ "required_scopes": ["customer_task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-create": {+ "description": "Create a Customer analytics task with a name and optional description, account UUID, project member assignee ID, ISO 8601 deadline, and initial status. This is a customer follow-up task, not an AI coding task.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "Create customer task",+ "title": "Create customer task",+ "required_scopes": ["customer_task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": false,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-list": {+ "description": "List accessible Customer analytics tasks. Filter by search, account UUID, assignee (me, unassigned, or user ID), comma-separated statuses, deadline, or archive state. Active tasks are returned by default.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "List customer tasks",+ "title": "List customer tasks",+ "required_scopes": ["customer_task:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-partial-update": {+ "description": "Update a Customer analytics task by ID. Supply only fields to change. Use null to clear the account, assignee, description, or deadline. Statuses are open, in_progress, completed, and canceled. Reopen a completed or canceled task before moving it to another status. Restore archived tasks before editing.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "Update customer task",+ "title": "Update customer task",+ "required_scopes": ["customer_task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-restore-create": {+ "description": "Restore an archived Customer analytics task by ID so it appears in active lists and can be edited again.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "Restore customer task",+ "title": "Restore customer task",+ "required_scopes": ["customer_task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },+ "customer-tasks-retrieve": {+ "description": "Retrieve one accessible Customer analytics task by ID, including its linked account, assignee, deadline, status, and archive state.",+ "category": "Customer analytics",+ "feature": "customer_analytics",+ "summary": "Get customer task",+ "title": "Get customer task",+ "required_scopes": ["customer_task:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ },+ "feature_flag": "customer-analytics-customer-tasks"+ },"dashboard-create": {"description": "Create a new dashboard. Provide a name and optional description, tags, and pinned status. Can also create from a template or duplicate an existing dashboard. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight. To add widget tiles after creation, see dashboard-widget-catalog-list for available widget types and dashboard-widgets-batch-add to add them.\nA dashboard is the right artifact for a set of metrics someone will check repeatedly over time — monitoring, weekly or monthly tracking, team overviews, launch and health boards. It is the wrong one for a deep dive: an investigation with a narrative, intermediate steps, and a conclusion belongs in a notebook (`search notebooks-`), which interleaves prose with executable SQL and Python cells. When a deep dive turns up a few metrics worth tracking, save those as insights rather than reshaping the analysis into a dashboard.","category": "Dashboards",diff --git a/services/mcp/src/generated/customer_analytics/api.ts b/services/mcp/src/generated/customer_analytics/api.tsindex 94fab7b89874..97f2711b3d82 100644--- a/services/mcp/src/generated/customer_analytics/api.ts+++ b/services/mcp/src/generated/customer_analytics/api.ts@@ -3,7 +3,7 @@* MCP service uses these Zod schemas for generated tool handlers.* To regenerate: hogli build:openapi*- * PostHog API - MCP 65 enabled ops+ * PostHog API - MCP 72 enabled ops* OpenAPI spec version: 1.0.0*/import * as zod from 'zod'@@ -924,6 +924,169 @@ export const CustomPropertySourcesSyncParams = () => zod.object({),})+export const CustomerTasksListParams = () => 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 customerTasksListQueryArchiveStateDefault = `active`+export const customerTasksListQueryLimitDefault = 50+export const customerTasksListQueryLimitMax = 100++export const customerTasksListQueryOffsetDefault = 0+export const customerTasksListQueryOffsetMin = 0++export const CustomerTasksListQueryParams = () => zod.object({+ account_id: zod.string().optional().describe('Filter by account UUID.'),+ archive_state: zod+ .enum(['active', 'archived', 'all'])+ .default(customerTasksListQueryArchiveStateDefault)+ .describe('Which archive state to include.\n\n\* `active` - active\n\* `archived` - archived\n\* `all` - all'),+ assigned_to: zod.string().min(1).optional().describe('Filter by me, unassigned, or one user ID.'),+ due_after: zod.iso.datetime({ offset: true }).optional().describe('Inclusive lower deadline bound.'),+ due_before: zod.iso.datetime({ offset: true }).optional().describe('Exclusive upper deadline bound.'),+ has_due_at: zod.boolean().optional().describe('Filter tasks by whether a deadline exists.'),+ limit: zod+ .number()+ .min(1)+ .max(customerTasksListQueryLimitMax)+ .default(customerTasksListQueryLimitDefault)+ .describe('Page size, from 1 to 100.'),+ offset: zod+ .number()+ .min(customerTasksListQueryOffsetMin)+ .default(customerTasksListQueryOffsetDefault)+ .describe('Number of rows to skip.'),+ ordering: zod+ .string()+ .min(1)+ .optional()+ .describe(+ 'Sort by task name, status, assignee, deadline, last update, account, or creation time. Prefix with - for descending order.\n\n\* `name` - name\n\* `-name` - -name\n\* `status` - status\n\* `-status` - -status\n\* `assigned_to` - assigned_to\n\* `-assigned_to` - -assigned_to\n\* `due_at` - due_at\n\* `-due_at` - -due_at\n\* `updated_at` - updated_at\n\* `-updated_at` - -updated_at\n\* `account` - account\n\* `-account` - -account\n\* `created_at` - created_at\n\* `-created_at` - -created_at'+ ),+ search: zod.string().optional().describe('Search task name and description.'),+ statuses: zod.string().min(1).optional().describe('Comma-separated task statuses.'),+})++export const CustomerTasksCreateParams = () => 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 customerTasksCreateBodyNameMax = 400++export const customerTasksCreateBodyStatusDefault = `open`++export const CustomerTasksCreateBody = () => zod.object({+ account_id: zod.string().nullish().describe('UUID of a visible account, or null for an accountless task.'),+ name: zod.string().max(customerTasksCreateBodyNameMax).describe('Task name.'),+ description: zod.string().nullish().describe('Task description, or null to leave it empty.'),+ assigned_to_id: zod.number().nullish().describe('PostHog user ID to assign, or null to leave unassigned.'),+ due_at: zod.iso.datetime({ offset: true }).nullish().describe('ISO 8601 deadline, or null for no deadline.'),+ status: zod+ .enum(['open', 'in_progress', 'completed', 'canceled'])+ .describe(+ '\* `open` - Open\n\* `in_progress` - In progress\n\* `completed` - Completed\n\* `canceled` - Canceled'+ )+ .default(customerTasksCreateBodyStatusDefault)+ .describe(+ 'Initial task status.\n\n\* `open` - Open\n\* `in_progress` - In progress\n\* `completed` - Completed\n\* `canceled` - Canceled'+ ),+})++export const CustomerTasksRetrieveParams = () => zod.object({+ id: zod.string(),+ project_id: zod+ .string()+ .describe(+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."+ ),+})++export const CustomerTasksPartialUpdateParams = () => zod.object({+ id: zod.string(),+ project_id: zod+ .string()+ .describe(+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."+ ),+})++export const customerTasksPartialUpdateBodyNameMax = 400++export const CustomerTasksPartialUpdateBody = () => zod.object({+ account_id: zod.string().nullish().describe('UUID of a visible account, or null to remove the account link.'),+ name: zod.string().max(customerTasksPartialUpdateBodyNameMax).optional().describe('Replacement task name.'),+ description: zod.string().nullish().describe('Replacement description, or null to clear it.'),+ assigned_to_id: zod.number().nullish().describe('Replacement assignee ID, or null to unassign.'),+ due_at: zod.iso+ .datetime({ offset: true })+ .nullish()+ .describe('Replacement ISO 8601 deadline, or null to clear it.'),+ status: zod+ .enum(['open', 'in_progress', 'completed', 'canceled'])+ .describe(+ '\* `open` - Open\n\* `in_progress` - In progress\n\* `completed` - Completed\n\* `canceled` - Canceled'+ )+ .optional()+ .describe(+ 'Replacement task status.\n\n\* `open` - Open\n\* `in_progress` - In progress\n\* `completed` - Completed\n\* `canceled` - Canceled'+ ),+})++export const CustomerTasksActivitiesListParams = () => zod.object({+ id: zod.string(),+ project_id: zod+ .string()+ .describe(+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."+ ),+})++export const customerTasksActivitiesListQueryLimitDefault = 50+export const customerTasksActivitiesListQueryLimitMax = 100++export const customerTasksActivitiesListQueryOffsetDefault = 0+export const customerTasksActivitiesListQueryOffsetMin = 0++export const CustomerTasksActivitiesListQueryParams = () => zod.object({+ limit: zod+ .number()+ .min(1)+ .max(customerTasksActivitiesListQueryLimitMax)+ .default(customerTasksActivitiesListQueryLimitDefault)+ .describe('Page size, from 1 to 100.'),+ offset: zod+ .number()+ .min(customerTasksActivitiesListQueryOffsetMin)+ .default(customerTasksActivitiesListQueryOffsetDefault)+ .describe('Number of rows to skip.'),+})++export const CustomerTasksArchiveCreateParams = () => zod.object({+ id: zod.string(),+ project_id: zod+ .string()+ .describe(+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."+ ),+})++export const CustomerTasksRestoreCreateParams = () => zod.object({+ id: zod.string(),+ project_id: zod+ .string()+ .describe(+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."+ ),+})+/*** The caller's event stream: a live feed of selected accounts' events posted to a* Slack channel of their choice. Per-user — each team member owns at most one stream, anddiff --git a/services/mcp/src/tools/generated/customer_analytics.ts b/services/mcp/src/tools/generated/customer_analytics.tsindex 2940b89e7ed9..defe0cd7b4d9 100644--- a/services/mcp/src/tools/generated/customer_analytics.ts+++ b/services/mcp/src/tools/generated/customer_analytics.ts@@ -1132,6 +1132,208 @@ const customPropertySourcesSync = (): ToolBase<ReturnType<typeof CustomPropertyS},})+const CustomerTasksActivitiesListSchema = () => {+ const CustomerTasksActivitiesListParams = orvalSchemas.CustomerTasksActivitiesListParams()+ const CustomerTasksActivitiesListQueryParams = orvalSchemas.CustomerTasksActivitiesListQueryParams()+ return CustomerTasksActivitiesListParams.omit({ project_id: true }).extend(+ CustomerTasksActivitiesListQueryParams.shape+ )+}++const customerTasksActivitiesList = (): ToolBase<+ ReturnType<typeof CustomerTasksActivitiesListSchema>,+ WithPostHogUrl<Schemas.CustomerTaskActivityPage>+> => ({+ name: 'customer-tasks-activities-list',+ schema: CustomerTasksActivitiesListSchema(),+ handler: async (context: Context, params: z.infer<ReturnType<typeof CustomerTasksActivitiesListSchema>>) => {+ const projectId = await context.stateManager.getProjectId()+ const result = await context.api.request<Schemas.CustomerTaskActivityPage>({+ method: 'GET',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/customer_tasks/${encodeURIComponent(String(params.id))}/activities/`,+ query: {+ limit: params.limit,+ offset: params.offset,+ },+ })+ return await withPostHogUrl(context, result, '/customer_analytics')+ },+})++const CustomerTasksArchiveCreateSchema = () => {+ const CustomerTasksArchiveCreateParams = orvalSchemas.CustomerTasksArchiveCreateParams()+ return CustomerTasksArchiveCreateParams.omit({ project_id: true })+}++const customerTasksArchiveCreate = (): ToolBase<+ ReturnType<typeof CustomerTasksArchiveCreateSchema>,+ Schemas.CustomerTask+> => ({+ name: 'customer-tasks-archive-create',+ schema: CustomerTasksArchiveCreateSchema(),+ handler: async (context: Context, params: z.infer<ReturnType<typeof CustomerTasksArchiveCreateSchema>>) => {+ const projectId = await context.stateManager.getProjectId()+ const result = await context.api.request<Schemas.CustomerTask>({+ method: 'POST',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/customer_tasks/${encodeURIComponent(String(params.id))}/archive/`,+ })+ return result+ },+})++const CustomerTasksCreateSchema = () => {+ const CustomerTasksCreateBody = orvalSchemas.CustomerTasksCreateBody()+ return CustomerTasksCreateBody+}++const customerTasksCreate = (): ToolBase<ReturnType<typeof CustomerTasksCreateSchema>, Schemas.CustomerTask> => ({+ name: 'customer-tasks-create',+ schema: CustomerTasksCreateSchema(),+ handler: async (context: Context, params: z.infer<ReturnType<typeof CustomerTasksCreateSchema>>) => {+ const projectId = await context.stateManager.getProjectId()+ const body: Record<string, unknown> = {}+ if (params.account_id !== undefined) {+ body['account_id'] = params.account_id+ }+ if (params.name !== undefined) {+ body['name'] = params.name+ }+ if (params.description !== undefined) {+ body['description'] = params.description+ }+ if (params.assigned_to_id !== undefined) {+ body['assigned_to_id'] = params.assigned_to_id+ }+ if (params.due_at !== undefined) {+ body['due_at'] = params.due_at+ }+ if (params.status !== undefined) {+ body['status'] = params.status+ }+ const result = await context.api.request<Schemas.CustomerTask>({+ method: 'POST',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/customer_tasks/`,+ body,+ })+ return result+ },+})++const CustomerTasksListSchema = () => {+ const CustomerTasksListQueryParams = orvalSchemas.CustomerTasksListQueryParams()+ return CustomerTasksListQueryParams+}++const customerTasksList = (): ToolBase<+ ReturnType<typeof CustomerTasksListSchema>,+ WithPostHogUrl<Schemas.CustomerTaskPage>+> => ({+ name: 'customer-tasks-list',+ schema: CustomerTasksListSchema(),+ handler: async (context: Context, params: z.infer<ReturnType<typeof CustomerTasksListSchema>>) => {+ const projectId = await context.stateManager.getProjectId()+ const result = await context.api.request<Schemas.CustomerTaskPage>({+ method: 'GET',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/customer_tasks/`,+ query: {+ account_id: params.account_id,+ archive_state: params.archive_state,+ assigned_to: params.assigned_to,+ due_after: params.due_after,+ due_before: params.due_before,+ has_due_at: params.has_due_at,+ limit: params.limit,+ offset: params.offset,+ ordering: params.ordering,+ search: params.search,+ statuses: params.statuses,+ },+ })+ return await withPostHogUrl(context, result, '/customer_analytics')+ },+})++const CustomerTasksPartialUpdateSchema = () => {+ const CustomerTasksPartialUpdateBody = orvalSchemas.CustomerTasksPartialUpdateBody()+ const CustomerTasksPartialUpdateParams = orvalSchemas.CustomerTasksPartialUpdateParams()+ return CustomerTasksPartialUpdateParams.omit({ project_id: true }).extend(CustomerTasksPartialUpdateBody.shape)+}++const customerTasksPartialUpdate = (): ToolBase<+ ReturnType<typeof CustomerTasksPartialUpdateSchema>,+ Schemas.CustomerTask+> => ({+ name: 'customer-tasks-partial-update',+ schema: CustomerTasksPartialUpdateSchema(),+ handler: async (context: Context, params: z.infer<ReturnType<typeof CustomerTasksPartialUpdateSchema>>) => {+ const projectId = await context.stateManager.getProjectId()+ const body: Record<string, unknown> = {}+ if (params.account_id !== undefined) {+ body['account_id'] = params.account_id+ }+ if (params.name !== undefined) {+ body['name'] = params.name+ }+ if (params.description !== undefined) {+ body['description'] = params.description+ }+ if (params.assigned_to_id !== undefined) {+ body['assigned_to_id'] = params.assigned_to_id+ }+ if (params.due_at !== undefined) {+ body['due_at'] = params.due_at+ }+ if (params.status !== undefined) {+ body['status'] = params.status+ }+ const result = await context.api.request<Schemas.CustomerTask>({+ method: 'PATCH',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/customer_tasks/${encodeURIComponent(String(params.id))}/`,+ body,+ })+ return result+ },+})++const CustomerTasksRestoreCreateSchema = () => {+ const CustomerTasksRestoreCreateParams = orvalSchemas.CustomerTasksRestoreCreateParams()+ return CustomerTasksRestoreCreateParams.omit({ project_id: true })+}++const customerTasksRestoreCreate = (): ToolBase<+ ReturnType<typeof CustomerTasksRestoreCreateSchema>,+ Schemas.CustomerTask+> => ({+ name: 'customer-tasks-restore-create',+ schema: CustomerTasksRestoreCreateSchema(),+ handler: async (context: Context, params: z.infer<ReturnType<typeof CustomerTasksRestoreCreateSchema>>) => {+ const projectId = await context.stateManager.getProjectId()+ const result = await context.api.request<Schemas.CustomerTask>({+ method: 'POST',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/customer_tasks/${encodeURIComponent(String(params.id))}/restore/`,+ })+ return result+ },+})++const CustomerTasksRetrieveSchema = () => {+ const CustomerTasksRetrieveParams = orvalSchemas.CustomerTasksRetrieveParams()+ return CustomerTasksRetrieveParams.omit({ project_id: true })+}++const customerTasksRetrieve = (): ToolBase<ReturnType<typeof CustomerTasksRetrieveSchema>, Schemas.CustomerTask> => ({+ name: 'customer-tasks-retrieve',+ schema: CustomerTasksRetrieveSchema(),+ handler: async (context: Context, params: z.infer<ReturnType<typeof CustomerTasksRetrieveSchema>>) => {+ const projectId = await context.stateManager.getProjectId()+ const result = await context.api.request<Schemas.CustomerTask>({+ method: 'GET',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/customer_tasks/${encodeURIComponent(String(params.id))}/`,+ })+ return result+ },+})+const EventStreamsAddAccountSchema = () => {const EventStreamsAddAccountCreateBody = orvalSchemas.EventStreamsAddAccountCreateBody()const EventStreamsAddAccountCreateParams = orvalSchemas.EventStreamsAddAccountCreateParams()@@ -2055,6 +2257,13 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'custom-property-sources-retrieve': customPropertySourcesRetrieve,'custom-property-sources-runs-list': customPropertySourcesRunsList,'custom-property-sources-sync': customPropertySourcesSync,+ 'customer-tasks-activities-list': customerTasksActivitiesList,+ 'customer-tasks-archive-create': customerTasksArchiveCreate,+ 'customer-tasks-create': customerTasksCreate,+ 'customer-tasks-list': customerTasksList,+ 'customer-tasks-partial-update': customerTasksPartialUpdate,+ 'customer-tasks-restore-create': customerTasksRestoreCreate,+ 'customer-tasks-retrieve': customerTasksRetrieve,'event-streams-add-account': eventStreamsAddAccount,'event-streams-create': eventStreamsCreate,'event-streams-destroy': eventStreamsDestroy,diff --git a/services/mcp/tests/unit/customer-task-update.test.ts b/services/mcp/tests/unit/customer-task-update.test.tsnew file mode 100644index 000000000000..f923bfee5392--- /dev/null+++ b/services/mcp/tests/unit/customer-task-update.test.ts@@ -0,0 +1,27 @@+import { describe, expect, it, vi } from 'vitest'++import { GENERATED_TOOLS } from '@/tools/generated/customer_analytics'+import type { Context } from '@/tools/types'++describe('customer task updates', () => {+ it.each([{ status: 'completed' }, { account_id: null, assigned_to_id: null, due_at: null, description: null }])(+ 'preserves omitted fields and forwards explicit changes: %j',+ async (changes) => {+ const request = vi.fn().mockResolvedValue({ id: '00000000-0000-4000-8000-000000000001' })+ const context = {+ api: { request },+ stateManager: { getProjectId: async () => '42' },+ } as unknown as Context+ const tool = GENERATED_TOOLS['customer-tasks-partial-update']!()+ const params = tool.schema.parse({ id: '00000000-0000-4000-8000-000000000001', ...changes })++ await tool.handler(context, params)++ expect(request).toHaveBeenCalledWith({+ method: 'PATCH',+ path: '/api/projects/42/customer_tasks/00000000-0000-4000-8000-000000000001/',+ body: changes,+ })+ }+ )+})diff --git a/services/mcp/tests/unit/tool-filtering.test.ts b/services/mcp/tests/unit/tool-filtering.test.tsindex 11897d81537b..f6e8f9b318fe 100644--- a/services/mcp/tests/unit/tool-filtering.test.ts+++ b/services/mcp/tests/unit/tool-filtering.test.ts@@ -958,6 +958,7 @@ describe('Tool Filtering - Feature Flags', () => {'user-interviews','customer-analytics-csp','customer-analytics-feature-requests',+ 'customer-analytics-customer-tasks','notebooks-collaboration','revamped-py-notebooks','notebook-generated-widgets',@@ -987,7 +988,7 @@ describe('Tool Filtering - Feature Flags', () => {'warehouse-multi-destination',]))- expect(flags).toHaveLength(34)+ expect(flags).toHaveLength(35)})it('every loops tool is gated on the loops flag', () => {