Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(access-control): write MCP tools per subject (#102274)

Alex Lider5bcf222c3f12
diff --git a/frontend/src/lib/agentScopes.generated.ts b/frontend/src/lib/agentScopes.generated.ts
index 54f3029a713b..9361799baa13 100644
--- a/frontend/src/lib/agentScopes.generated.ts
+++ b/frontend/src/lib/agentScopes.generated.ts
@@ -10,6 +10,7 @@ export const AGENT_USE_CASE_SCOPES = [
'action:read',
'action:write',
'access_control:read',
+ 'access_control:write',
'account:read',
'account:write',
'activity_log:read',
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index b58a2ec02243..808fe8a6059a 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -626,6 +626,7 @@ SPECTACULAR_SETTINGS = {
# class carries them. The lists are derived from those literals.
"ResolvedAccessSourceEnum": "products.access_control.backend.facade.enums.RESOLVED_ACCESS_SOURCE_CHOICES",
"ResolvedAccessSourceSubjectEnum": "products.access_control.backend.facade.enums.RESOLVED_ACCESS_SOURCE_SUBJECT_CHOICES",
+ "RuleResourceEnum": "products.access_control.backend.facade.user_access_control.RULE_RESOURCE_CHOICES",
"TaskArtifactStatusEnum": ["active", "failed"],
# signals maps a warehouse import's status down to these three. Same values as the
# warehouse's own SyncStatus, but that class carries different labels, so the two are
diff --git a/products/access_control/backend/facade/api.py b/products/access_control/backend/facade/api.py
index ee4827c1b077..d507805382df 100644
--- a/products/access_control/backend/facade/api.py
+++ b/products/access_control/backend/facade/api.py
@@ -21,6 +21,7 @@ from __future__ import annotations
from typing import cast
from uuid import UUID
+from django.http import Http404
from django.shortcuts import get_object_or_404
from posthog.hogql.property_access_types import RestrictedProperty
@@ -90,15 +91,17 @@ def _to_rule(rule: PropertyAccessControl) -> contracts.PropertyAccessControlRule
def _get_property_definition(property_definition_id: str, team_id: int) -> PropertyDefinition:
+ # Callers often send the property name. The pk is a UUID, and Django raises its own
+ # ValidationError for any other string, which the API would turn into a 500.
+ try:
+ UUID(str(property_definition_id))
+ except ValueError as exc:
+ raise PropertyDefinitionNotFoundError(property_definition_id) from exc
try:
return get_object_or_404(PropertyDefinition, id=property_definition_id, team_id=team_id)
- except Exception as exc:
+ except Http404 as exc:
# Normalize 404 -> domain error so presentation can translate without leaking ORM concerns.
- from django.http import Http404
-
- if isinstance(exc, Http404):
- raise PropertyDefinitionNotFoundError(property_definition_id) from exc
- raise
+ raise PropertyDefinitionNotFoundError(property_definition_id) from exc
# --- Read API ---
diff --git a/products/access_control/backend/facade/user_access_control.py b/products/access_control/backend/facade/user_access_control.py
index d9acef1ca064..58e0d62934f9 100644
--- a/products/access_control/backend/facade/user_access_control.py
+++ b/products/access_control/backend/facade/user_access_control.py
@@ -127,6 +127,13 @@ RESOURCE_INHERITANCE_MAP: dict[APIScopeObject, APIScopeObject] = {
"vision_alert": "replay_scanner",
}
+# Every scope a rule write accepts: the project, the resource types with resource-level rules,
+# the resource types that inherit from one of them and take object rules only, and properties.
+# The schema names it RuleResourceEnum through ENUM_NAME_OVERRIDES in posthog/settings/web.py.
+RULE_RESOURCE_CHOICES: list[str] = sorted(
+ {"project", "property_definition", *ACCESS_CONTROL_RESOURCES, *RESOURCE_INHERITANCE_MAP}
+)
+
# Unlike RESOURCE_INHERITANCE_MAP above, where the child has no access of its own and just uses the
# parent's, this checks the child's own access first and falls back to the parent.
# For example:
diff --git a/products/access_control/backend/presentation/access_control.py b/products/access_control/backend/presentation/access_control.py
index 5bcb57eda980..3cd4615f5692 100644
--- a/products/access_control/backend/presentation/access_control.py
+++ b/products/access_control/backend/presentation/access_control.py
@@ -247,15 +247,16 @@ class AccessControlSerializer(serializers.ModelSerializer):
return data
-def upsert_access_control(
+def apply_access_control_rule(
*,
team: Team,
user_access_control: UserAccessControl,
build_serializer: Callable[[AccessControl | None], AccessControlSerializer],
-) -> Response:
+) -> AccessControl | None:
"""Apply one validated access control rule: a null level deletes the subject's rule, any other
- level creates or updates it. Shared by the per-resource PUT actions and the settings page's
- generic object-rule write, so validation and cache behavior cannot drift between them."""
+ level creates or updates it. Returns the stored row, or None once the rule is gone. Shared by
+ the per-resource PUT actions and the settings page's rule writes, so validation and cache
+ behavior cannot drift between them."""
serializer = build_serializer(None)
serializer.is_valid(raise_exception=True)
params = serializer.validated_data
@@ -269,21 +270,38 @@ def upsert_access_control(
).first()
if params["access_level"] is None:
- if instance:
- instance.delete()
- # Drop the preloaded access-control snapshot so later reads this request are fresh.
- user_access_control._clear_cache()
- return Response(status=status.HTTP_204_NO_CONTENT)
+ if instance is None:
+ return None
+ instance.delete()
+ # Drop the preloaded access-control snapshot so later reads this request are fresh.
+ user_access_control._clear_cache()
+ return None
if instance:
serializer = build_serializer(instance)
serializer.is_valid(raise_exception=True)
serializer.validated_data["team"] = team
- serializer.save()
+ rule = serializer.save()
# Drop the preloaded access-control snapshot so later reads this request are fresh.
user_access_control._clear_cache()
- return Response(serializer.data, status=status.HTTP_200_OK)
+ return rule
+
+
+def upsert_access_control(
+ *,
+ team: Team,
+ user_access_control: UserAccessControl,
+ build_serializer: Callable[[AccessControl | None], AccessControlSerializer],
+) -> Response:
+ """The 200-or-204 form of `apply_access_control_rule` that the settings UI and the per-resource
+ PUT actions expect."""
+ rule = apply_access_control_rule(
+ team=team, user_access_control=user_access_control, build_serializer=build_serializer
+ )
+ if rule is None:
+ return Response(status=status.HTTP_204_NO_CONTENT)
+ return Response(AccessControlSerializer(rule).data, status=status.HTTP_200_OK)
class AccessControlViewSetMixin(_GenericViewSet):
diff --git a/products/access_control/backend/presentation/access_control_settings.py b/products/access_control/backend/presentation/access_control_settings.py
index 659f7f56d85a..7331f5c3410b 100644
--- a/products/access_control/backend/presentation/access_control_settings.py
+++ b/products/access_control/backend/presentation/access_control_settings.py
@@ -7,8 +7,10 @@ controls every product viewset mixes in stay in access_control.py.
"""
from collections import defaultdict
+from collections.abc import Callable
from dataclasses import asdict, dataclass
from typing import TYPE_CHECKING, Any, cast
+from uuid import UUID
from django.core.cache import cache as django_cache
from django.core.exceptions import ValidationError as DjangoValidationError
@@ -16,7 +18,7 @@ from django.db.models import Count, Max, Model, Prefetch, Q
from django.db.models.functions import Coalesce
from drf_spectacular.types import OpenApiTypes
-from rest_framework import exceptions
+from rest_framework import exceptions, serializers, status
from rest_framework.decorators import action
from rest_framework.generics import get_object_or_404
from rest_framework.request import Request
@@ -30,6 +32,12 @@ from posthog.models.team.team import Team
from posthog.permissions import get_authenticator_scoped_team_ids
from posthog.scopes import APIScopeObject
+from products.access_control.backend.facade import api as access_control_api
+from products.access_control.backend.facade.contracts import (
+ DeletePropertyAccessControlInput,
+ PropertyAccessLevel,
+ UpsertPropertyAccessControlInput,
+)
from products.access_control.backend.facade.object_names import (
display_model,
model_has_field,
@@ -41,6 +49,7 @@ from products.access_control.backend.facade.subject_access_control import Subjec
from products.access_control.backend.facade.user_access_control import (
ACCESS_CONTROL_LEVELS_RESOURCE,
ACCESS_CONTROL_RESOURCES,
+ RESOURCES_WITHOUT_RESOURCE_LEVEL_CONTROLS,
AccessControlLevel,
UserAccessControl,
default_access_level,
@@ -51,15 +60,20 @@ from products.access_control.backend.facade.user_access_control import (
from products.access_control.backend.models.access_control import AccessControl
from products.access_control.backend.models.role import Role, RoleMembership
-from .access_control import AccessControlSerializer, upsert_access_control
+from .access_control import AccessControlSerializer, apply_access_control_rule, upsert_access_control
from .serializers import (
AccessControlDefaultsResponseSerializer,
+ AccessControlMemberRuleRequestSerializer,
AccessControlMembersResponseSerializer,
AccessControlObjectRulesResponseSerializer,
AccessControlPropertyRulesResponseSerializer,
AccessControlResolutionAcceptResponseSerializer,
+ AccessControlRoleRuleRequestSerializer,
AccessControlRolesResponseSerializer,
+ AccessControlRuleRequestSerializer,
+ AccessControlStoredRuleSerializer,
)
+from .views import check_can_write_property_rules, check_can_write_role_rule
if TYPE_CHECKING:
_GenericViewSet = GenericViewSet
@@ -69,6 +83,8 @@ else:
# These actions sit on the core project viewset, so the product has to be named for the
# generated types and MCP tools to land in access_control rather than core
_SCHEMA_EXTENSIONS = {"x-product": "access_control"}
+# The rule writes are for MCP tools and the frontend, not a public REST contract
+_INTERNAL_SCHEMA_EXTENSIONS = {**_SCHEMA_EXTENSIONS, "x-internal": True}
_MEMBER_ID_PARAM = OpenApiParameter(
name="member_id",
@@ -142,7 +158,12 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
"access_control_resolution_preview",
]:
return ["access_control:read"]
- if request.method == "PUT" and self.action == "access_control_object_rules":
+ if request.method == "PUT" and self.action in [
+ "access_control_object_rules",
+ "access_control_default_rules",
+ "access_control_member_rules",
+ "access_control_role_rules",
+ ]:
return ["access_control:write"]
if request.method == "POST" and self.action == "access_control_resolution_accept":
return ["access_control:write"]
@@ -434,6 +455,9 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
member_id = request.query_params.get("member_id")
if not member_id:
raise exceptions.ValidationError("member_id is required")
+ return self._visible_membership(team, member_id)
+
+ def _visible_membership(self, team: Team, member_id: str) -> OrganizationMembership:
user_access_control = cast(UserAccessControl, self.user_access_control) # type: ignore
# An org hiding its member list means plain members can't browse other members' details, so 404.
# Org admins and explicit project admins keep these endpoints, since they can manage access
@@ -517,11 +541,7 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
role: Role | None = None,
) -> Response:
"""Property rules belonging to one subject, including read & write grants over a stricter default."""
- from products.access_control.backend.facade.api import (
- list_property_access_controls, # noqa: PLC0415 — the facade imports ee models, a module-level import would be circular
- )
-
- rules = list_property_access_controls(
+ rules = access_control_api.list_property_access_controls(
team_id=team.id,
organization_member_id=organization_member.id if organization_member else None,
role_id=role.id if role else None,
@@ -709,11 +729,31 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
resource = str(request.data.get("resource") or "")
resource_id = str(request.data.get("resource_id") or "")
+ if not resource_id:
+ raise exceptions.ValidationError("resource_id is required")
+ target = self._visible_object(
+ team, user_access_control, resource, resource_id, access_level=request.data.get("access_level")
+ )
+
+ data = {**request.data, "resource": resource, "resource_id": resource_id}
+ return upsert_access_control(
+ team=team,
+ user_access_control=user_access_control,
+ build_serializer=self._rule_serializer_builder(team, user_access_control, target, data),
+ )
+
+ def _visible_object(
+ self,
+ team: Team,
+ user_access_control: UserAccessControl,
+ resource: str,
+ resource_id: str,
+ *,
+ access_level: object,
+ ) -> Model:
display = display_model(resource)
if display is None:
raise exceptions.ValidationError("resource does not support object access rules")
- if not resource_id:
- raise exceptions.ValidationError("resource_id is required")
# _base_manager, not the default one: a rule left on a soft-deleted object still shows in
# the rules list, and this is the only way to clear it
visible = user_access_control.filter_queryset_by_access_level(
@@ -724,16 +764,214 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
# An object the requester cannot see is not theirs to configure; 404 rather than 403 so the
# endpoint doesn't confirm it exists
target = get_object_or_404(visible, pk=resource_id)
- if request.data.get("access_level") is not None and getattr(target, "deleted", None) is True:
+ if access_level is not None and getattr(target, "deleted", None) is True:
raise exceptions.ValidationError("cannot set an access rule on a deleted object")
+ return target
- data = {**request.data, "resource": resource, "resource_id": resource_id}
+ def _rule_serializer_builder(
+ self, team: Team, user_access_control: UserAccessControl, target: Model, data: dict[str, Any]
+ ) -> Callable[[AccessControl | None], AccessControlSerializer]:
context = {
**self.get_serializer_context(),
"view": _ObjectRuleValidationContext(team=team, user_access_control=user_access_control, target=target),
}
- return upsert_access_control(
+ return lambda instance: AccessControlSerializer(instance, data=data, context=context)
+
+ def _rule_target(
+ self,
+ team: Team,
+ user_access_control: UserAccessControl,
+ resource: str,
+ resource_id: str | None,
+ *,
+ access_level: str | None,
+ ) -> tuple[Model, str | None]:
+ """The object a rule is validated against, and the resource_id to store.
+
+ A project rule is stored as an object rule on the team itself, so the team is both the
+ target and the id. A resource-type rule has no object; the team stands in for the permission
+ check, which AccessControlSerializer runs against the project for such rules.
+ """
+ if resource == "project":
+ if resource_id != str(team.id):
+ raise exceptions.ValidationError("A project rule takes the project's own id as resource_id.")
+ return team, resource_id
+ if resource in RESOURCES_WITHOUT_RESOURCE_LEVEL_CONTROLS:
+ raise exceptions.ValidationError(f"{resource} does not accept access rules.")
+ if resource_id:
+ target = self._visible_object(team, user_access_control, resource, resource_id, access_level=access_level)
+ return target, resource_id
+ if resource not in ACCESS_CONTROL_RESOURCES:
+ raise exceptions.ValidationError(
+ f"{resource} has no resource-level rules. Pass a resource_id for a rule on one object."
+ )
+ return team, None
+
+ def _write_rule(self, request: Request, request_serializer: type[serializers.Serializer]) -> Response:
+ """Set or clear one rule for the subject the request serializer names.
+
+ The subject is resolved to a row first, so a member hidden from the caller or a role of
+ another organization is a 404 before any validation runs. Property rules live in their own
+ model and go through the property facade; everything else is an AccessControl row.
+ """
+ team = cast(Team, self.team) # type: ignore
+ user_access_control = cast(UserAccessControl, self.user_access_control) # type: ignore
+ serializer = request_serializer(data=request.data)
+ serializer.is_valid(raise_exception=True)
+ data = serializer.validated_data
+
+ membership: OrganizationMembership | None = None
+ role: Role | None = None
+ if "member_id" in data:
+ membership = self._visible_membership(team, str(data["member_id"]))
+ if "role_id" in data:
+ role = get_object_or_404(Role, id=data["role_id"], organization=team.organization)
+
+ resource = data["resource"]
+ resource_id = data.get("resource_id") or None
+ access_level = data["access_level"]
+ if resource == "property_definition":
+ return self._write_property_rule(
+ team, user_access_control, resource_id, access_level, membership=membership, role=role
+ )
+
+ target, stored_resource_id = self._rule_target(
+ team, user_access_control, resource, resource_id, access_level=access_level
+ )
+ body: dict[str, Any] = {"resource": resource, "resource_id": stored_resource_id, "access_level": access_level}
+ if membership is not None:
+ body["organization_member"] = str(membership.id)
+ if role is not None:
+ body["role"] = str(role.id)
+ rule = apply_access_control_rule(
team=team,
user_access_control=user_access_control,
- build_serializer=lambda instance: AccessControlSerializer(instance, data=data, context=context),
+ build_serializer=self._rule_serializer_builder(team, user_access_control, target, body),
+ )
+ if rule is None:
+ return Response(status=status.HTTP_204_NO_CONTENT)
+ return self._stored_rule_response(
+ resource=rule.resource,
+ resource_id=rule.resource_id,
+ access_level=rule.access_level,
+ member_id=rule.organization_member_id,
+ role_id=rule.role_id,
+ )
+
+ def _write_property_rule(
+ self,
+ team: Team,
+ user_access_control: UserAccessControl,
+ property_definition_id: str | None,
+ access_level: str | None,
+ *,
+ membership: OrganizationMembership | None,
+ role: Role | None,
+ ) -> Response:
+ """Property rules live in their own model and go through the property facade, behind the
+ same gate as PropertyAccessControlViewSet."""
+ if not property_definition_id:
+ raise exceptions.ValidationError("resource_id is required for a property rule.")
+ check_can_write_property_rules(team, user_access_control)
+ check_can_write_role_rule(team, role_id=role.id if role else None)
+ levels = [level.value for level in PropertyAccessLevel]
+ if access_level is not None and access_level not in levels:
+ raise exceptions.ValidationError(f"Invalid access level. Must be one of: {', '.join(levels)}")
+
+ membership_id = membership.id if membership else None
+ role_id = role.id if role else None
+ try:
+ if access_level is None:
+ access_control_api.delete_property_access_control(
+ team_id=team.id,
+ input=DeletePropertyAccessControlInput(
+ property_definition_id=property_definition_id,
+ organization_member_id=membership_id,
+ role_id=role_id,
+ ),
+ )
+ return Response(status=status.HTTP_204_NO_CONTENT)
+ rule = access_control_api.upsert_property_access_control(
+ team_id=team.id,
+ created_by_id=self.request.user.pk if self.request.user.is_authenticated else None,
+ input=UpsertPropertyAccessControlInput(
+ property_definition_id=property_definition_id,
+ access_level=PropertyAccessLevel(access_level),
+ organization_member_id=membership_id,
+ role_id=role_id,
+ ),
+ )
+ except access_control_api.PropertyAccessControlRuleNotFoundError:
+ # Nothing to clear, including a rule a concurrent clear removed first
+ return Response(status=status.HTTP_204_NO_CONTENT)
+ except access_control_api.PropertyDefinitionNotFoundError:
+ raise exceptions.NotFound("Property definition not found.")
+ except access_control_api.InvalidPropertyAccessControlTargetError as exc:
+ raise exceptions.ValidationError(str(exc))
+ return self._stored_rule_response(
+ resource="property_definition",
+ resource_id=str(rule.property_definition_id),
+ access_level=rule.access_level.value,
+ member_id=rule.organization_member_id,
+ role_id=rule.role_id,
)
+
+ @staticmethod
+ def _stored_rule_response(
+ *,
+ resource: str,
+ resource_id: str | None,
+ access_level: str,
+ member_id: UUID | None,
+ role_id: UUID | None,
+ ) -> Response:
+ """The stored rule in one shape for access rules and property rules."""
+ stored = {
+ "resource": resource,
+ "resource_id": resource_id,
+ "access_level": access_level,
+ "member_id": member_id,
+ "role_id": role_id,
+ }
+ return Response(AccessControlStoredRuleSerializer(stored).data)
+
+ @extend_schema(
+ description="Set or clear the rule everyone in the project gets for a scope, unless a member or role rule "
+ "of their own applies. The scope is the project (`resource: project` with the project id as `resource_id`), "
+ "a whole resource type, one object, or one property definition. A null `access_level` removes the rule. "
+ "Returns the stored rule, or 204 with no body when the rule is cleared.",
+ request=AccessControlRuleRequestSerializer,
+ responses={200: AccessControlStoredRuleSerializer, 204: None},
+ extensions=_INTERNAL_SCHEMA_EXTENSIONS,
+ )
+ @action(methods=["PUT"], detail=True, url_path="access_control_default_rules")
+ def access_control_default_rules(self, request: Request, *args, **kwargs) -> Response:
+ return self._write_rule(request, AccessControlRuleRequestSerializer)
+
+ @extend_schema(
+ description="Set or clear one member's rule for a scope. A member rule applies to that person only and "
+ "takes precedence over their role rules and the default. The scope is the project (`resource: project` with "
+ "the project id as `resource_id`), a whole resource type, one object, or one property definition. A null "
+ "`access_level` removes the rule. "
+ "Returns the stored rule, or 204 with no body when the rule is cleared.",
+ request=AccessControlMemberRuleRequestSerializer,
+ responses={200: AccessControlStoredRuleSerializer, 204: None},
+ extensions=_INTERNAL_SCHEMA_EXTENSIONS,
+ )
+ @action(methods=["PUT"], detail=True, url_path="access_control_member_rules")
+ def access_control_member_rules(self, request: Request, *args, **kwargs) -> Response:
+ return self._write_rule(request, AccessControlMemberRuleRequestSerializer)
+
+ @extend_schema(
+ description="Set or clear one role's rule for a scope. A role rule applies to every member of the role and "
+ "takes precedence over the default. Requires the role-based access feature. The scope is the project "
+ "(`resource: project` with the project id as `resource_id`), a whole resource type, one object, or one "
+ "property definition. A null `access_level` removes the rule. "
+ "Returns the stored rule, or 204 with no body when the rule is cleared.",
+ request=AccessControlRoleRuleRequestSerializer,
+ responses={200: AccessControlStoredRuleSerializer, 204: None},
+ extensions=_INTERNAL_SCHEMA_EXTENSIONS,
+ )
+ @action(methods=["PUT"], detail=True, url_path="access_control_role_rules")
+ def access_control_role_rules(self, request: Request, *args, **kwargs) -> Response:
+ return self._write_rule(request, AccessControlRoleRuleRequestSerializer)
diff --git a/products/access_control/backend/presentation/serializers.py b/products/access_control/backend/presentation/serializers.py
index 0523a61f1f17..0a5deecde6b9 100644
--- a/products/access_control/backend/presentation/serializers.py
+++ b/products/access_control/backend/presentation/serializers.py
@@ -12,6 +12,7 @@ from posthog.models.organization import OrganizationMembership
from ..facade import contracts
from ..facade.contracts import PropertyAccessLevel
+from ..facade.user_access_control import RULE_RESOURCE_CHOICES
from .access_control import ResolvedAccessSerializer
_ACCESS_LEVEL_CHOICES = [(e.value, e.value) for e in PropertyAccessLevel]
@@ -281,3 +282,60 @@ class AccessControlResolutionAcceptResponseSerializer(serializers.Serializer):
uses_most_specific_access_resolution = serializers.BooleanField(
help_text="Always true: the organization now resolves access with the most specific rule."
)
+
+
+class AccessControlRuleRequestSerializer(serializers.Serializer):
+ """The scope and level of one rule write. On its own it is the default rule, for everyone in the
+ project without a member or role rule of their own. The subclasses add the subject."""
+
+ resource = serializers.ChoiceField(
+ choices=RULE_RESOURCE_CHOICES,
+ help_text="The scope of the rule: `project` for the project itself (with the project id as `resource_id`), "
+ "a resource type such as `dashboard` for the whole resource type or for one object of it, or "
+ "`property_definition` for one person or event property.",
+ )
+ resource_id = serializers.CharField(
+ required=False,
+ allow_null=True,
+ help_text="The object the rule applies to: the project id for a project rule, an object's primary key for "
+ "a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only "
+ "for a rule on a whole resource type.",
+ )
+ access_level = serializers.CharField(
+ allow_null=True,
+ help_text="The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` "
+ "for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, "
+ "so the subject falls back to the level it inherits.",
+ )
+
+
+class AccessControlMemberRuleRequestSerializer(AccessControlRuleRequestSerializer):
+ """A rule for one organization member."""
+
+ member_id = serializers.UUIDField(
+ help_text="The organization membership id, as `organization_membership_id` in the members endpoint.",
+ )
+
+
+class AccessControlRoleRuleRequestSerializer(AccessControlRuleRequestSerializer):
+ """A rule for every member of one role."""
+
+ role_id = serializers.UUIDField(help_text="The role id, as `role_id` in the roles endpoint.")
+
+
+class AccessControlStoredRuleSerializer(serializers.Serializer):
+ """One stored rule, the same shape for object, resource, project and property rules."""
+
+ resource = serializers.CharField(help_text="The rule's scope, as sent in the request.")
+ resource_id = serializers.CharField(
+ allow_null=True,
+ help_text="The object the rule applies to: the project id for a project rule, an object's primary key, or a "
+ "property definition id. Null for a resource-type rule.",
+ )
+ access_level = serializers.CharField(help_text="The stored level.")
+ member_id = serializers.UUIDField(
+ allow_null=True, help_text="The organization membership the rule is for. Null unless it is a member rule."
+ )
+ role_id = serializers.UUIDField(
+ allow_null=True, help_text="The role the rule is for. Null unless it is a role rule."
+ )
diff --git a/products/access_control/backend/presentation/views.py b/products/access_control/backend/presentation/views.py
index 9f5f059f7d92..bb1e5bd01925 100644
--- a/products/access_control/backend/presentation/views.py
+++ b/products/access_control/backend/presentation/views.py
@@ -11,6 +11,7 @@ No business logic or ORM access here — that belongs in the facade / logic laye
"""
from typing import Any
+from uuid import UUID
from drf_spectacular.openapi import AutoSchema
from drf_spectacular.utils import OpenApiParameter, extend_schema
@@ -22,10 +23,12 @@ from rest_framework.viewsets import GenericViewSet
from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.constants import AvailableFeature
+from posthog.models.team.team import Team
from posthog.permissions import TeamMemberStrictManagementPermission
from ..facade import api
from ..facade.contracts import DeletePropertyAccessControlInput, PropertyAccessLevel, UpsertPropertyAccessControlInput
+from ..facade.user_access_control import UserAccessControl
from .serializers import (
PropertyAccessControlDeleteSerializer,
PropertyAccessControlRuleSerializer,
@@ -36,6 +39,24 @@ from .serializers import (
PROPERTY_ACCESS_CONTROL_FEATURE_REQUIRED_MESSAGE = "Property access control feature is required"
+def check_can_write_property_rules(team: Team, user_access_control: UserAccessControl) -> None:
+ """The gate every property rule write passes, from the settings page or the rule endpoints,
+ so the two surfaces cannot drift. Runs before the request body is read, so a caller without
+ access gets 403 rather than a validation error."""
+ if not team.organization.is_feature_available(AvailableFeature.PROPERTY_ACCESS_CONTROL):
+ raise PermissionDenied(PROPERTY_ACCESS_CONTROL_FEATURE_REQUIRED_MESSAGE)
+ if not user_access_control.check_can_modify_access_levels_for_object(team):
+ raise PermissionDenied()
+
+
+def check_can_write_role_rule(team: Team, *, role_id: UUID | None) -> None:
+ """A role rule needs the role-based access feature, the same gate AccessControlSerializer
+ applies to role rules on every other scope. Without it a role rule grants nobody anything,
+ because role memberships are not resolved at all."""
+ if role_id is not None and not team.organization.is_feature_available(AvailableFeature.ROLE_BASED_ACCESS):
+ raise PermissionDenied("Role-based access controls require the Role-based access feature.")
+
+
class _SingletonStateSchema(AutoSchema):
"""Prevents drf-spectacular from wrapping the ``list`` response in an array.
@@ -99,14 +120,12 @@ class PropertyAccessControlViewSet(TeamAndOrgViewSetMixin, GenericViewSet):
description="Create or update a property access control rule.",
)
def create(self, request: Request, *args: Any, **kwargs: Any) -> Response:
- if not self.organization.is_feature_available(AvailableFeature.PROPERTY_ACCESS_CONTROL):
- raise PermissionDenied(PROPERTY_ACCESS_CONTROL_FEATURE_REQUIRED_MESSAGE)
- if not self.user_access_control.check_can_modify_access_levels_for_object(self.team):
- raise PermissionDenied()
+ check_can_write_property_rules(self.team, self.user_access_control)
serializer = PropertyAccessControlUpdateSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
data = serializer.validated_data
+ check_can_write_role_rule(self.team, role_id=data.get("role"))
created_by_id: int | None = request.user.pk if request.user.is_authenticated else None
try:
@@ -159,14 +178,12 @@ class PropertyAccessControlViewSet(TeamAndOrgViewSetMixin, GenericViewSet):
),
)
def destroy(self, request: Request, *args: Any, **kwargs: Any) -> Response:
- if not self.organization.is_feature_available(AvailableFeature.PROPERTY_ACCESS_CONTROL):
- raise PermissionDenied(PROPERTY_ACCESS_CONTROL_FEATURE_REQUIRED_MESSAGE)
- if not self.user_access_control.check_can_modify_access_levels_for_object(self.team):
- raise PermissionDenied()
+ check_can_write_property_rules(self.team, self.user_access_control)
serializer = PropertyAccessControlDeleteSerializer(data=request.query_params)
serializer.is_valid(raise_exception=True)
data = serializer.validated_data
+ check_can_write_role_rule(self.team, role_id=data.get("role"))
try:
api.delete_property_access_control(
diff --git a/products/access_control/backend/tests/test_access_control.py b/products/access_control/backend/tests/test_access_control.py
index e42d0751defc..f33485dd2351 100644
--- a/products/access_control/backend/tests/test_access_control.py
+++ b/products/access_control/backend/tests/test_access_control.py
@@ -1,4 +1,5 @@
import json
+import uuid
from unittest.mock import MagicMock, patch
@@ -10,6 +11,7 @@ from parameterized import parameterized
from rest_framework import status
from posthog.constants import AvailableFeature
+from posthog.models import PropertyDefinition
from posthog.models.organization import Organization, OrganizationMembership
from posthog.models.personal_api_key import PersonalAPIKey
from posthog.models.team.team import Team
@@ -19,9 +21,11 @@ from posthog.session_recordings.models.session_recording import SessionRecording
from posthog.session_recordings.models.session_recording_playlist import SessionRecordingPlaylist
from posthog.utils import render_template
+from products.access_control.backend.facade.api import PropertyAccessControlRuleNotFoundError
from products.access_control.backend.facade.object_names import display_model, resources_with_object_access_controls
from products.access_control.backend.facade.user_access_control import AccessSource
from products.access_control.backend.models.access_control import AccessControl
+from products.access_control.backend.models.property_access_control import PropertyAccessControl
from products.access_control.backend.models.role import Role, RoleMembership
from products.ai_observability.backend.models.evaluations import Evaluation
from products.cohorts.backend.models.cohort import Cohort
@@ -2777,3 +2781,216 @@ class TestOrganizationMemberProjectAccess(BaseAccessControlTest):
# Each project costs one query for its rules; nothing per (member, project) pair
Team.objects.create(organization=self.organization, name="Team D")
assert query_count() == baseline + 1
+
+
+class TestAccessControlSubjectRuleWrites(BaseAccessControlTest):
+ def setUp(self):
+ super().setUp()
+ self._org_membership(OrganizationMembership.Level.ADMIN)
+ colleague = self._create_user("[email protected]")
+ self.colleague_membership = colleague.organization_memberships.get(organization=self.organization)
+ self.role = Role.objects.create(name="Engineering", organization=self.organization)
+ self.dashboard = Dashboard.objects.create(team=self.team, name="Growth", created_by=self.user)
+
+ def _subject(self, subject: str) -> dict:
+ if subject == "member":
+ return {"member_id": str(self.colleague_membership.id)}
+ if subject == "role":
+ return {"role_id": str(self.role.id)}
+ return {}
+
+ def _put(self, subject: str, body: dict, **kwargs):
+ return self.client.put(f"/api/projects/@current/access_control_{subject}_rules", body, **kwargs)
+
+ @parameterized.expand(
+ [
+ (f"{subject}_{scope}", subject, scope)
+ for subject in ("default", "member", "role")
+ for scope in ("project", "resource", "object")
+ ]
+ )
+ def test_writes_a_rule_per_subject_and_scope(self, _name, subject, scope):
+ body = {
+ "project": {"resource": "project", "resource_id": str(self.team.id), "access_level": "admin"},
+ "resource": {"resource": "dashboard", "access_level": "editor"},
+ "object": {"resource": "dashboard", "resource_id": str(self.dashboard.id), "access_level": "viewer"},
+ }[scope]
+ res = self._put(subject, {**body, **self._subject(subject)})
+ assert res.status_code == status.HTTP_200_OK, res.json()
+
+ expected_resource_id = {"project": str(self.team.id), "resource": None, "object": str(self.dashboard.id)}[scope]
+ row = AccessControl.objects.get(team=self.team, resource=body["resource"])
+ assert row.resource_id == expected_resource_id
+ assert row.access_level == body["access_level"]
+ assert str(row.organization_member_id or "") == self._subject(subject).get("member_id", "")
+ assert str(row.role_id or "") == self._subject(subject).get("role_id", "")
+ assert res.json() == {
+ "resource": body["resource"],
+ "resource_id": expected_resource_id,
+ "access_level": body["access_level"],
+ "member_id": self._subject(subject).get("member_id"),
+ "role_id": self._subject(subject).get("role_id"),
+ }
+
+ def test_null_level_clears_the_rule_and_clearing_again_is_idempotent(self):
+ body = {"resource": "dashboard", "access_level": "viewer", **self._subject("member")}
+ assert self._put("member", body).status_code == status.HTTP_200_OK
+ assert self._put("member", {**body, "access_level": "editor"}).status_code == status.HTTP_200_OK
+
+ res = self._put("member", {**body, "access_level": None})
+ assert res.status_code == status.HTTP_204_NO_CONTENT
+ assert not AccessControl.objects.filter(team=self.team, resource="dashboard").exists()
+ assert self._put("member", {**body, "access_level": None}).status_code == status.HTTP_204_NO_CONTENT
+
+ entry = self.client.get(
+ f"/api/projects/@current/access_control_members?member_id={self.colleague_membership.id}"
+ ).json()["results"][0]["resources"]["dashboard"]
+ assert entry["access_level"] is None
+
+ @parameterized.expand([("default",), ("member",), ("role",)])
+ def test_write_requires_access_control_write_scope(self, subject):
+ key_value = generate_random_token_personal()
+ PersonalAPIKey.objects.create(
+ user=self.user, label="read only", secure_value=hash_key_value(key_value), scopes=["access_control:read"]
+ )
+ res = self._put(
+ subject,
+ {"resource": "dashboard", "access_level": "viewer", **self._subject(subject)},
+ headers={"authorization": f"Bearer {key_value}"},
+ )
+ assert res.status_code == status.HTTP_403_FORBIDDEN, res.json()
+ assert "access_control:write" in res.json()["detail"]
+
+ def test_member_rule_requires_a_visible_member(self):
+ res = self._put("member", {"resource": "dashboard", "access_level": "viewer"})
+ assert res.status_code == status.HTTP_400_BAD_REQUEST, res.json()
+ assert res.json()["attr"] == "member_id"
+
+ other_org = Organization.objects.create(name="Other org")
+ other_user = User.objects.create_and_join(other_org, "[email protected]", None)
+ other_membership = OrganizationMembership.objects.get(user=other_user, organization=other_org)
+ res = self._put(
+ "member",
+ {"resource": "dashboard", "access_level": "viewer", "member_id": str(other_membership.id)},
+ )
+ assert res.status_code == status.HTTP_404_NOT_FOUND, res.json()
+
+ # A plain member in an organization that hides its member list cannot address other members
+ self.organization.members_can_see_org_members = False
+ self.organization.save()
+ self._org_membership(OrganizationMembership.Level.MEMBER)
+ res = self._put("member", {"resource": "dashboard", "access_level": "viewer", **self._subject("member")})
+ assert res.status_code == status.HTTP_404_NOT_FOUND, res.json()
+
+ def test_role_rule_requires_the_role_based_access_feature_and_an_org_role(self):
+ other_role = Role.objects.create(name="Other org role", organization=Organization.objects.create(name="O"))
+ res = self._put("role", {"resource": "dashboard", "access_level": "viewer", "role_id": str(other_role.id)})
+ assert res.status_code == status.HTTP_404_NOT_FOUND, res.json()
+
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL}
+ ]
+ self.organization.save()
+ res = self._put("role", {"resource": "dashboard", "access_level": "viewer", **self._subject("role")})
+ assert res.status_code == status.HTTP_403_FORBIDDEN, res.json()
+ assert not AccessControl.objects.filter(team=self.team, role=self.role).exists()
+
+ @parameterized.expand(
+ [
+ ("inheritance_child_without_object", {"resource": "warehouse_table", "access_level": "viewer"}),
+ ("organization", {"resource": "organization", "access_level": "admin"}),
+ ("project_with_foreign_id", {"resource": "project", "resource_id": "999", "access_level": "admin"}),
+ ("project_without_id", {"resource": "project", "access_level": "admin"}),
+ ("level_out_of_bounds", {"resource": "dashboard", "access_level": "owner"}),
+ ]
+ )
+ def test_rejects_scopes_that_store_an_inert_rule(self, _name, body):
+ res = self._put("default", body)
+ assert res.status_code == status.HTTP_400_BAD_REQUEST, res.json()
+ assert not AccessControl.objects.filter(team=self.team).exists()
+
+ def test_object_rule_on_a_hidden_object_is_404(self):
+ owner = User.objects.create_and_join(self.organization, "[email protected]", None)
+ hidden = Dashboard.objects.create(team=self.team, name="Confidential", created_by=owner)
+ AccessControl.objects.create(
+ team=self.team,
+ resource="dashboard",
+ resource_id=str(hidden.id),
+ access_level="none",
+ organization_member=self.organization_membership,
+ )
+ self._org_membership(OrganizationMembership.Level.MEMBER)
+ res = self._put("default", {"resource": "dashboard", "resource_id": str(hidden.id), "access_level": "editor"})
+ assert res.status_code == status.HTTP_404_NOT_FOUND, res.json()
+
+ def _property_definition(self) -> PropertyDefinition:
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},
+ {"key": AvailableFeature.ROLE_BASED_ACCESS, "name": AvailableFeature.ROLE_BASED_ACCESS},
+ {"key": AvailableFeature.PROPERTY_ACCESS_CONTROL, "name": AvailableFeature.PROPERTY_ACCESS_CONTROL},
+ ]
+ self.organization.save()
+ return PropertyDefinition.objects.create(
+ team=self.team, name="salary", property_type="Numeric", type=PropertyDefinition.Type.EVENT
+ )
+
+ @parameterized.expand([("default",), ("member",), ("role",)])
+ def test_property_rule_per_subject_sets_and_clears(self, subject):
+ prop = self._property_definition()
+ body = {"resource": "property_definition", "resource_id": str(prop.id), **self._subject(subject)}
+
+ res = self._put(subject, {**body, "access_level": "none"})
+ assert res.status_code == status.HTTP_200_OK, res.json()
+ assert res.json()["access_level"] == "none"
+ row = PropertyAccessControl.objects.get(team=self.team, property_definition=prop)
+ assert str(row.organization_member_id or "") == self._subject(subject).get("member_id", "")
+ assert str(row.role_id or "") == self._subject(subject).get("role_id", "")
+
+ assert self._put(subject, {**body, "access_level": "read"}).status_code == status.HTTP_200_OK
+ assert self._put(subject, {**body, "access_level": None}).status_code == status.HTTP_204_NO_CONTENT
+ assert not PropertyAccessControl.objects.filter(team=self.team).exists()
+ assert self._put(subject, {**body, "access_level": None}).status_code == status.HTTP_204_NO_CONTENT
+
+ def test_property_rule_clear_that_loses_a_race_is_still_a_204(self):
+ prop = self._property_definition()
+ body = {"resource": "property_definition", "resource_id": str(prop.id), "access_level": None}
+ # The rule vanishes between the request and the delete, as a concurrent clear would make it
+ with patch(
+ "products.access_control.backend.facade.api.delete_property_access_control",
+ side_effect=PropertyAccessControlRuleNotFoundError,
+ ):
+ res = self._put("default", body)
+ assert res.status_code == status.HTTP_204_NO_CONTENT
+
+ def test_property_rule_validation(self):
+ prop = self._property_definition()
+ base = {"resource": "property_definition", "resource_id": str(prop.id)}
+
+ res = self._put("default", {"resource": "property_definition", "access_level": "read"})
+ assert res.status_code == status.HTTP_400_BAD_REQUEST, res.json()
+ res = self._put("default", {**base, "access_level": "viewer"})
+ assert res.status_code == status.HTTP_400_BAD_REQUEST, res.json()
+ res = self._put("default", {**base, "resource_id": str(uuid.uuid4()), "access_level": "read"})
+ assert res.status_code == status.HTTP_404_NOT_FOUND, res.json()
+ # A property name instead of the id, for a set and for a clear
+ res = self._put("default", {**base, "resource_id": "salary", "access_level": "read"})
+ assert res.status_code == status.HTTP_404_NOT_FOUND, res.json()
+ res = self._put("default", {**base, "resource_id": "salary", "access_level": None})
+ assert res.status_code == status.HTTP_404_NOT_FOUND, res.json()
+
+ # Property access without role-based access: role rules stay gated like every other scope
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},
+ {"key": AvailableFeature.PROPERTY_ACCESS_CONTROL, "name": AvailableFeature.PROPERTY_ACCESS_CONTROL},
+ ]
+ self.organization.save()
+ res = self._put("role", {**base, "access_level": "read", **self._subject("role")})
+ assert res.status_code == status.HTTP_403_FORBIDDEN, res.json()
+
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL}
+ ]
+ self.organization.save()
+ res = self._put("default", {**base, "access_level": "read"})
+ assert res.status_code == status.HTTP_403_FORBIDDEN, res.json()
+ assert not PropertyAccessControl.objects.filter(team=self.team).exists()
diff --git a/products/access_control/backend/tests/test_mcp_access.py b/products/access_control/backend/tests/test_mcp_access.py
index 3e9aa50c4205..088594c177a4 100644
--- a/products/access_control/backend/tests/test_mcp_access.py
+++ b/products/access_control/backend/tests/test_mcp_access.py
@@ -97,6 +97,18 @@ class TestMCPReadOnlyEnforcement(APIBaseTest):
assert self._request("get").status_code == 200
+ def test_read_only_org_denies_access_rule_writes(self) -> None:
+ self._set_read_only(True)
+
+ denied = self.client.put(
+ f"/api/projects/{self.team.id}/access_control_default_rules",
+ {"resource": "dashboard", "access_level": "viewer"},
+ HTTP_AUTHORIZATION=f"Bearer {self.key_value}",
+ headers={"User-Agent": f"cursor/1.0 {MCP_USER_AGENT_MARKER}; version: 1.0.0"},
+ )
+ assert denied.status_code == 403
+ assert "read-only" in denied.json()["detail"]
+
@parameterized.expand([("flag_off", False, True), ("not_mcp_user_agent", True, False)])
def test_writes_pass_without_flag_or_marker(self, _name: str, read_only: bool, mcp: bool) -> None:
self._set_read_only(read_only)
diff --git a/products/access_control/backend/tests/test_property_access_control_viewset.py b/products/access_control/backend/tests/test_property_access_control_viewset.py
index 5cbc0b6a33e4..c2f56c7c0316 100644
--- a/products/access_control/backend/tests/test_property_access_control_viewset.py
+++ b/products/access_control/backend/tests/test_property_access_control_viewset.py
@@ -47,6 +47,10 @@ class TestPropertyAccessControlViewSet(APIBaseTest):
response = self.client.get(self.url)
assert response.status_code == status.HTTP_400_BAD_REQUEST
+ def test_list_with_property_name_instead_of_id_returns_404(self):
+ response = self.client.get(f"{self.url}?property_definition_id={self.prop_def.name}")
+ assert response.status_code == status.HTTP_404_NOT_FOUND
+
def test_create_default_rule(self):
response = self._post({"access_level": PropertyAccessLevel.NONE.value})
assert response.status_code == status.HTTP_200_OK
@@ -69,9 +73,17 @@ class TestPropertyAccessControlViewSet(APIBaseTest):
# PrimaryKeyRelatedField serializes the FK as the PK value
assert str(response.json()["organization_member"]) == str(self.organization_membership.id)
+ def _grant_role_based_access(self) -> None:
+ self.organization.available_product_features = [
+ {"name": AvailableFeature.PROPERTY_ACCESS_CONTROL, "key": AvailableFeature.PROPERTY_ACCESS_CONTROL},
+ {"name": AvailableFeature.ROLE_BASED_ACCESS, "key": AvailableFeature.ROLE_BASED_ACCESS},
+ ]
+ self.organization.save()
+
def test_create_role_override(self):
from products.access_control.backend.models.role import Role
+ self._grant_role_based_access()
role = Role.objects.create(name="Analyst", organization=self.organization)
response = self._post(
{
@@ -160,6 +172,7 @@ class TestPropertyAccessControlViewSet(APIBaseTest):
def test_list_with_multiple_rules(self):
from products.access_control.backend.models.role import Role
+ self._grant_role_based_access()
role = Role.objects.create(name="Analyst", organization=self.organization)
# default rule
@@ -187,6 +200,7 @@ class TestPropertyAccessControlViewSet(APIBaseTest):
from products.access_control.backend.models.role import Role
+ self._grant_role_based_access()
other_org = Organization.objects.create(name="Other org")
other_role = Role.objects.create(name="Other org role", organization=other_org)
@@ -222,6 +236,7 @@ class TestPropertyAccessControlViewSet(APIBaseTest):
from products.access_control.backend.models.role import Role
+ self._grant_role_based_access()
other_org = Organization.objects.create(name="Other org")
other_role = Role.objects.create(name="Other org role", organization=other_org)
@@ -274,6 +289,16 @@ class TestPropertyAccessControlViewSet(APIBaseTest):
response = self._post({"access_level": PropertyAccessLevel.NONE.value})
assert response.status_code == status.HTTP_403_FORBIDDEN
assert PropertyAccessControl.objects.filter(property_definition=self.prop_def).count() == 0
+ # The gate runs before the body is validated, so an invalid body is still a 403 and not a 400
+ assert self._post({}).status_code == status.HTTP_403_FORBIDDEN
+
+ def test_role_rule_forbidden_without_role_based_access_feature(self):
+ from products.access_control.backend.models.role import Role
+
+ role = Role.objects.create(name="Analyst", organization=self.organization)
+ response = self._post({"access_level": PropertyAccessLevel.READ.value, "role": str(role.id)})
+ assert response.status_code == status.HTTP_403_FORBIDDEN
+ assert PropertyAccessControl.objects.filter(property_definition=self.prop_def).count() == 0
def test_delete_forbidden_without_property_access_control_feature(self):
# Create a rule while the feature is available
diff --git a/products/access_control/frontend/generated/api.schemas.ts b/products/access_control/frontend/generated/api.schemas.ts
index 51b297176270..175cf8d1826c 100644
--- a/products/access_control/frontend/generated/api.schemas.ts
+++ b/products/access_control/frontend/generated/api.schemas.ts
@@ -152,6 +152,217 @@ export interface AccessControlPropertyRulesResponseApi {
results: AccessControlPropertyRuleApi[]
}
+/**
+ * * `account` - account
+ * * `action` - action
+ * * `activity_log` - activity_log
+ * * `ai_observability_clusters` - ai_observability_clusters
+ * * `customer_analytics` - customer_analytics
+ * * `customer_journey` - customer_journey
+ * * `customer_task` - customer_task
+ * * `dashboard` - dashboard
+ * * `dashboard_template` - dashboard_template
+ * * `data_catalog` - data_catalog
+ * * `data_deletion` - data_deletion
+ * * `dataset` - dataset
+ * * `early_access_feature` - early_access_feature
+ * * `endpoint` - endpoint
+ * * `error_tracking` - error_tracking
+ * * `evaluation` - evaluation
+ * * `experiment` - experiment
+ * * `experiment_holdout` - experiment_holdout
+ * * `experiment_saved_metric` - experiment_saved_metric
+ * * `export` - export
+ * * `external_data_source` - external_data_source
+ * * `feature_flag` - feature_flag
+ * * `heatmap` - heatmap
+ * * `hog_flow` - hog_flow
+ * * `insight` - insight
+ * * `llm_analytics` - llm_analytics
+ * * `llm_playground` - llm_playground
+ * * `llm_prompt` - llm_prompt
+ * * `llm_provider_key` - llm_provider_key
+ * * `llm_skill` - llm_skill
+ * * `logs` - logs
+ * * `marketing_analytics` - marketing_analytics
+ * * `mcp_analytics` - mcp_analytics
+ * * `metrics` - metrics
+ * * `notebook` - notebook
+ * * `project` - project
+ * * `property_definition` - property_definition
+ * * `replay_scanner` - replay_scanner
+ * * `revenue_analytics` - revenue_analytics
+ * * `session_recording` - session_recording
+ * * `session_recording_playlist` - session_recording_playlist
+ * * `sharing_configuration` - sharing_configuration
+ * * `stamphog` - stamphog
+ * * `survey` - survey
+ * * `tagger` - tagger
+ * * `ticket` - ticket
+ * * `toolbar` - toolbar
+ * * `tracing` - tracing
+ * * `vision_alert` - vision_alert
+ * * `warehouse_objects` - warehouse_objects
+ * * `warehouse_table` - warehouse_table
+ * * `warehouse_view` - warehouse_view
+ * * `web_analytics` - web_analytics
+ */
+export type RuleResourceEnumApi = (typeof RuleResourceEnumApi)[keyof typeof RuleResourceEnumApi]
+
+export const RuleResourceEnumApi = {
+ Account: 'account',
+ Action: 'action',
+ ActivityLog: 'activity_log',
+ AiObservabilityClusters: 'ai_observability_clusters',
+ CustomerAnalytics: 'customer_analytics',
+ CustomerJourney: 'customer_journey',
+ CustomerTask: 'customer_task',
+ Dashboard: 'dashboard',
+ DashboardTemplate: 'dashboard_template',
+ DataCatalog: 'data_catalog',
+ DataDeletion: 'data_deletion',
+ Dataset: 'dataset',
+ EarlyAccessFeature: 'early_access_feature',
+ Endpoint: 'endpoint',
+ ErrorTracking: 'error_tracking',
+ Evaluation: 'evaluation',
+ Experiment: 'experiment',
+ ExperimentHoldout: 'experiment_holdout',
+ ExperimentSavedMetric: 'experiment_saved_metric',
+ Export: 'export',
+ ExternalDataSource: 'external_data_source',
+ FeatureFlag: 'feature_flag',
+ Heatmap: 'heatmap',
+ HogFlow: 'hog_flow',
+ Insight: 'insight',
+ LlmAnalytics: 'llm_analytics',
+ LlmPlayground: 'llm_playground',
+ LlmPrompt: 'llm_prompt',
+ LlmProviderKey: 'llm_provider_key',
+ LlmSkill: 'llm_skill',
+ Logs: 'logs',
+ MarketingAnalytics: 'marketing_analytics',
+ McpAnalytics: 'mcp_analytics',
+ Metrics: 'metrics',
+ Notebook: 'notebook',
+ Project: 'project',
+ PropertyDefinition: 'property_definition',
+ ReplayScanner: 'replay_scanner',
+ RevenueAnalytics: 'revenue_analytics',
+ SessionRecording: 'session_recording',
+ SessionRecordingPlaylist: 'session_recording_playlist',
+ SharingConfiguration: 'sharing_configuration',
+ Stamphog: 'stamphog',
+ Survey: 'survey',
+ Tagger: 'tagger',
+ Ticket: 'ticket',
+ Toolbar: 'toolbar',
+ Tracing: 'tracing',
+ VisionAlert: 'vision_alert',
+ WarehouseObjects: 'warehouse_objects',
+ WarehouseTable: 'warehouse_table',
+ WarehouseView: 'warehouse_view',
+ WebAnalytics: 'web_analytics',
+} as const
+
+/**
+ * The scope and level of one rule write. On its own it is the default rule, for everyone in the
+ * project without a member or role rule of their own. The subclasses add the subject.
+ */
+export interface AccessControlRuleRequestApi {
+ /** The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.
+ *
+ * * `account` - account
+ * * `action` - action
+ * * `activity_log` - activity_log
+ * * `ai_observability_clusters` - ai_observability_clusters
+ * * `customer_analytics` - customer_analytics
+ * * `customer_journey` - customer_journey
+ * * `customer_task` - customer_task
+ * * `dashboard` - dashboard
+ * * `dashboard_template` - dashboard_template
+ * * `data_catalog` - data_catalog
+ * * `data_deletion` - data_deletion
+ * * `dataset` - dataset
+ * * `early_access_feature` - early_access_feature
+ * * `endpoint` - endpoint
+ * * `error_tracking` - error_tracking
+ * * `evaluation` - evaluation
+ * * `experiment` - experiment
+ * * `experiment_holdout` - experiment_holdout
+ * * `experiment_saved_metric` - experiment_saved_metric
+ * * `export` - export
+ * * `external_data_source` - external_data_source
+ * * `feature_flag` - feature_flag
+ * * `heatmap` - heatmap
+ * * `hog_flow` - hog_flow
+ * * `insight` - insight
+ * * `llm_analytics` - llm_analytics
+ * * `llm_playground` - llm_playground
+ * * `llm_prompt` - llm_prompt
+ * * `llm_provider_key` - llm_provider_key
+ * * `llm_skill` - llm_skill
+ * * `logs` - logs
+ * * `marketing_analytics` - marketing_analytics
+ * * `mcp_analytics` - mcp_analytics
+ * * `metrics` - metrics
+ * * `notebook` - notebook
+ * * `project` - project
+ * * `property_definition` - property_definition
+ * * `replay_scanner` - replay_scanner
+ * * `revenue_analytics` - revenue_analytics
+ * * `session_recording` - session_recording
+ * * `session_recording_playlist` - session_recording_playlist
+ * * `sharing_configuration` - sharing_configuration
+ * * `stamphog` - stamphog
+ * * `survey` - survey
+ * * `tagger` - tagger
+ * * `ticket` - ticket
+ * * `toolbar` - toolbar
+ * * `tracing` - tracing
+ * * `vision_alert` - vision_alert
+ * * `warehouse_objects` - warehouse_objects
+ * * `warehouse_table` - warehouse_table
+ * * `warehouse_view` - warehouse_view
+ * * `web_analytics` - web_analytics */
+ resource: RuleResourceEnumApi
+ /**
+ * The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type.
+ * @nullable
+ */
+ resource_id?: string | null
+ /**
+ * The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.
+ * @nullable
+ */
+ access_level: string | null
+}
+
+/**
+ * One stored rule, the same shape for object, resource, project and property rules.
+ */
+export interface AccessControlStoredRuleApi {
+ /** The rule's scope, as sent in the request. */
+ resource: string
+ /**
+ * The object the rule applies to: the project id for a project rule, an object's primary key, or a property definition id. Null for a resource-type rule.
+ * @nullable
+ */
+ resource_id: string | null
+ /** The stored level. */
+ access_level: string
+ /**
+ * The organization membership the rule is for. Null unless it is a member rule.
+ * @nullable
+ */
+ member_id: string | null
+ /**
+ * The role the rule is for. Null unless it is a role rule.
+ * @nullable
+ */
+ role_id: string | null
+}
+
export interface AccessControlResourceDefaultApi {
/**
* The stored default level for this resource type. Null when the PostHog default applies.
@@ -196,6 +407,80 @@ export interface AccessControlDefaultsResponseApi {
object_rule_resources: AccessControlObjectRuleResourceApi[]
}
+/**
+ * A rule for one organization member.
+ */
+export interface AccessControlMemberRuleRequestApi {
+ /** The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.
+ *
+ * * `account` - account
+ * * `action` - action
+ * * `activity_log` - activity_log
+ * * `ai_observability_clusters` - ai_observability_clusters
+ * * `customer_analytics` - customer_analytics
+ * * `customer_journey` - customer_journey
+ * * `customer_task` - customer_task
+ * * `dashboard` - dashboard
+ * * `dashboard_template` - dashboard_template
+ * * `data_catalog` - data_catalog
+ * * `data_deletion` - data_deletion
+ * * `dataset` - dataset
+ * * `early_access_feature` - early_access_feature
+ * * `endpoint` - endpoint
+ * * `error_tracking` - error_tracking
+ * * `evaluation` - evaluation
+ * * `experiment` - experiment
+ * * `experiment_holdout` - experiment_holdout
+ * * `experiment_saved_metric` - experiment_saved_metric
+ * * `export` - export
+ * * `external_data_source` - external_data_source
+ * * `feature_flag` - feature_flag
+ * * `heatmap` - heatmap
+ * * `hog_flow` - hog_flow
+ * * `insight` - insight
+ * * `llm_analytics` - llm_analytics
+ * * `llm_playground` - llm_playground
+ * * `llm_prompt` - llm_prompt
+ * * `llm_provider_key` - llm_provider_key
+ * * `llm_skill` - llm_skill
+ * * `logs` - logs
+ * * `marketing_analytics` - marketing_analytics
+ * * `mcp_analytics` - mcp_analytics
+ * * `metrics` - metrics
+ * * `notebook` - notebook
+ * * `project` - project
+ * * `property_definition` - property_definition
+ * * `replay_scanner` - replay_scanner
+ * * `revenue_analytics` - revenue_analytics
+ * * `session_recording` - session_recording
+ * * `session_recording_playlist` - session_recording_playlist
+ * * `sharing_configuration` - sharing_configuration
+ * * `stamphog` - stamphog
+ * * `survey` - survey
+ * * `tagger` - tagger
+ * * `ticket` - ticket
+ * * `toolbar` - toolbar
+ * * `tracing` - tracing
+ * * `vision_alert` - vision_alert
+ * * `warehouse_objects` - warehouse_objects
+ * * `warehouse_table` - warehouse_table
+ * * `warehouse_view` - warehouse_view
+ * * `web_analytics` - web_analytics */
+ resource: RuleResourceEnumApi
+ /**
+ * The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type.
+ * @nullable
+ */
+ resource_id?: string | null
+ /**
+ * The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.
+ * @nullable
+ */
+ access_level: string | null
+ /** The organization membership id, as `organization_membership_id` in the members endpoint. */
+ member_id: string
+}
+
export interface AccessControlMemberUserApi {
/** The user's UUID. */
uuid: string
@@ -314,6 +599,80 @@ export interface AccessControlMembersResponseApi {
results: AccessControlMemberAccessApi[]
}
+/**
+ * A rule for every member of one role.
+ */
+export interface AccessControlRoleRuleRequestApi {
+ /** The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.
+ *
+ * * `account` - account
+ * * `action` - action
+ * * `activity_log` - activity_log
+ * * `ai_observability_clusters` - ai_observability_clusters
+ * * `customer_analytics` - customer_analytics
+ * * `customer_journey` - customer_journey
+ * * `customer_task` - customer_task
+ * * `dashboard` - dashboard
+ * * `dashboard_template` - dashboard_template
+ * * `data_catalog` - data_catalog
+ * * `data_deletion` - data_deletion
+ * * `dataset` - dataset
+ * * `early_access_feature` - early_access_feature
+ * * `endpoint` - endpoint
+ * * `error_tracking` - error_tracking
+ * * `evaluation` - evaluation
+ * * `experiment` - experiment
+ * * `experiment_holdout` - experiment_holdout
+ * * `experiment_saved_metric` - experiment_saved_metric
+ * * `export` - export
+ * * `external_data_source` - external_data_source
+ * * `feature_flag` - feature_flag
+ * * `heatmap` - heatmap
+ * * `hog_flow` - hog_flow
+ * * `insight` - insight
+ * * `llm_analytics` - llm_analytics
+ * * `llm_playground` - llm_playground
+ * * `llm_prompt` - llm_prompt
+ * * `llm_provider_key` - llm_provider_key
+ * * `llm_skill` - llm_skill
+ * * `logs` - logs
+ * * `marketing_analytics` - marketing_analytics
+ * * `mcp_analytics` - mcp_analytics
+ * * `metrics` - metrics
+ * * `notebook` - notebook
+ * * `project` - project
+ * * `property_definition` - property_definition
+ * * `replay_scanner` - replay_scanner
+ * * `revenue_analytics` - revenue_analytics
+ * * `session_recording` - session_recording
+ * * `session_recording_playlist` - session_recording_playlist
+ * * `sharing_configuration` - sharing_configuration
+ * * `stamphog` - stamphog
+ * * `survey` - survey
+ * * `tagger` - tagger
+ * * `ticket` - ticket
+ * * `toolbar` - toolbar
+ * * `tracing` - tracing
+ * * `vision_alert` - vision_alert
+ * * `warehouse_objects` - warehouse_objects
+ * * `warehouse_table` - warehouse_table
+ * * `warehouse_view` - warehouse_view
+ * * `web_analytics` - web_analytics */
+ resource: RuleResourceEnumApi
+ /**
+ * The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type.
+ * @nullable
+ */
+ resource_id?: string | null
+ /**
+ * The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.
+ * @nullable
+ */
+ access_level: string | null
+ /** The role id, as `role_id` in the roles endpoint. */
+ role_id: string
+}
+
/**
* Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`).
*/
diff --git a/products/access_control/frontend/generated/api.ts b/products/access_control/frontend/generated/api.ts
index 013ccc9e9b85..dc4cf37e913b 100644
--- a/products/access_control/frontend/generated/api.ts
+++ b/products/access_control/frontend/generated/api.ts
@@ -10,10 +10,14 @@ import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
*/
import type {
AccessControlDefaultsResponseApi,
+ AccessControlMemberRuleRequestApi,
AccessControlMembersResponseApi,
AccessControlObjectRulesResponseApi,
AccessControlPropertyRulesResponseApi,
+ AccessControlRoleRuleRequestApi,
AccessControlRolesResponseApi,
+ AccessControlRuleRequestApi,
+ AccessControlStoredRuleApi,
MemberProjectAccessResponseApi,
MembersProjectAccessRetrieveParams,
OrganizationsProjectsAccessControlMemberObjectsRetrieveParams,
@@ -107,6 +111,30 @@ export const organizationsProjectsAccessControlDefaultPropertiesRetrieve = async
)
}
+export const getOrganizationsProjectsAccessControlDefaultRulesUpdateUrl = (organizationId: string, id: number) => {
+ return `/api/organizations/${organizationId}/projects/${id}/access_control_default_rules/`
+}
+
+/**
+ * Set or clear the rule everyone in the project gets for a scope, unless a member or role rule of their own applies. The scope is the project (`resource: project` with the project id as `resource_id`), a whole resource type, one object, or one property definition. A null `access_level` removes the rule. Returns the stored rule, or 204 with no body when the rule is cleared.
+ */
+export const organizationsProjectsAccessControlDefaultRulesUpdate = async (
+ organizationId: string,
+ id: number,
+ accessControlRuleRequestApi: AccessControlRuleRequestApi,
+ options?: RequestInit
+): Promise<AccessControlStoredRuleApi | void> => {
+ return apiMutator<AccessControlStoredRuleApi | void>(
+ getOrganizationsProjectsAccessControlDefaultRulesUpdateUrl(organizationId, id),
+ {
+ ...options,
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(accessControlRuleRequestApi),
+ }
+ )
+}
+
export const getOrganizationsProjectsAccessControlDefaultsRetrieveUrl = (organizationId: string, id: number) => {
return `/api/organizations/${organizationId}/projects/${id}/access_control_defaults/`
}
@@ -204,6 +232,30 @@ export const organizationsProjectsAccessControlMemberPropertiesRetrieve = async
)
}
+export const getOrganizationsProjectsAccessControlMemberRulesUpdateUrl = (organizationId: string, id: number) => {
+ return `/api/organizations/${organizationId}/projects/${id}/access_control_member_rules/`
+}
+
+/**
+ * Set or clear one member's rule for a scope. A member rule applies to that person only and takes precedence over their role rules and the default. The scope is the project (`resource: project` with the project id as `resource_id`), a whole resource type, one object, or one property definition. A null `access_level` removes the rule. Returns the stored rule, or 204 with no body when the rule is cleared.
+ */
+export const organizationsProjectsAccessControlMemberRulesUpdate = async (
+ organizationId: string,
+ id: number,
+ accessControlMemberRuleRequestApi: AccessControlMemberRuleRequestApi,
+ options?: RequestInit
+): Promise<AccessControlStoredRuleApi | void> => {
+ return apiMutator<AccessControlStoredRuleApi | void>(
+ getOrganizationsProjectsAccessControlMemberRulesUpdateUrl(organizationId, id),
+ {
+ ...options,
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(accessControlMemberRuleRequestApi),
+ }
+ )
+}
+
export const getOrganizationsProjectsAccessControlMembersRetrieveUrl = (
organizationId: string,
id: number,
@@ -318,6 +370,30 @@ export const organizationsProjectsAccessControlRolePropertiesRetrieve = async (
)
}
+export const getOrganizationsProjectsAccessControlRoleRulesUpdateUrl = (organizationId: string, id: number) => {
+ return `/api/organizations/${organizationId}/projects/${id}/access_control_role_rules/`
+}
+
+/**
+ * Set or clear one role's rule for a scope. A role rule applies to every member of the role and takes precedence over the default. Requires the role-based access feature. The scope is the project (`resource: project` with the project id as `resource_id`), a whole resource type, one object, or one property definition. A null `access_level` removes the rule. Returns the stored rule, or 204 with no body when the rule is cleared.
+ */
+export const organizationsProjectsAccessControlRoleRulesUpdate = async (
+ organizationId: string,
+ id: number,
+ accessControlRoleRuleRequestApi: AccessControlRoleRuleRequestApi,
+ options?: RequestInit
+): Promise<AccessControlStoredRuleApi | void> => {
+ return apiMutator<AccessControlStoredRuleApi | void>(
+ getOrganizationsProjectsAccessControlRoleRulesUpdateUrl(organizationId, id),
+ {
+ ...options,
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(accessControlRoleRuleRequestApi),
+ }
+ )
+}
+
export const getOrganizationsProjectsAccessControlRolesRetrieveUrl = (
organizationId: string,
id: number,
diff --git a/products/access_control/frontend/generated/api.zod.ts b/products/access_control/frontend/generated/api.zod.ts
index 32787713b102..bebf009fa380 100644
--- a/products/access_control/frontend/generated/api.zod.ts
+++ b/products/access_control/frontend/generated/api.zod.ts
@@ -9,6 +9,258 @@
*/
import * as zod from 'zod'
+/**
+ * Set or clear the rule everyone in the project gets for a scope, unless a member or role rule of their own applies. The scope is the project (`resource: project` with the project id as `resource_id`), a whole resource type, one object, or one property definition. A null `access_level` removes the rule. Returns the stored rule, or 204 with no body when the rule is cleared.
+ */
+export const OrganizationsProjectsAccessControlDefaultRulesUpdateBody = /* @__PURE__ */ zod
+ .object({
+ resource: zod
+ .enum([
+ 'account',
+ 'action',
+ 'activity_log',
+ 'ai_observability_clusters',
+ 'customer_analytics',
+ 'customer_journey',
+ 'customer_task',
+ 'dashboard',
+ 'dashboard_template',
+ 'data_catalog',
+ 'data_deletion',
+ 'dataset',
+ 'early_access_feature',
+ 'endpoint',
+ 'error_tracking',
+ 'evaluation',
+ 'experiment',
+ 'experiment_holdout',
+ 'experiment_saved_metric',
+ 'export',
+ 'external_data_source',
+ 'feature_flag',
+ 'heatmap',
+ 'hog_flow',
+ 'insight',
+ 'llm_analytics',
+ 'llm_playground',
+ 'llm_prompt',
+ 'llm_provider_key',
+ 'llm_skill',
+ 'logs',
+ 'marketing_analytics',
+ 'mcp_analytics',
+ 'metrics',
+ 'notebook',
+ 'project',
+ 'property_definition',
+ 'replay_scanner',
+ 'revenue_analytics',
+ 'session_recording',
+ 'session_recording_playlist',
+ 'sharing_configuration',
+ 'stamphog',
+ 'survey',
+ 'tagger',
+ 'ticket',
+ 'toolbar',
+ 'tracing',
+ 'vision_alert',
+ 'warehouse_objects',
+ 'warehouse_table',
+ 'warehouse_view',
+ 'web_analytics',
+ ])
+ .describe(
+ '\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ )
+ .describe(
+ 'The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.\n\n\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ ),
+ resource_id: zod
+ .string()
+ .nullish()
+ .describe(
+ "The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type."
+ ),
+ access_level: zod
+ .string()
+ .nullable()
+ .describe(
+ 'The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.'
+ ),
+ })
+ .describe(
+ 'The scope and level of one rule write. On its own it is the default rule, for everyone in the\nproject without a member or role rule of their own. The subclasses add the subject.'
+ )
+
+/**
+ * Set or clear one member's rule for a scope. A member rule applies to that person only and takes precedence over their role rules and the default. The scope is the project (`resource: project` with the project id as `resource_id`), a whole resource type, one object, or one property definition. A null `access_level` removes the rule. Returns the stored rule, or 204 with no body when the rule is cleared.
+ */
+export const OrganizationsProjectsAccessControlMemberRulesUpdateBody = /* @__PURE__ */ zod
+ .object({
+ resource: zod
+ .enum([
+ 'account',
+ 'action',
+ 'activity_log',
+ 'ai_observability_clusters',
+ 'customer_analytics',
+ 'customer_journey',
+ 'customer_task',
+ 'dashboard',
+ 'dashboard_template',
+ 'data_catalog',
+ 'data_deletion',
+ 'dataset',
+ 'early_access_feature',
+ 'endpoint',
+ 'error_tracking',
+ 'evaluation',
+ 'experiment',
+ 'experiment_holdout',
+ 'experiment_saved_metric',
+ 'export',
+ 'external_data_source',
+ 'feature_flag',
+ 'heatmap',
+ 'hog_flow',
+ 'insight',
+ 'llm_analytics',
+ 'llm_playground',
+ 'llm_prompt',
+ 'llm_provider_key',
+ 'llm_skill',
+ 'logs',
+ 'marketing_analytics',
+ 'mcp_analytics',
+ 'metrics',
+ 'notebook',
+ 'project',
+ 'property_definition',
+ 'replay_scanner',
+ 'revenue_analytics',
+ 'session_recording',
+ 'session_recording_playlist',
+ 'sharing_configuration',
+ 'stamphog',
+ 'survey',
+ 'tagger',
+ 'ticket',
+ 'toolbar',
+ 'tracing',
+ 'vision_alert',
+ 'warehouse_objects',
+ 'warehouse_table',
+ 'warehouse_view',
+ 'web_analytics',
+ ])
+ .describe(
+ '\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ )
+ .describe(
+ 'The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.\n\n\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ ),
+ resource_id: zod
+ .string()
+ .nullish()
+ .describe(
+ "The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type."
+ ),
+ access_level: zod
+ .string()
+ .nullable()
+ .describe(
+ 'The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.'
+ ),
+ member_id: zod
+ .uuid()
+ .describe('The organization membership id, as `organization_membership_id` in the members endpoint.'),
+ })
+ .describe('A rule for one organization member.')
+
+/**
+ * Set or clear one role's rule for a scope. A role rule applies to every member of the role and takes precedence over the default. Requires the role-based access feature. The scope is the project (`resource: project` with the project id as `resource_id`), a whole resource type, one object, or one property definition. A null `access_level` removes the rule. Returns the stored rule, or 204 with no body when the rule is cleared.
+ */
+export const OrganizationsProjectsAccessControlRoleRulesUpdateBody = /* @__PURE__ */ zod
+ .object({
+ resource: zod
+ .enum([
+ 'account',
+ 'action',
+ 'activity_log',
+ 'ai_observability_clusters',
+ 'customer_analytics',
+ 'customer_journey',
+ 'customer_task',
+ 'dashboard',
+ 'dashboard_template',
+ 'data_catalog',
+ 'data_deletion',
+ 'dataset',
+ 'early_access_feature',
+ 'endpoint',
+ 'error_tracking',
+ 'evaluation',
+ 'experiment',
+ 'experiment_holdout',
+ 'experiment_saved_metric',
+ 'export',
+ 'external_data_source',
+ 'feature_flag',
+ 'heatmap',
+ 'hog_flow',
+ 'insight',
+ 'llm_analytics',
+ 'llm_playground',
+ 'llm_prompt',
+ 'llm_provider_key',
+ 'llm_skill',
+ 'logs',
+ 'marketing_analytics',
+ 'mcp_analytics',
+ 'metrics',
+ 'notebook',
+ 'project',
+ 'property_definition',
+ 'replay_scanner',
+ 'revenue_analytics',
+ 'session_recording',
+ 'session_recording_playlist',
+ 'sharing_configuration',
+ 'stamphog',
+ 'survey',
+ 'tagger',
+ 'ticket',
+ 'toolbar',
+ 'tracing',
+ 'vision_alert',
+ 'warehouse_objects',
+ 'warehouse_table',
+ 'warehouse_view',
+ 'web_analytics',
+ ])
+ .describe(
+ '\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ )
+ .describe(
+ 'The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.\n\n\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ ),
+ resource_id: zod
+ .string()
+ .nullish()
+ .describe(
+ "The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type."
+ ),
+ access_level: zod
+ .string()
+ .nullable()
+ .describe(
+ 'The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.'
+ ),
+ role_id: zod.uuid().describe('The role id, as `role_id` in the roles endpoint.'),
+ })
+ .describe('A rule for every member of one role.')
+
/**
* Create or update a property access control rule.
*/
diff --git a/products/access_control/mcp/tools.yaml b/products/access_control/mcp/tools.yaml
index d9000d770379..953bb14ea0b3 100644
--- a/products/access_control/mcp/tools.yaml
+++ b/products/access_control/mcp/tools.yaml
@@ -52,6 +52,55 @@ tools:
optional: true
fallback: projectId
feature_entitlement: access_control
+ access-control-default-rule-set:
+ operation: organizations_projects_access_control_default_rules_update
+ enabled: true
+ scopes:
+ - access_control:write
+ annotations:
+ readOnly: false
+ destructive: true
+ idempotent: true
+ title: Set or clear the default access rule for a scope
+ description: >
+ Sets the level everyone in the project gets for one scope when they have no member rule or role rule of
+ their own there. Use it to change the project baseline (`resource: project` with the project id as
+ `resource_id`, level `member` or `admin`), the default for a whole tool (`resource: dashboard`, level
+ `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one person or event property
+ (`resource: property_definition` with the property definition id as `resource_id`, level `none`, `read` or
+ `read_write`). A null `access_level` removes the rule, so the scope falls back to its inherited level. An
+ empty result means the rule is cleared. Read access-control-defaults-get first and tell the user the current
+ and the new level before you ask for confirmation. Requires human typed confirmation.
+ agent_note: >
+ A member rule or a role rule on the same scope still wins over this default. Verify the result with
+ access-control-defaults-get or access-control-members-list.
+ param_overrides:
+ id:
+ description: |
+ Project id. If omitted, uses the active project.
+ optional: true
+ fallback: projectId
+ resource:
+ description: >
+ The scope: `project`, a tool name such as `dashboard` or `feature_flag`, or `property_definition`.
+ The tool names are the keys of `resource_access_levels` on access-control-defaults-get.
+ resource_id:
+ description: >
+ The project id for a project rule, the object's id for a rule on one object (a pk, as returned by
+ the object's own get tool), or the property definition id for a property rule. Null only for a rule
+ on a whole tool.
+ default: null
+ access_level:
+ description: >
+ The level to set, within the scope's `minimum` and `maximum` on access-control-defaults-get, or null
+ to remove the rule.
+ feature_entitlement: access_control
+ confirmed_action:
+ message: >
+ About to set the default {resource} access rule in project {id} to {access_level}, for object
+ {resource_id} (null means the whole tool; a null level clears the rule). This changes what every member
+ without a rule of their own gets. Reply 'confirm' to proceed.
+ action_label: change the default access rule
access-control-defaults-get:
operation: organizations_projects_access_control_defaults_retrieve
enabled: true
@@ -140,6 +189,59 @@ tools:
description: |
The organization membership id, as `organization_membership_id` in access-control-members-list.
feature_entitlement: access_control
+ access-control-member-rule-set:
+ operation: organizations_projects_access_control_member_rules_update
+ enabled: true
+ scopes:
+ - access_control:write
+ annotations:
+ readOnly: false
+ destructive: true
+ idempotent: true
+ title: Set or clear one member's access rule for a scope
+ description: >
+ Sets the level one organization member gets for one scope. A member rule applies to that person only and
+ wins over their role rules and the default. The scope is the project (`resource: project` with the project
+ id as `resource_id`, level `member` or `admin`), a whole tool (`resource: dashboard`, level `none`,
+ `viewer`, `editor` or `manager`), one object (add `resource_id`), or one property (`resource:
+ property_definition`, level `none`, `read` or `read_write`). A null `access_level` removes the member's
+ rule, so they fall back to their role rules or the default. An empty result means the rule is cleared. When
+ several people need the same change, prefer a role rule. Read access-control-members-list with `member_id`
+ first and tell the user the current and the new level before you ask for confirmation. Requires human typed
+ confirmation.
+ agent_note: >
+ Organization admins and owners have full access regardless of rules. Verify the result with
+ access-control-members-list and `member_id`.
+ param_overrides:
+ id:
+ description: |
+ Project id. If omitted, uses the active project.
+ optional: true
+ fallback: projectId
+ member_id:
+ description: |
+ The organization membership id, as `organization_membership_id` in access-control-members-list.
+ resource:
+ description: >
+ The scope: `project`, a tool name such as `dashboard` or `feature_flag`, or `property_definition`.
+ The tool names are the keys of `resources` in access-control-members-list.
+ resource_id:
+ description: >
+ The project id for a project rule, the object's id for a rule on one object (a pk, as returned by
+ the object's own get tool), or the property definition id for a property rule. Null only for a rule
+ on a whole tool.
+ default: null
+ access_level:
+ description: >
+ The level to set, within the scope's `minimum` and `maximum` on access-control-defaults-get, or null
+ to remove the rule.
+ feature_entitlement: access_control
+ confirmed_action:
+ message: >
+ About to set the {resource} access rule for member {member_id} in project {id} to {access_level}, for
+ object {resource_id} (null means the whole tool; a null level clears the rule). Reply 'confirm' to
+ proceed.
+ action_label: change a member's access rule
access-control-members-list:
operation: organizations_projects_access_control_members_retrieve
enabled: true
@@ -230,6 +332,57 @@ tools:
The role id, as `role_id` in access-control-roles-list or an entry of `role_ids` in
access-control-members-list.
feature_entitlement: role_based_access
+ access-control-role-rule-set:
+ operation: organizations_projects_access_control_role_rules_update
+ enabled: true
+ scopes:
+ - access_control:write
+ annotations:
+ readOnly: false
+ destructive: true
+ idempotent: true
+ title: Set or clear one role's access rule for a scope
+ description: >
+ Sets the level every member of one role gets for one scope. A role rule wins over the default, and a
+ member's own rule wins over it. The scope is the project (`resource: project` with the project id as
+ `resource_id`, level `member` or `admin`), a whole tool (`resource: dashboard`, level `none`, `viewer`,
+ `editor` or `manager`), one object (add `resource_id`), or one property (`resource: property_definition`,
+ level `none`, `read` or `read_write`). A null `access_level` removes the role's rule. An empty result means
+ the rule is cleared. Role rules are enforced only on plans with role-based access. Read
+ access-control-roles-list with `role_id` first and tell the user the current and the new level before you
+ ask for confirmation. Requires human typed confirmation.
+ agent_note: |
+ Who is in the role is on role-members-list. Verify the result with access-control-roles-list and `role_id`.
+ param_overrides:
+ id:
+ description: |
+ Project id. If omitted, uses the active project.
+ optional: true
+ fallback: projectId
+ role_id:
+ description: |
+ The role id, as `role_id` in access-control-roles-list or `id` in roles-list.
+ resource:
+ description: >
+ The scope: `project`, a tool name such as `dashboard` or `feature_flag`, or `property_definition`.
+ The tool names are the keys of `resources` in access-control-roles-list.
+ resource_id:
+ description: >
+ The project id for a project rule, the object's id for a rule on one object (a pk, as returned by
+ the object's own get tool), or the property definition id for a property rule. Null only for a rule
+ on a whole tool.
+ default: null
+ access_level:
+ description: >
+ The level to set, within the scope's `minimum` and `maximum` on access-control-defaults-get, or null
+ to remove the rule.
+ feature_entitlement: role_based_access
+ confirmed_action:
+ message: >
+ About to set the {resource} access rule for role {role_id} in project {id} to {access_level}, for object
+ {resource_id} (null means the whole tool; a null level clears the rule). This affects every member of
+ the role. Reply 'confirm' to proceed.
+ action_label: change a role's access rule
access-control-roles-list:
operation: organizations_projects_access_control_roles_retrieve
enabled: true
diff --git a/products/ai_observability/frontend/generated/api.schemas.ts b/products/ai_observability/frontend/generated/api.schemas.ts
index b89a6d2bd522..e167625cc191 100644
--- a/products/ai_observability/frontend/generated/api.schemas.ts
+++ b/products/ai_observability/frontend/generated/api.schemas.ts
@@ -481,9 +481,10 @@ export const CodeEnumApi = {
* * `dataset_items` - dataset_items
* * `dataset_item_versions` - dataset_item_versions
*/
-export type ResourceEnumApi = (typeof ResourceEnumApi)[keyof typeof ResourceEnumApi]
+export type DatasetConflictResponseResourceEnumApi =
+ (typeof DatasetConflictResponseResourceEnumApi)[keyof typeof DatasetConflictResponseResourceEnumApi]
-export const ResourceEnumApi = {
+export const DatasetConflictResponseResourceEnumApi = {
Datasets: 'datasets',
DatasetItems: 'dataset_items',
DatasetItemVersions: 'dataset_item_versions',
@@ -517,7 +518,7 @@ export interface DatasetConflictResponseApi {
* * `datasets` - datasets
* * `dataset_items` - dataset_items
* * `dataset_item_versions` - dataset_item_versions */
- resource?: ResourceEnumApi
+ resource?: DatasetConflictResponseResourceEnumApi
/** Number of resources that already exist. */
current_count?: number
/** Maximum number of resources allowed. */
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index ac920e30cd65..4ec90cb59a1c 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -29,6 +29,36 @@
},
"feature_entitlement": "access_control"
},
+ "access-control-default-rule-set-execute": {
+ "description": "Step 2 of 2 for change the default access rule. Verifies the confirmation_hash from -prepare and the literal \"confirm\" string typed by the user, then performs the action. ONLY call this after the user has explicitly typed \"confirm\" in chat. Original action: Sets the level everyone in the project gets for one scope when they have no member rule or role rule of their own there. Use it to change the project baseline (`resource: project` with the project id as `resource_id`, level `member` or `admin`), the default for a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one person or event property (`resource: property_definition` with the property definition id as `resource_id`, level `none`, `read` or `read_write`). A null `access_level` removes the rule, so the scope falls back to its inherited level. An empty result means the rule is cleared. Read access-control-defaults-get first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear the default access rule for a scope (execute)",
+ "title": "Set or clear the default access rule for a scope (execute)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_entitlement": "access_control"
+ },
+ "access-control-default-rule-set-prepare": {
+ "description": "Step 1 of 2 for change the default access rule. Validates the arguments and returns a signed confirmation_hash plus a message to surface to the user. The user must reply with the literal word \"confirm\" before you call the matching -execute tool with the hash. Original action: Sets the level everyone in the project gets for one scope when they have no member rule or role rule of their own there. Use it to change the project baseline (`resource: project` with the project id as `resource_id`, level `member` or `admin`), the default for a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one person or event property (`resource: property_definition` with the property definition id as `resource_id`, level `none`, `read` or `read_write`). A null `access_level` removes the rule, so the scope falls back to its inherited level. An empty result means the rule is cleared. Read access-control-defaults-get first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear the default access rule for a scope (prepare)",
+ "title": "Set or clear the default access rule for a scope (prepare)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_entitlement": "access_control"
+ },
"access-control-defaults-get": {
"description": "The access everyone in the project gets unless a rule of their own, or a role's rule, says otherwise: the default project level (member or admin) and the default level per tool (none, viewer, editor, manager), with the lowest and highest level each tool allows. Also lists which tools accept rules on single objects, such as one dashboard or one notebook. Start here to understand a project's baseline before checking a member or a role.",
"category": "Access control",
@@ -74,6 +104,36 @@
},
"feature_entitlement": "access_control"
},
+ "access-control-member-rule-set-execute": {
+ "description": "Step 2 of 2 for change a member's access rule. Verifies the confirmation_hash from -prepare and the literal \"confirm\" string typed by the user, then performs the action. ONLY call this after the user has explicitly typed \"confirm\" in chat. Original action: Sets the level one organization member gets for one scope. A member rule applies to that person only and wins over their role rules and the default. The scope is the project (`resource: project` with the project id as `resource_id`, level `member` or `admin`), a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one property (`resource: property_definition`, level `none`, `read` or `read_write`). A null `access_level` removes the member's rule, so they fall back to their role rules or the default. An empty result means the rule is cleared. When several people need the same change, prefer a role rule. Read access-control-members-list with `member_id` first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear one member's access rule for a scope (execute)",
+ "title": "Set or clear one member's access rule for a scope (execute)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_entitlement": "access_control"
+ },
+ "access-control-member-rule-set-prepare": {
+ "description": "Step 1 of 2 for change a member's access rule. Validates the arguments and returns a signed confirmation_hash plus a message to surface to the user. The user must reply with the literal word \"confirm\" before you call the matching -execute tool with the hash. Original action: Sets the level one organization member gets for one scope. A member rule applies to that person only and wins over their role rules and the default. The scope is the project (`resource: project` with the project id as `resource_id`, level `member` or `admin`), a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one property (`resource: property_definition`, level `none`, `read` or `read_write`). A null `access_level` removes the member's rule, so they fall back to their role rules or the default. An empty result means the rule is cleared. When several people need the same change, prefer a role rule. Read access-control-members-list with `member_id` first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear one member's access rule for a scope (prepare)",
+ "title": "Set or clear one member's access rule for a scope (prepare)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_entitlement": "access_control"
+ },
"access-control-members-list": {
"description": "For every organization member, the access enforced in the project: to the project itself and to each tool (dashboards, insights, feature flags, and so on). Per entry, `access_level` is the member's own stored rule (null when none), `effective_access_level` is what is enforced, and `inherited_access` says where that level comes from when it is not the member's own rule: `source_subject` is `role` or `default`, and `source` is `org_admin` when the member is an organization admin with full access to everything. Pass `member_id` (an `organization_membership_id`, from this tool or org-members-list) for one member. The checking-member-access skill explains how the levels combine.",
"category": "Access control",
@@ -119,6 +179,36 @@
},
"feature_entitlement": "role_based_access"
},
+ "access-control-role-rule-set-execute": {
+ "description": "Step 2 of 2 for change a role's access rule. Verifies the confirmation_hash from -prepare and the literal \"confirm\" string typed by the user, then performs the action. ONLY call this after the user has explicitly typed \"confirm\" in chat. Original action: Sets the level every member of one role gets for one scope. A role rule wins over the default, and a member's own rule wins over it. The scope is the project (`resource: project` with the project id as `resource_id`, level `member` or `admin`), a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one property (`resource: property_definition`, level `none`, `read` or `read_write`). A null `access_level` removes the role's rule. An empty result means the rule is cleared. Role rules are enforced only on plans with role-based access. Read access-control-roles-list with `role_id` first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear one role's access rule for a scope (execute)",
+ "title": "Set or clear one role's access rule for a scope (execute)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_entitlement": "role_based_access"
+ },
+ "access-control-role-rule-set-prepare": {
+ "description": "Step 1 of 2 for change a role's access rule. Validates the arguments and returns a signed confirmation_hash plus a message to surface to the user. The user must reply with the literal word \"confirm\" before you call the matching -execute tool with the hash. Original action: Sets the level every member of one role gets for one scope. A role rule wins over the default, and a member's own rule wins over it. The scope is the project (`resource: project` with the project id as `resource_id`, level `member` or `admin`), a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one property (`resource: property_definition`, level `none`, `read` or `read_write`). A null `access_level` removes the role's rule. An empty result means the rule is cleared. Role rules are enforced only on plans with role-based access. Read access-control-roles-list with `role_id` first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear one role's access rule for a scope (prepare)",
+ "title": "Set or clear one role's access rule for a scope (prepare)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_entitlement": "role_based_access"
+ },
"access-control-roles-list": {
"description": "For every role in the organization, the access it grants in the project: to the project itself and to each tool. Per entry, `access_level` is the role's own stored rule, `effective_access_level` is what the role's members get from it, and `inherited_access` says where that level comes from when the role has no rule of its own. Pass `role_id` for one role.",
"category": "Access control",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index a51fa85bc190..cc3fcedb1d6e 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -29,6 +29,36 @@
},
"feature_entitlement": "access_control"
},
+ "access-control-default-rule-set-execute": {
+ "description": "Step 2 of 2 for change the default access rule. Verifies the confirmation_hash from -prepare and the literal \"confirm\" string typed by the user, then performs the action. ONLY call this after the user has explicitly typed \"confirm\" in chat. Original action: Sets the level everyone in the project gets for one scope when they have no member rule or role rule of their own there. Use it to change the project baseline (`resource: project` with the project id as `resource_id`, level `member` or `admin`), the default for a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one person or event property (`resource: property_definition` with the property definition id as `resource_id`, level `none`, `read` or `read_write`). A null `access_level` removes the rule, so the scope falls back to its inherited level. An empty result means the rule is cleared. Read access-control-defaults-get first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear the default access rule for a scope (execute)",
+ "title": "Set or clear the default access rule for a scope (execute)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_entitlement": "access_control"
+ },
+ "access-control-default-rule-set-prepare": {
+ "description": "Step 1 of 2 for change the default access rule. Validates the arguments and returns a signed confirmation_hash plus a message to surface to the user. The user must reply with the literal word \"confirm\" before you call the matching -execute tool with the hash. Original action: Sets the level everyone in the project gets for one scope when they have no member rule or role rule of their own there. Use it to change the project baseline (`resource: project` with the project id as `resource_id`, level `member` or `admin`), the default for a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one person or event property (`resource: property_definition` with the property definition id as `resource_id`, level `none`, `read` or `read_write`). A null `access_level` removes the rule, so the scope falls back to its inherited level. An empty result means the rule is cleared. Read access-control-defaults-get first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear the default access rule for a scope (prepare)",
+ "title": "Set or clear the default access rule for a scope (prepare)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_entitlement": "access_control"
+ },
"access-control-defaults-get": {
"description": "The access everyone in the project gets unless a rule of their own, or a role's rule, says otherwise: the default project level (member or admin) and the default level per tool (none, viewer, editor, manager), with the lowest and highest level each tool allows. Also lists which tools accept rules on single objects, such as one dashboard or one notebook. Start here to understand a project's baseline before checking a member or a role.",
"category": "Access control",
@@ -74,6 +104,36 @@
},
"feature_entitlement": "access_control"
},
+ "access-control-member-rule-set-execute": {
+ "description": "Step 2 of 2 for change a member's access rule. Verifies the confirmation_hash from -prepare and the literal \"confirm\" string typed by the user, then performs the action. ONLY call this after the user has explicitly typed \"confirm\" in chat. Original action: Sets the level one organization member gets for one scope. A member rule applies to that person only and wins over their role rules and the default. The scope is the project (`resource: project` with the project id as `resource_id`, level `member` or `admin`), a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one property (`resource: property_definition`, level `none`, `read` or `read_write`). A null `access_level` removes the member's rule, so they fall back to their role rules or the default. An empty result means the rule is cleared. When several people need the same change, prefer a role rule. Read access-control-members-list with `member_id` first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear one member's access rule for a scope (execute)",
+ "title": "Set or clear one member's access rule for a scope (execute)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_entitlement": "access_control"
+ },
+ "access-control-member-rule-set-prepare": {
+ "description": "Step 1 of 2 for change a member's access rule. Validates the arguments and returns a signed confirmation_hash plus a message to surface to the user. The user must reply with the literal word \"confirm\" before you call the matching -execute tool with the hash. Original action: Sets the level one organization member gets for one scope. A member rule applies to that person only and wins over their role rules and the default. The scope is the project (`resource: project` with the project id as `resource_id`, level `member` or `admin`), a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one property (`resource: property_definition`, level `none`, `read` or `read_write`). A null `access_level` removes the member's rule, so they fall back to their role rules or the default. An empty result means the rule is cleared. When several people need the same change, prefer a role rule. Read access-control-members-list with `member_id` first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear one member's access rule for a scope (prepare)",
+ "title": "Set or clear one member's access rule for a scope (prepare)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_entitlement": "access_control"
+ },
"access-control-members-list": {
"description": "For every organization member, the access enforced in the project: to the project itself and to each tool (dashboards, insights, feature flags, and so on). Per entry, `access_level` is the member's own stored rule (null when none), `effective_access_level` is what is enforced, and `inherited_access` says where that level comes from when it is not the member's own rule: `source_subject` is `role` or `default`, and `source` is `org_admin` when the member is an organization admin with full access to everything. Pass `member_id` (an `organization_membership_id`, from this tool or org-members-list) for one member. The checking-member-access skill explains how the levels combine.",
"category": "Access control",
@@ -119,6 +179,36 @@
},
"feature_entitlement": "role_based_access"
},
+ "access-control-role-rule-set-execute": {
+ "description": "Step 2 of 2 for change a role's access rule. Verifies the confirmation_hash from -prepare and the literal \"confirm\" string typed by the user, then performs the action. ONLY call this after the user has explicitly typed \"confirm\" in chat. Original action: Sets the level every member of one role gets for one scope. A role rule wins over the default, and a member's own rule wins over it. The scope is the project (`resource: project` with the project id as `resource_id`, level `member` or `admin`), a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one property (`resource: property_definition`, level `none`, `read` or `read_write`). A null `access_level` removes the role's rule. An empty result means the rule is cleared. Role rules are enforced only on plans with role-based access. Read access-control-roles-list with `role_id` first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear one role's access rule for a scope (execute)",
+ "title": "Set or clear one role's access rule for a scope (execute)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_entitlement": "role_based_access"
+ },
+ "access-control-role-rule-set-prepare": {
+ "description": "Step 1 of 2 for change a role's access rule. Validates the arguments and returns a signed confirmation_hash plus a message to surface to the user. The user must reply with the literal word \"confirm\" before you call the matching -execute tool with the hash. Original action: Sets the level every member of one role gets for one scope. A role rule wins over the default, and a member's own rule wins over it. The scope is the project (`resource: project` with the project id as `resource_id`, level `member` or `admin`), a whole tool (`resource: dashboard`, level `none`, `viewer`, `editor` or `manager`), one object (add `resource_id`), or one property (`resource: property_definition`, level `none`, `read` or `read_write`). A null `access_level` removes the role's rule. An empty result means the rule is cleared. Role rules are enforced only on plans with role-based access. Read access-control-roles-list with `role_id` first and tell the user the current and the new level before you ask for confirmation. Requires human typed confirmation.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "Set or clear one role's access rule for a scope (prepare)",
+ "title": "Set or clear one role's access rule for a scope (prepare)",
+ "required_scopes": ["access_control:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_entitlement": "role_based_access"
+ },
"access-control-roles-list": {
"description": "For every role in the organization, the access it grants in the project: to the project itself and to each tool. Per entry, `access_level` is the role's own stored rule, `effective_access_level` is what the role's members get from it, and `inherited_access` says where that level comes from when the role has no rule of its own. Pass `role_id` for one role.",
"category": "Access control",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 34efddc8adfa..29ca39a4d8ee 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -377,6 +377,194 @@ export namespace Schemas {
resources: AccessControlMemberAccessResources;
}
+ /**
+ * * `account` - account
+ * * `action` - action
+ * * `activity_log` - activity_log
+ * * `ai_observability_clusters` - ai_observability_clusters
+ * * `customer_analytics` - customer_analytics
+ * * `customer_journey` - customer_journey
+ * * `customer_task` - customer_task
+ * * `dashboard` - dashboard
+ * * `dashboard_template` - dashboard_template
+ * * `data_catalog` - data_catalog
+ * * `data_deletion` - data_deletion
+ * * `dataset` - dataset
+ * * `early_access_feature` - early_access_feature
+ * * `endpoint` - endpoint
+ * * `error_tracking` - error_tracking
+ * * `evaluation` - evaluation
+ * * `experiment` - experiment
+ * * `experiment_holdout` - experiment_holdout
+ * * `experiment_saved_metric` - experiment_saved_metric
+ * * `export` - export
+ * * `external_data_source` - external_data_source
+ * * `feature_flag` - feature_flag
+ * * `heatmap` - heatmap
+ * * `hog_flow` - hog_flow
+ * * `insight` - insight
+ * * `llm_analytics` - llm_analytics
+ * * `llm_playground` - llm_playground
+ * * `llm_prompt` - llm_prompt
+ * * `llm_provider_key` - llm_provider_key
+ * * `llm_skill` - llm_skill
+ * * `logs` - logs
+ * * `marketing_analytics` - marketing_analytics
+ * * `mcp_analytics` - mcp_analytics
+ * * `metrics` - metrics
+ * * `notebook` - notebook
+ * * `project` - project
+ * * `property_definition` - property_definition
+ * * `replay_scanner` - replay_scanner
+ * * `revenue_analytics` - revenue_analytics
+ * * `session_recording` - session_recording
+ * * `session_recording_playlist` - session_recording_playlist
+ * * `sharing_configuration` - sharing_configuration
+ * * `stamphog` - stamphog
+ * * `survey` - survey
+ * * `tagger` - tagger
+ * * `ticket` - ticket
+ * * `toolbar` - toolbar
+ * * `tracing` - tracing
+ * * `vision_alert` - vision_alert
+ * * `warehouse_objects` - warehouse_objects
+ * * `warehouse_table` - warehouse_table
+ * * `warehouse_view` - warehouse_view
+ * * `web_analytics` - web_analytics
+ */
+ export type RuleResourceEnum = typeof RuleResourceEnum[keyof typeof RuleResourceEnum];
+
+
+ export const RuleResourceEnum = {
+ Account: 'account',
+ Action: 'action',
+ ActivityLog: 'activity_log',
+ AiObservabilityClusters: 'ai_observability_clusters',
+ CustomerAnalytics: 'customer_analytics',
+ CustomerJourney: 'customer_journey',
+ CustomerTask: 'customer_task',
+ Dashboard: 'dashboard',
+ DashboardTemplate: 'dashboard_template',
+ DataCatalog: 'data_catalog',
+ DataDeletion: 'data_deletion',
+ Dataset: 'dataset',
+ EarlyAccessFeature: 'early_access_feature',
+ Endpoint: 'endpoint',
+ ErrorTracking: 'error_tracking',
+ Evaluation: 'evaluation',
+ Experiment: 'experiment',
+ ExperimentHoldout: 'experiment_holdout',
+ ExperimentSavedMetric: 'experiment_saved_metric',
+ Export: 'export',
+ ExternalDataSource: 'external_data_source',
+ FeatureFlag: 'feature_flag',
+ Heatmap: 'heatmap',
+ HogFlow: 'hog_flow',
+ Insight: 'insight',
+ LlmAnalytics: 'llm_analytics',
+ LlmPlayground: 'llm_playground',
+ LlmPrompt: 'llm_prompt',
+ LlmProviderKey: 'llm_provider_key',
+ LlmSkill: 'llm_skill',
+ Logs: 'logs',
+ MarketingAnalytics: 'marketing_analytics',
+ McpAnalytics: 'mcp_analytics',
+ Metrics: 'metrics',
+ Notebook: 'notebook',
+ Project: 'project',
+ PropertyDefinition: 'property_definition',
+ ReplayScanner: 'replay_scanner',
+ RevenueAnalytics: 'revenue_analytics',
+ SessionRecording: 'session_recording',
+ SessionRecordingPlaylist: 'session_recording_playlist',
+ SharingConfiguration: 'sharing_configuration',
+ Stamphog: 'stamphog',
+ Survey: 'survey',
+ Tagger: 'tagger',
+ Ticket: 'ticket',
+ Toolbar: 'toolbar',
+ Tracing: 'tracing',
+ VisionAlert: 'vision_alert',
+ WarehouseObjects: 'warehouse_objects',
+ WarehouseTable: 'warehouse_table',
+ WarehouseView: 'warehouse_view',
+ WebAnalytics: 'web_analytics',
+ } as const;
+
+ /**
+ * A rule for one organization member.
+ */
+ export interface AccessControlMemberRuleRequest {
+ /** The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.
+ *
+ * * `account` - account
+ * * `action` - action
+ * * `activity_log` - activity_log
+ * * `ai_observability_clusters` - ai_observability_clusters
+ * * `customer_analytics` - customer_analytics
+ * * `customer_journey` - customer_journey
+ * * `customer_task` - customer_task
+ * * `dashboard` - dashboard
+ * * `dashboard_template` - dashboard_template
+ * * `data_catalog` - data_catalog
+ * * `data_deletion` - data_deletion
+ * * `dataset` - dataset
+ * * `early_access_feature` - early_access_feature
+ * * `endpoint` - endpoint
+ * * `error_tracking` - error_tracking
+ * * `evaluation` - evaluation
+ * * `experiment` - experiment
+ * * `experiment_holdout` - experiment_holdout
+ * * `experiment_saved_metric` - experiment_saved_metric
+ * * `export` - export
+ * * `external_data_source` - external_data_source
+ * * `feature_flag` - feature_flag
+ * * `heatmap` - heatmap
+ * * `hog_flow` - hog_flow
+ * * `insight` - insight
+ * * `llm_analytics` - llm_analytics
+ * * `llm_playground` - llm_playground
+ * * `llm_prompt` - llm_prompt
+ * * `llm_provider_key` - llm_provider_key
+ * * `llm_skill` - llm_skill
+ * * `logs` - logs
+ * * `marketing_analytics` - marketing_analytics
+ * * `mcp_analytics` - mcp_analytics
+ * * `metrics` - metrics
+ * * `notebook` - notebook
+ * * `project` - project
+ * * `property_definition` - property_definition
+ * * `replay_scanner` - replay_scanner
+ * * `revenue_analytics` - revenue_analytics
+ * * `session_recording` - session_recording
+ * * `session_recording_playlist` - session_recording_playlist
+ * * `sharing_configuration` - sharing_configuration
+ * * `stamphog` - stamphog
+ * * `survey` - survey
+ * * `tagger` - tagger
+ * * `ticket` - ticket
+ * * `toolbar` - toolbar
+ * * `tracing` - tracing
+ * * `vision_alert` - vision_alert
+ * * `warehouse_objects` - warehouse_objects
+ * * `warehouse_table` - warehouse_table
+ * * `warehouse_view` - warehouse_view
+ * * `web_analytics` - web_analytics */
+ resource: RuleResourceEnum;
+ /**
+ * The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type.
+ * @nullable
+ */
+ resource_id?: string | null;
+ /**
+ * The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.
+ * @nullable
+ */
+ access_level: string | null;
+ /** The organization membership id, as `organization_membership_id` in the members endpoint. */
+ member_id: string;
+ }
+
export interface AccessControlMembersResponse {
/** The project access levels, lowest first. */
available_project_levels: string[];
@@ -450,6 +638,80 @@ export namespace Schemas {
resources: AccessControlRoleAccessResources;
}
+ /**
+ * A rule for every member of one role.
+ */
+ export interface AccessControlRoleRuleRequest {
+ /** The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.
+ *
+ * * `account` - account
+ * * `action` - action
+ * * `activity_log` - activity_log
+ * * `ai_observability_clusters` - ai_observability_clusters
+ * * `customer_analytics` - customer_analytics
+ * * `customer_journey` - customer_journey
+ * * `customer_task` - customer_task
+ * * `dashboard` - dashboard
+ * * `dashboard_template` - dashboard_template
+ * * `data_catalog` - data_catalog
+ * * `data_deletion` - data_deletion
+ * * `dataset` - dataset
+ * * `early_access_feature` - early_access_feature
+ * * `endpoint` - endpoint
+ * * `error_tracking` - error_tracking
+ * * `evaluation` - evaluation
+ * * `experiment` - experiment
+ * * `experiment_holdout` - experiment_holdout
+ * * `experiment_saved_metric` - experiment_saved_metric
+ * * `export` - export
+ * * `external_data_source` - external_data_source
+ * * `feature_flag` - feature_flag
+ * * `heatmap` - heatmap
+ * * `hog_flow` - hog_flow
+ * * `insight` - insight
+ * * `llm_analytics` - llm_analytics
+ * * `llm_playground` - llm_playground
+ * * `llm_prompt` - llm_prompt
+ * * `llm_provider_key` - llm_provider_key
+ * * `llm_skill` - llm_skill
+ * * `logs` - logs
+ * * `marketing_analytics` - marketing_analytics
+ * * `mcp_analytics` - mcp_analytics
+ * * `metrics` - metrics
+ * * `notebook` - notebook
+ * * `project` - project
+ * * `property_definition` - property_definition
+ * * `replay_scanner` - replay_scanner
+ * * `revenue_analytics` - revenue_analytics
+ * * `session_recording` - session_recording
+ * * `session_recording_playlist` - session_recording_playlist
+ * * `sharing_configuration` - sharing_configuration
+ * * `stamphog` - stamphog
+ * * `survey` - survey
+ * * `tagger` - tagger
+ * * `ticket` - ticket
+ * * `toolbar` - toolbar
+ * * `tracing` - tracing
+ * * `vision_alert` - vision_alert
+ * * `warehouse_objects` - warehouse_objects
+ * * `warehouse_table` - warehouse_table
+ * * `warehouse_view` - warehouse_view
+ * * `web_analytics` - web_analytics */
+ resource: RuleResourceEnum;
+ /**
+ * The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type.
+ * @nullable
+ */
+ resource_id?: string | null;
+ /**
+ * The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.
+ * @nullable
+ */
+ access_level: string | null;
+ /** The role id, as `role_id` in the roles endpoint. */
+ role_id: string;
+ }
+
export interface AccessControlRolesResponse {
/** The project access levels, lowest first. */
available_project_levels: string[];
@@ -461,6 +723,104 @@ export namespace Schemas {
results: AccessControlRoleAccess[];
}
+ /**
+ * The scope and level of one rule write. On its own it is the default rule, for everyone in the
+ * project without a member or role rule of their own. The subclasses add the subject.
+ */
+ export interface AccessControlRuleRequest {
+ /** The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.
+ *
+ * * `account` - account
+ * * `action` - action
+ * * `activity_log` - activity_log
+ * * `ai_observability_clusters` - ai_observability_clusters
+ * * `customer_analytics` - customer_analytics
+ * * `customer_journey` - customer_journey
+ * * `customer_task` - customer_task
+ * * `dashboard` - dashboard
+ * * `dashboard_template` - dashboard_template
+ * * `data_catalog` - data_catalog
+ * * `data_deletion` - data_deletion
+ * * `dataset` - dataset
+ * * `early_access_feature` - early_access_feature
+ * * `endpoint` - endpoint
+ * * `error_tracking` - error_tracking
+ * * `evaluation` - evaluation
+ * * `experiment` - experiment
+ * * `experiment_holdout` - experiment_holdout
+ * * `experiment_saved_metric` - experiment_saved_metric
+ * * `export` - export
+ * * `external_data_source` - external_data_source
+ * * `feature_flag` - feature_flag
+ * * `heatmap` - heatmap
+ * * `hog_flow` - hog_flow
+ * * `insight` - insight
+ * * `llm_analytics` - llm_analytics
+ * * `llm_playground` - llm_playground
+ * * `llm_prompt` - llm_prompt
+ * * `llm_provider_key` - llm_provider_key
+ * * `llm_skill` - llm_skill
+ * * `logs` - logs
+ * * `marketing_analytics` - marketing_analytics
+ * * `mcp_analytics` - mcp_analytics
+ * * `metrics` - metrics
+ * * `notebook` - notebook
+ * * `project` - project
+ * * `property_definition` - property_definition
+ * * `replay_scanner` - replay_scanner
+ * * `revenue_analytics` - revenue_analytics
+ * * `session_recording` - session_recording
+ * * `session_recording_playlist` - session_recording_playlist
+ * * `sharing_configuration` - sharing_configuration
+ * * `stamphog` - stamphog
+ * * `survey` - survey
+ * * `tagger` - tagger
+ * * `ticket` - ticket
+ * * `toolbar` - toolbar
+ * * `tracing` - tracing
+ * * `vision_alert` - vision_alert
+ * * `warehouse_objects` - warehouse_objects
+ * * `warehouse_table` - warehouse_table
+ * * `warehouse_view` - warehouse_view
+ * * `web_analytics` - web_analytics */
+ resource: RuleResourceEnum;
+ /**
+ * The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type.
+ * @nullable
+ */
+ resource_id?: string | null;
+ /**
+ * The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.
+ * @nullable
+ */
+ access_level: string | null;
+ }
+
+ /**
+ * One stored rule, the same shape for object, resource, project and property rules.
+ */
+ export interface AccessControlStoredRule {
+ /** The rule's scope, as sent in the request. */
+ resource: string;
+ /**
+ * The object the rule applies to: the project id for a project rule, an object's primary key, or a property definition id. Null for a resource-type rule.
+ * @nullable
+ */
+ resource_id: string | null;
+ /** The stored level. */
+ access_level: string;
+ /**
+ * The organization membership the rule is for. Null unless it is a member rule.
+ * @nullable
+ */
+ member_id: string | null;
+ /**
+ * The role the rule is for. Null unless it is a role rule.
+ * @nullable
+ */
+ role_id: string | null;
+ }
+
/**
* * `read_write` - read_write
* * `read` - read
@@ -31152,10 +31512,10 @@ export namespace Schemas {
* * `dataset_items` - dataset_items
* * `dataset_item_versions` - dataset_item_versions
*/
- export type ResourceEnum = typeof ResourceEnum[keyof typeof ResourceEnum];
+ export type DatasetConflictResponseResourceEnum = typeof DatasetConflictResponseResourceEnum[keyof typeof DatasetConflictResponseResourceEnum];
- export const ResourceEnum = {
+ export const DatasetConflictResponseResourceEnum = {
Datasets: 'datasets',
DatasetItems: 'dataset_items',
DatasetItemVersions: 'dataset_item_versions',
@@ -31189,7 +31549,7 @@ export namespace Schemas {
* * `datasets` - datasets
* * `dataset_items` - dataset_items
* * `dataset_item_versions` - dataset_item_versions */
- resource?: ResourceEnum;
+ resource?: DatasetConflictResponseResourceEnum;
/** Number of resources that already exist. */
current_count?: number;
/** Maximum number of resources allowed. */
diff --git a/services/mcp/src/generated/access_control/api.ts b/services/mcp/src/generated/access_control/api.ts
index eebd9dc3aef4..59f5c97f28c9 100644
--- a/services/mcp/src/generated/access_control/api.ts
+++ b/services/mcp/src/generated/access_control/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 12 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -46,6 +46,106 @@ export const OrganizationsProjectsAccessControlDefaultPropertiesRetrieveParams =
),
})
+/**
+ * Set or clear the rule everyone in the project gets for a scope, unless a member or role rule of their own applies. The scope is the project (`resource: project` with the project id as `resource_id`), a whole resource type, one object, or one property definition. A null `access_level` removes the rule. Returns the stored rule, or 204 with no body when the rule is cleared.
+ */
+export const organizationsProjectsAccessControlDefaultRulesUpdatePathIdMin = -2147483648
+export const organizationsProjectsAccessControlDefaultRulesUpdatePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlDefaultRulesUpdateParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlDefaultRulesUpdatePathIdMin)
+ .max(organizationsProjectsAccessControlDefaultRulesUpdatePathIdMax)
+ .describe('A unique value identifying this project.'),
+ organization_id: zod
+ .string()
+ .describe(
+ "ID of the organization you're trying to access. To find the ID of the organization, make a call to \/api\/organizations\/."
+ ),
+})
+
+export const OrganizationsProjectsAccessControlDefaultRulesUpdateBody = () => zod
+ .object({
+ resource: zod
+ .enum([
+ 'account',
+ 'action',
+ 'activity_log',
+ 'ai_observability_clusters',
+ 'customer_analytics',
+ 'customer_journey',
+ 'customer_task',
+ 'dashboard',
+ 'dashboard_template',
+ 'data_catalog',
+ 'data_deletion',
+ 'dataset',
+ 'early_access_feature',
+ 'endpoint',
+ 'error_tracking',
+ 'evaluation',
+ 'experiment',
+ 'experiment_holdout',
+ 'experiment_saved_metric',
+ 'export',
+ 'external_data_source',
+ 'feature_flag',
+ 'heatmap',
+ 'hog_flow',
+ 'insight',
+ 'llm_analytics',
+ 'llm_playground',
+ 'llm_prompt',
+ 'llm_provider_key',
+ 'llm_skill',
+ 'logs',
+ 'marketing_analytics',
+ 'mcp_analytics',
+ 'metrics',
+ 'notebook',
+ 'project',
+ 'property_definition',
+ 'replay_scanner',
+ 'revenue_analytics',
+ 'session_recording',
+ 'session_recording_playlist',
+ 'sharing_configuration',
+ 'stamphog',
+ 'survey',
+ 'tagger',
+ 'ticket',
+ 'toolbar',
+ 'tracing',
+ 'vision_alert',
+ 'warehouse_objects',
+ 'warehouse_table',
+ 'warehouse_view',
+ 'web_analytics',
+ ])
+ .describe(
+ '\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ )
+ .describe(
+ 'The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.\n\n\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ ),
+ resource_id: zod
+ .string()
+ .nullish()
+ .describe(
+ "The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type."
+ ),
+ access_level: zod
+ .string()
+ .nullable()
+ .describe(
+ 'The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.'
+ ),
+ })
+ .describe(
+ 'The scope and level of one rule write. On its own it is the default rule, for everyone in the\nproject without a member or role rule of their own. The subclasses add the subject.'
+ )
+
/**
* The project's default access. Returns the level that applies to the project and to each resource type when a member or a role has no rule of their own. Also lists the resource types that accept rules on single objects, with the levels such a rule can set.
*/
@@ -115,6 +215,107 @@ export const OrganizationsProjectsAccessControlMemberPropertiesRetrieveQueryPara
.describe('The organization membership id, as `organization_membership_id` in the members endpoint.'),
})
+/**
+ * Set or clear one member's rule for a scope. A member rule applies to that person only and takes precedence over their role rules and the default. The scope is the project (`resource: project` with the project id as `resource_id`), a whole resource type, one object, or one property definition. A null `access_level` removes the rule. Returns the stored rule, or 204 with no body when the rule is cleared.
+ */
+export const organizationsProjectsAccessControlMemberRulesUpdatePathIdMin = -2147483648
+export const organizationsProjectsAccessControlMemberRulesUpdatePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlMemberRulesUpdateParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlMemberRulesUpdatePathIdMin)
+ .max(organizationsProjectsAccessControlMemberRulesUpdatePathIdMax)
+ .describe('A unique value identifying this project.'),
+ organization_id: zod
+ .string()
+ .describe(
+ "ID of the organization you're trying to access. To find the ID of the organization, make a call to \/api\/organizations\/."
+ ),
+})
+
+export const OrganizationsProjectsAccessControlMemberRulesUpdateBody = () => zod
+ .object({
+ resource: zod
+ .enum([
+ 'account',
+ 'action',
+ 'activity_log',
+ 'ai_observability_clusters',
+ 'customer_analytics',
+ 'customer_journey',
+ 'customer_task',
+ 'dashboard',
+ 'dashboard_template',
+ 'data_catalog',
+ 'data_deletion',
+ 'dataset',
+ 'early_access_feature',
+ 'endpoint',
+ 'error_tracking',
+ 'evaluation',
+ 'experiment',
+ 'experiment_holdout',
+ 'experiment_saved_metric',
+ 'export',
+ 'external_data_source',
+ 'feature_flag',
+ 'heatmap',
+ 'hog_flow',
+ 'insight',
+ 'llm_analytics',
+ 'llm_playground',
+ 'llm_prompt',
+ 'llm_provider_key',
+ 'llm_skill',
+ 'logs',
+ 'marketing_analytics',
+ 'mcp_analytics',
+ 'metrics',
+ 'notebook',
+ 'project',
+ 'property_definition',
+ 'replay_scanner',
+ 'revenue_analytics',
+ 'session_recording',
+ 'session_recording_playlist',
+ 'sharing_configuration',
+ 'stamphog',
+ 'survey',
+ 'tagger',
+ 'ticket',
+ 'toolbar',
+ 'tracing',
+ 'vision_alert',
+ 'warehouse_objects',
+ 'warehouse_table',
+ 'warehouse_view',
+ 'web_analytics',
+ ])
+ .describe(
+ '\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ )
+ .describe(
+ 'The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.\n\n\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ ),
+ resource_id: zod
+ .string()
+ .nullish()
+ .describe(
+ "The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type."
+ ),
+ access_level: zod
+ .string()
+ .nullable()
+ .describe(
+ 'The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.'
+ ),
+ member_id: zod
+ .string()
+ .describe('The organization membership id, as `organization_membership_id` in the members endpoint.'),
+ })
+ .describe('A rule for one organization member.')
+
/**
* Every organization member's access in this project. For the project and for each resource type, the response gives the member's own rule and the level that is enforced. It also says where the enforced level comes from: the member's rule, a role's rule, the project default, or full access as an organization admin. Pass `member_id` for one member.
*/
@@ -184,6 +385,105 @@ export const OrganizationsProjectsAccessControlRolePropertiesRetrieveQueryParams
role_id: zod.string().describe('The role id, as `role_id` in the roles endpoint.'),
})
+/**
+ * Set or clear one role's rule for a scope. A role rule applies to every member of the role and takes precedence over the default. Requires the role-based access feature. The scope is the project (`resource: project` with the project id as `resource_id`), a whole resource type, one object, or one property definition. A null `access_level` removes the rule. Returns the stored rule, or 204 with no body when the rule is cleared.
+ */
+export const organizationsProjectsAccessControlRoleRulesUpdatePathIdMin = -2147483648
+export const organizationsProjectsAccessControlRoleRulesUpdatePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlRoleRulesUpdateParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlRoleRulesUpdatePathIdMin)
+ .max(organizationsProjectsAccessControlRoleRulesUpdatePathIdMax)
+ .describe('A unique value identifying this project.'),
+ organization_id: zod
+ .string()
+ .describe(
+ "ID of the organization you're trying to access. To find the ID of the organization, make a call to \/api\/organizations\/."
+ ),
+})
+
+export const OrganizationsProjectsAccessControlRoleRulesUpdateBody = () => zod
+ .object({
+ resource: zod
+ .enum([
+ 'account',
+ 'action',
+ 'activity_log',
+ 'ai_observability_clusters',
+ 'customer_analytics',
+ 'customer_journey',
+ 'customer_task',
+ 'dashboard',
+ 'dashboard_template',
+ 'data_catalog',
+ 'data_deletion',
+ 'dataset',
+ 'early_access_feature',
+ 'endpoint',
+ 'error_tracking',
+ 'evaluation',
+ 'experiment',
+ 'experiment_holdout',
+ 'experiment_saved_metric',
+ 'export',
+ 'external_data_source',
+ 'feature_flag',
+ 'heatmap',
+ 'hog_flow',
+ 'insight',
+ 'llm_analytics',
+ 'llm_playground',
+ 'llm_prompt',
+ 'llm_provider_key',
+ 'llm_skill',
+ 'logs',
+ 'marketing_analytics',
+ 'mcp_analytics',
+ 'metrics',
+ 'notebook',
+ 'project',
+ 'property_definition',
+ 'replay_scanner',
+ 'revenue_analytics',
+ 'session_recording',
+ 'session_recording_playlist',
+ 'sharing_configuration',
+ 'stamphog',
+ 'survey',
+ 'tagger',
+ 'ticket',
+ 'toolbar',
+ 'tracing',
+ 'vision_alert',
+ 'warehouse_objects',
+ 'warehouse_table',
+ 'warehouse_view',
+ 'web_analytics',
+ ])
+ .describe(
+ '\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ )
+ .describe(
+ 'The scope of the rule: `project` for the project itself (with the project id as `resource_id`), a resource type such as `dashboard` for the whole resource type or for one object of it, or `property_definition` for one person or event property.\n\n\* `account` - account\n\* `action` - action\n\* `activity_log` - activity_log\n\* `ai_observability_clusters` - ai_observability_clusters\n\* `customer_analytics` - customer_analytics\n\* `customer_journey` - customer_journey\n\* `customer_task` - customer_task\n\* `dashboard` - dashboard\n\* `dashboard_template` - dashboard_template\n\* `data_catalog` - data_catalog\n\* `data_deletion` - data_deletion\n\* `dataset` - dataset\n\* `early_access_feature` - early_access_feature\n\* `endpoint` - endpoint\n\* `error_tracking` - error_tracking\n\* `evaluation` - evaluation\n\* `experiment` - experiment\n\* `experiment_holdout` - experiment_holdout\n\* `experiment_saved_metric` - experiment_saved_metric\n\* `export` - export\n\* `external_data_source` - external_data_source\n\* `feature_flag` - feature_flag\n\* `heatmap` - heatmap\n\* `hog_flow` - hog_flow\n\* `insight` - insight\n\* `llm_analytics` - llm_analytics\n\* `llm_playground` - llm_playground\n\* `llm_prompt` - llm_prompt\n\* `llm_provider_key` - llm_provider_key\n\* `llm_skill` - llm_skill\n\* `logs` - logs\n\* `marketing_analytics` - marketing_analytics\n\* `mcp_analytics` - mcp_analytics\n\* `metrics` - metrics\n\* `notebook` - notebook\n\* `project` - project\n\* `property_definition` - property_definition\n\* `replay_scanner` - replay_scanner\n\* `revenue_analytics` - revenue_analytics\n\* `session_recording` - session_recording\n\* `session_recording_playlist` - session_recording_playlist\n\* `sharing_configuration` - sharing_configuration\n\* `stamphog` - stamphog\n\* `survey` - survey\n\* `tagger` - tagger\n\* `ticket` - ticket\n\* `toolbar` - toolbar\n\* `tracing` - tracing\n\* `vision_alert` - vision_alert\n\* `warehouse_objects` - warehouse_objects\n\* `warehouse_table` - warehouse_table\n\* `warehouse_view` - warehouse_view\n\* `web_analytics` - web_analytics'
+ ),
+ resource_id: zod
+ .string()
+ .nullish()
+ .describe(
+ "The object the rule applies to: the project id for a project rule, an object's primary key for a rule on one object, or a property definition id when `resource` is `property_definition`. Omit it only for a rule on a whole resource type."
+ ),
+ access_level: zod
+ .string()
+ .nullable()
+ .describe(
+ 'The level to set. `member` or `admin` for the project, `none`, `viewer`, `editor` or `manager` for a resource type or an object, `none`, `read` or `read_write` for a property. Null removes the rule, so the subject falls back to the level it inherits.'
+ ),
+ role_id: zod.string().describe('The role id, as `role_id` in the roles endpoint.'),
+ })
+ .describe('A rule for every member of one role.')
+
/**
* Every role's resolved access to this project and to each resource type in it: the role's own rule, the level that is enforced, and the rule the enforced level comes from. Pass `role_id` for one role.
*/
diff --git a/services/mcp/src/tools/generated/access_control.ts b/services/mcp/src/tools/generated/access_control.ts
index 0477a7afe0b0..297a4ea21a4c 100644
--- a/services/mcp/src/tools/generated/access_control.ts
+++ b/services/mcp/src/tools/generated/access_control.ts
@@ -3,6 +3,12 @@ import { z } from 'zod'
import type { Schemas } from '@/api/generated'
import * as orvalSchemas from '@/generated/access_control/api'
+import { getConfirmedActionRuntime } from '@/tools/confirmed-action-registry'
+import {
+ executeConfirmedAction,
+ prepareConfirmedAction,
+ type PrepareConfirmedActionResult,
+} from '@/tools/confirmed-action-runtime'
import {
withPostHogUrl,
withAgentNote,
@@ -72,6 +78,116 @@ const accessControlDefaultPropertiesList = (): ToolBase<
},
})
+const AccessControlDefaultRuleSetSchema = () => {
+ const OrganizationsProjectsAccessControlDefaultRulesUpdateBody =
+ orvalSchemas.OrganizationsProjectsAccessControlDefaultRulesUpdateBody()
+ const OrganizationsProjectsAccessControlDefaultRulesUpdateParams =
+ orvalSchemas.OrganizationsProjectsAccessControlDefaultRulesUpdateParams()
+ return OrganizationsProjectsAccessControlDefaultRulesUpdateParams.omit({ organization_id: true })
+ .extend(OrganizationsProjectsAccessControlDefaultRulesUpdateBody.shape)
+ .extend({
+ id: OrganizationsProjectsAccessControlDefaultRulesUpdateParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ resource: OrganizationsProjectsAccessControlDefaultRulesUpdateBody.shape['resource'].describe(
+ 'The scope: `project`, a tool name such as `dashboard` or `feature_flag`, or `property_definition`. The tool names are the keys of `resource_access_levels` on access-control-defaults-get.'
+ ),
+ resource_id: OrganizationsProjectsAccessControlDefaultRulesUpdateBody.shape['resource_id']
+ .default(null)
+ .optional()
+ .describe(
+ "The project id for a project rule, the object's id for a rule on one object (a pk, as returned by the object's own get tool), or the property definition id for a property rule. Null only for a rule on a whole tool."
+ ),
+ access_level: OrganizationsProjectsAccessControlDefaultRulesUpdateBody.shape['access_level'].describe(
+ "The level to set, within the scope's `minimum` and `maximum` on access-control-defaults-get, or null to remove the rule."
+ ),
+ })
+}
+
+const AccessControlDefaultRuleSetSchemaExecute = z.strictObject({
+ confirmation_hash: z
+ .string()
+ .describe('The confirmation_hash returned by the matching -prepare tool. Pass it back verbatim.'),
+ confirmation: z.string().describe('The literal string "confirm", typed by the user in chat. Required to proceed.'),
+})
+
+const accessControlDefaultRuleSetPrepare = (): ToolBase<
+ ReturnType<typeof AccessControlDefaultRuleSetSchema>,
+ PrepareConfirmedActionResult
+> => ({
+ name: 'access-control-default-rule-set-prepare',
+ schema: AccessControlDefaultRuleSetSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlDefaultRuleSetSchema>>) => {
+ const __runtime = getConfirmedActionRuntime()
+ const __scopeOrgId = await context.stateManager.getOrgID()
+ const id = params.id ?? (await context.stateManager.getProjectId())
+ if (!id) {
+ throw new Error('id is required. Provide it explicitly or set an active project first.')
+ }
+ return await prepareConfirmedAction(context, {
+ args: { ...params, id },
+ purpose: 'access-control-default-rule-set',
+ actionLabel: 'change the default access rule',
+ messageTemplate:
+ "About to set the default {resource} access rule in project {id} to {access_level}, for object {resource_id} (null means the whole tool; a null level clears the rule). This changes what every member without a rule of their own gets. Reply 'confirm' to proceed.\n",
+ codec: __runtime.codec,
+ stash: __runtime.stash,
+ boundScope: { orgId: String(__scopeOrgId) },
+ })
+ },
+})
+
+const accessControlDefaultRuleSetExecute = (): ToolBase<
+ typeof AccessControlDefaultRuleSetSchemaExecute,
+ WithAgentNote<Schemas.AccessControlStoredRule>
+> => ({
+ name: 'access-control-default-rule-set-execute',
+ schema: AccessControlDefaultRuleSetSchemaExecute,
+ handler: async (context: Context, confirmationParams: z.infer<typeof AccessControlDefaultRuleSetSchemaExecute>) => {
+ const __runtime = getConfirmedActionRuntime()
+ const __scopeOrgId = await context.stateManager.getOrgID()
+ const __guard = await executeConfirmedAction<z.infer<ReturnType<typeof AccessControlDefaultRuleSetSchema>>>(
+ context,
+ {
+ incomingArgs: confirmationParams,
+ purpose: 'access-control-default-rule-set',
+ codec: __runtime.codec,
+ ledger: __runtime.ledger,
+ stash: __runtime.stash,
+ expectedScope: { orgId: String(__scopeOrgId) },
+ }
+ )
+ if (!__guard.ok) {
+ return __guard.result as never
+ }
+ const params = __guard.verifiedArgs
+ const orgId = __scopeOrgId
+ const id = params.id ?? (await context.stateManager.getProjectId())
+ if (!id) {
+ throw new Error('id is required. Provide it explicitly or set an active project first.')
+ }
+ const body: Record<string, unknown> = {}
+ if (params.resource !== undefined) {
+ body['resource'] = params.resource
+ }
+ if (params.resource_id !== undefined) {
+ body['resource_id'] = params.resource_id
+ }
+ if (params.access_level !== undefined) {
+ body['access_level'] = params.access_level
+ }
+ const result = await context.api.request<Schemas.AccessControlStoredRule>({
+ method: 'PUT',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_default_rules/`,
+ body,
+ })
+ return withAgentNote(
+ result,
+ 'A member rule or a role rule on the same scope still wins over this default. Verify the result with access-control-defaults-get or access-control-members-list.\n'
+ )
+ },
+})
+
const AccessControlDefaultsGetSchema = () => {
const OrganizationsProjectsAccessControlDefaultsRetrieveParams =
orvalSchemas.OrganizationsProjectsAccessControlDefaultsRetrieveParams()
@@ -194,6 +310,122 @@ const accessControlMemberPropertiesList = (): ToolBase<
},
})
+const AccessControlMemberRuleSetSchema = () => {
+ const OrganizationsProjectsAccessControlMemberRulesUpdateBody =
+ orvalSchemas.OrganizationsProjectsAccessControlMemberRulesUpdateBody()
+ const OrganizationsProjectsAccessControlMemberRulesUpdateParams =
+ orvalSchemas.OrganizationsProjectsAccessControlMemberRulesUpdateParams()
+ return OrganizationsProjectsAccessControlMemberRulesUpdateParams.omit({ organization_id: true })
+ .extend(OrganizationsProjectsAccessControlMemberRulesUpdateBody.shape)
+ .extend({
+ id: OrganizationsProjectsAccessControlMemberRulesUpdateParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ member_id: OrganizationsProjectsAccessControlMemberRulesUpdateBody.shape['member_id'].describe(
+ 'The organization membership id, as `organization_membership_id` in access-control-members-list.'
+ ),
+ resource: OrganizationsProjectsAccessControlMemberRulesUpdateBody.shape['resource'].describe(
+ 'The scope: `project`, a tool name such as `dashboard` or `feature_flag`, or `property_definition`. The tool names are the keys of `resources` in access-control-members-list.'
+ ),
+ resource_id: OrganizationsProjectsAccessControlMemberRulesUpdateBody.shape['resource_id']
+ .default(null)
+ .optional()
+ .describe(
+ "The project id for a project rule, the object's id for a rule on one object (a pk, as returned by the object's own get tool), or the property definition id for a property rule. Null only for a rule on a whole tool."
+ ),
+ access_level: OrganizationsProjectsAccessControlMemberRulesUpdateBody.shape['access_level'].describe(
+ "The level to set, within the scope's `minimum` and `maximum` on access-control-defaults-get, or null to remove the rule."
+ ),
+ })
+}
+
+const AccessControlMemberRuleSetSchemaExecute = z.strictObject({
+ confirmation_hash: z
+ .string()
+ .describe('The confirmation_hash returned by the matching -prepare tool. Pass it back verbatim.'),
+ confirmation: z.string().describe('The literal string "confirm", typed by the user in chat. Required to proceed.'),
+})
+
+const accessControlMemberRuleSetPrepare = (): ToolBase<
+ ReturnType<typeof AccessControlMemberRuleSetSchema>,
+ PrepareConfirmedActionResult
+> => ({
+ name: 'access-control-member-rule-set-prepare',
+ schema: AccessControlMemberRuleSetSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlMemberRuleSetSchema>>) => {
+ const __runtime = getConfirmedActionRuntime()
+ const __scopeOrgId = await context.stateManager.getOrgID()
+ const id = params.id ?? (await context.stateManager.getProjectId())
+ if (!id) {
+ throw new Error('id is required. Provide it explicitly or set an active project first.')
+ }
+ return await prepareConfirmedAction(context, {
+ args: { ...params, id },
+ purpose: 'access-control-member-rule-set',
+ actionLabel: "change a member's access rule",
+ messageTemplate:
+ "About to set the {resource} access rule for member {member_id} in project {id} to {access_level}, for object {resource_id} (null means the whole tool; a null level clears the rule). Reply 'confirm' to proceed.\n",
+ codec: __runtime.codec,
+ stash: __runtime.stash,
+ boundScope: { orgId: String(__scopeOrgId) },
+ })
+ },
+})
+
+const accessControlMemberRuleSetExecute = (): ToolBase<
+ typeof AccessControlMemberRuleSetSchemaExecute,
+ WithAgentNote<Schemas.AccessControlStoredRule>
+> => ({
+ name: 'access-control-member-rule-set-execute',
+ schema: AccessControlMemberRuleSetSchemaExecute,
+ handler: async (context: Context, confirmationParams: z.infer<typeof AccessControlMemberRuleSetSchemaExecute>) => {
+ const __runtime = getConfirmedActionRuntime()
+ const __scopeOrgId = await context.stateManager.getOrgID()
+ const __guard = await executeConfirmedAction<z.infer<ReturnType<typeof AccessControlMemberRuleSetSchema>>>(
+ context,
+ {
+ incomingArgs: confirmationParams,
+ purpose: 'access-control-member-rule-set',
+ codec: __runtime.codec,
+ ledger: __runtime.ledger,
+ stash: __runtime.stash,
+ expectedScope: { orgId: String(__scopeOrgId) },
+ }
+ )
+ if (!__guard.ok) {
+ return __guard.result as never
+ }
+ const params = __guard.verifiedArgs
+ const orgId = __scopeOrgId
+ const id = params.id ?? (await context.stateManager.getProjectId())
+ if (!id) {
+ throw new Error('id is required. Provide it explicitly or set an active project first.')
+ }
+ const body: Record<string, unknown> = {}
+ if (params.resource !== undefined) {
+ body['resource'] = params.resource
+ }
+ if (params.resource_id !== undefined) {
+ body['resource_id'] = params.resource_id
+ }
+ if (params.access_level !== undefined) {
+ body['access_level'] = params.access_level
+ }
+ if (params.member_id !== undefined) {
+ body['member_id'] = params.member_id
+ }
+ const result = await context.api.request<Schemas.AccessControlStoredRule>({
+ method: 'PUT',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_member_rules/`,
+ body,
+ })
+ return withAgentNote(
+ result,
+ 'Organization admins and owners have full access regardless of rules. Verify the result with access-control-members-list and `member_id`.\n'
+ )
+ },
+})
+
const AccessControlMembersListSchema = () => {
const OrganizationsProjectsAccessControlMembersRetrieveParams =
orvalSchemas.OrganizationsProjectsAccessControlMembersRetrieveParams()
@@ -328,6 +560,122 @@ const accessControlRolePropertiesList = (): ToolBase<
},
})
+const AccessControlRoleRuleSetSchema = () => {
+ const OrganizationsProjectsAccessControlRoleRulesUpdateBody =
+ orvalSchemas.OrganizationsProjectsAccessControlRoleRulesUpdateBody()
+ const OrganizationsProjectsAccessControlRoleRulesUpdateParams =
+ orvalSchemas.OrganizationsProjectsAccessControlRoleRulesUpdateParams()
+ return OrganizationsProjectsAccessControlRoleRulesUpdateParams.omit({ organization_id: true })
+ .extend(OrganizationsProjectsAccessControlRoleRulesUpdateBody.shape)
+ .extend({
+ id: OrganizationsProjectsAccessControlRoleRulesUpdateParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ role_id: OrganizationsProjectsAccessControlRoleRulesUpdateBody.shape['role_id'].describe(
+ 'The role id, as `role_id` in access-control-roles-list or `id` in roles-list.'
+ ),
+ resource: OrganizationsProjectsAccessControlRoleRulesUpdateBody.shape['resource'].describe(
+ 'The scope: `project`, a tool name such as `dashboard` or `feature_flag`, or `property_definition`. The tool names are the keys of `resources` in access-control-roles-list.'
+ ),
+ resource_id: OrganizationsProjectsAccessControlRoleRulesUpdateBody.shape['resource_id']
+ .default(null)
+ .optional()
+ .describe(
+ "The project id for a project rule, the object's id for a rule on one object (a pk, as returned by the object's own get tool), or the property definition id for a property rule. Null only for a rule on a whole tool."
+ ),
+ access_level: OrganizationsProjectsAccessControlRoleRulesUpdateBody.shape['access_level'].describe(
+ "The level to set, within the scope's `minimum` and `maximum` on access-control-defaults-get, or null to remove the rule."
+ ),
+ })
+}
+
+const AccessControlRoleRuleSetSchemaExecute = z.strictObject({
+ confirmation_hash: z
+ .string()
+ .describe('The confirmation_hash returned by the matching -prepare tool. Pass it back verbatim.'),
+ confirmation: z.string().describe('The literal string "confirm", typed by the user in chat. Required to proceed.'),
+})
+
+const accessControlRoleRuleSetPrepare = (): ToolBase<
+ ReturnType<typeof AccessControlRoleRuleSetSchema>,
+ PrepareConfirmedActionResult
+> => ({
+ name: 'access-control-role-rule-set-prepare',
+ schema: AccessControlRoleRuleSetSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlRoleRuleSetSchema>>) => {
+ const __runtime = getConfirmedActionRuntime()
+ const __scopeOrgId = await context.stateManager.getOrgID()
+ const id = params.id ?? (await context.stateManager.getProjectId())
+ if (!id) {
+ throw new Error('id is required. Provide it explicitly or set an active project first.')
+ }
+ return await prepareConfirmedAction(context, {
+ args: { ...params, id },
+ purpose: 'access-control-role-rule-set',
+ actionLabel: "change a role's access rule",
+ messageTemplate:
+ "About to set the {resource} access rule for role {role_id} in project {id} to {access_level}, for object {resource_id} (null means the whole tool; a null level clears the rule). This affects every member of the role. Reply 'confirm' to proceed.\n",
+ codec: __runtime.codec,
+ stash: __runtime.stash,
+ boundScope: { orgId: String(__scopeOrgId) },
+ })
+ },
+})
+
+const accessControlRoleRuleSetExecute = (): ToolBase<
+ typeof AccessControlRoleRuleSetSchemaExecute,
+ WithAgentNote<Schemas.AccessControlStoredRule>
+> => ({
+ name: 'access-control-role-rule-set-execute',
+ schema: AccessControlRoleRuleSetSchemaExecute,
+ handler: async (context: Context, confirmationParams: z.infer<typeof AccessControlRoleRuleSetSchemaExecute>) => {
+ const __runtime = getConfirmedActionRuntime()
+ const __scopeOrgId = await context.stateManager.getOrgID()
+ const __guard = await executeConfirmedAction<z.infer<ReturnType<typeof AccessControlRoleRuleSetSchema>>>(
+ context,
+ {
+ incomingArgs: confirmationParams,
+ purpose: 'access-control-role-rule-set',
+ codec: __runtime.codec,
+ ledger: __runtime.ledger,
+ stash: __runtime.stash,
+ expectedScope: { orgId: String(__scopeOrgId) },
+ }
+ )
+ if (!__guard.ok) {
+ return __guard.result as never
+ }
+ const params = __guard.verifiedArgs
+ const orgId = __scopeOrgId
+ const id = params.id ?? (await context.stateManager.getProjectId())
+ if (!id) {
+ throw new Error('id is required. Provide it explicitly or set an active project first.')
+ }
+ const body: Record<string, unknown> = {}
+ if (params.resource !== undefined) {
+ body['resource'] = params.resource
+ }
+ if (params.resource_id !== undefined) {
+ body['resource_id'] = params.resource_id
+ }
+ if (params.access_level !== undefined) {
+ body['access_level'] = params.access_level
+ }
+ if (params.role_id !== undefined) {
+ body['role_id'] = params.role_id
+ }
+ const result = await context.api.request<Schemas.AccessControlStoredRule>({
+ method: 'PUT',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_role_rules/`,
+ body,
+ })
+ return withAgentNote(
+ result,
+ 'Who is in the role is on role-members-list. Verify the result with access-control-roles-list and `role_id`.\n'
+ )
+ },
+})
+
const AccessControlRolesListSchema = () => {
const OrganizationsProjectsAccessControlRolesRetrieveParams =
orvalSchemas.OrganizationsProjectsAccessControlRolesRetrieveParams()
@@ -385,11 +733,17 @@ const accessControlRolesList = (): ToolBase<
export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'access-control-default-objects-list': accessControlDefaultObjectsList,
'access-control-default-properties-list': accessControlDefaultPropertiesList,
+ 'access-control-default-rule-set-prepare': accessControlDefaultRuleSetPrepare,
+ 'access-control-default-rule-set-execute': accessControlDefaultRuleSetExecute,
'access-control-defaults-get': accessControlDefaultsGet,
'access-control-member-objects-list': accessControlMemberObjectsList,
'access-control-member-properties-list': accessControlMemberPropertiesList,
+ 'access-control-member-rule-set-prepare': accessControlMemberRuleSetPrepare,
+ 'access-control-member-rule-set-execute': accessControlMemberRuleSetExecute,
'access-control-members-list': accessControlMembersList,
'access-control-role-objects-list': accessControlRoleObjectsList,
'access-control-role-properties-list': accessControlRolePropertiesList,
+ 'access-control-role-rule-set-prepare': accessControlRoleRuleSetPrepare,
+ 'access-control-role-rule-set-execute': accessControlRoleRuleSetExecute,
'access-control-roles-list': accessControlRolesList,
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-rule-set-execute.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-rule-set-execute.json
new file mode 100644
index 000000000000..f9e863b2ae53
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-rule-set-execute.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "additionalProperties": false,
+ "properties": {
+ "confirmation": {
+ "description": "The literal string \"confirm\", typed by the user in chat. Required to proceed.",
+ "type": "string"
+ },
+ "confirmation_hash": {
+ "description": "The confirmation_hash returned by the matching -prepare tool. Pass it back verbatim.",
+ "type": "string"
+ }
+ },
+ "required": ["confirmation_hash", "confirmation"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-rule-set-prepare.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-rule-set-prepare.json
new file mode 100644
index 000000000000..b4a337908fd2
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-rule-set-prepare.json
@@ -0,0 +1,95 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "access_level": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "The level to set, within the scope's `minimum` and `maximum` on access-control-defaults-get, or null to remove the rule."
+ },
+ "id": {
+ "description": "Project id. If omitted, uses the active project.",
+ "maximum": 2147483647,
+ "minimum": -2147483648,
+ "type": "number"
+ },
+ "resource": {
+ "description": "The scope: `project`, a tool name such as `dashboard` or `feature_flag`, or `property_definition`. The tool names are the keys of `resource_access_levels` on access-control-defaults-get.",
+ "enum": [
+ "account",
+ "action",
+ "activity_log",
+ "ai_observability_clusters",
+ "customer_analytics",
+ "customer_journey",
+ "customer_task",
+ "dashboard",
+ "dashboard_template",
+ "data_catalog",
+ "data_deletion",
+ "dataset",
+ "early_access_feature",
+ "endpoint",
+ "error_tracking",
+ "evaluation",
+ "experiment",
+ "experiment_holdout",
+ "experiment_saved_metric",
+ "export",
+ "external_data_source",
+ "feature_flag",
+ "heatmap",
+ "hog_flow",
+ "insight",
+ "llm_analytics",
+ "llm_playground",
+ "llm_prompt",
+ "llm_provider_key",
+ "llm_skill",
+ "logs",
+ "marketing_analytics",
+ "mcp_analytics",
+ "metrics",
+ "notebook",
+ "project",
+ "property_definition",
+ "replay_scanner",
+ "revenue_analytics",
+ "session_recording",
+ "session_recording_playlist",
+ "sharing_configuration",
+ "stamphog",
+ "survey",
+ "tagger",
+ "ticket",
+ "toolbar",
+ "tracing",
+ "vision_alert",
+ "warehouse_objects",
+ "warehouse_table",
+ "warehouse_view",
+ "web_analytics"
+ ],
+ "type": "string"
+ },
+ "resource_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The project id for a project rule, the object's id for a rule on one object (a pk, as returned by the object's own get tool), or the property definition id for a property rule. Null only for a rule on a whole tool."
+ }
+ },
+ "required": ["resource", "access_level"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-rule-set-execute.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-rule-set-execute.json
new file mode 100644
index 000000000000..f9e863b2ae53
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-rule-set-execute.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "additionalProperties": false,
+ "properties": {
+ "confirmation": {
+ "description": "The literal string \"confirm\", typed by the user in chat. Required to proceed.",
+ "type": "string"
+ },
+ "confirmation_hash": {
+ "description": "The confirmation_hash returned by the matching -prepare tool. Pass it back verbatim.",
+ "type": "string"
+ }
+ },
+ "required": ["confirmation_hash", "confirmation"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-rule-set-prepare.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-rule-set-prepare.json
new file mode 100644
index 000000000000..1d326a89bc36
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-rule-set-prepare.json
@@ -0,0 +1,99 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "access_level": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "The level to set, within the scope's `minimum` and `maximum` on access-control-defaults-get, or null to remove the rule."
+ },
+ "id": {
+ "description": "Project id. If omitted, uses the active project.",
+ "maximum": 2147483647,
+ "minimum": -2147483648,
+ "type": "number"
+ },
+ "member_id": {
+ "description": "The organization membership id, as `organization_membership_id` in access-control-members-list.",
+ "type": "string"
+ },
+ "resource": {
+ "description": "The scope: `project`, a tool name such as `dashboard` or `feature_flag`, or `property_definition`. The tool names are the keys of `resources` in access-control-members-list.",
+ "enum": [
+ "account",
+ "action",
+ "activity_log",
+ "ai_observability_clusters",
+ "customer_analytics",
+ "customer_journey",
+ "customer_task",
+ "dashboard",
+ "dashboard_template",
+ "data_catalog",
+ "data_deletion",
+ "dataset",
+ "early_access_feature",
+ "endpoint",
+ "error_tracking",
+ "evaluation",
+ "experiment",
+ "experiment_holdout",
+ "experiment_saved_metric",
+ "export",
+ "external_data_source",
+ "feature_flag",
+ "heatmap",
+ "hog_flow",
+ "insight",
+ "llm_analytics",
+ "llm_playground",
+ "llm_prompt",
+ "llm_provider_key",
+ "llm_skill",
+ "logs",
+ "marketing_analytics",
+ "mcp_analytics",
+ "metrics",
+ "notebook",
+ "project",
+ "property_definition",
+ "replay_scanner",
+ "revenue_analytics",
+ "session_recording",
+ "session_recording_playlist",
+ "sharing_configuration",
+ "stamphog",
+ "survey",
+ "tagger",
+ "ticket",
+ "toolbar",
+ "tracing",
+ "vision_alert",
+ "warehouse_objects",
+ "warehouse_table",
+ "warehouse_view",
+ "web_analytics"
+ ],
+ "type": "string"
+ },
+ "resource_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The project id for a project rule, the object's id for a rule on one object (a pk, as returned by the object's own get tool), or the property definition id for a property rule. Null only for a rule on a whole tool."
+ }
+ },
+ "required": ["resource", "access_level", "member_id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-rule-set-execute.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-rule-set-execute.json
new file mode 100644
index 000000000000..f9e863b2ae53
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-rule-set-execute.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "additionalProperties": false,
+ "properties": {
+ "confirmation": {
+ "description": "The literal string \"confirm\", typed by the user in chat. Required to proceed.",
+ "type": "string"
+ },
+ "confirmation_hash": {
+ "description": "The confirmation_hash returned by the matching -prepare tool. Pass it back verbatim.",
+ "type": "string"
+ }
+ },
+ "required": ["confirmation_hash", "confirmation"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-rule-set-prepare.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-rule-set-prepare.json
new file mode 100644
index 000000000000..59ac65274693
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-rule-set-prepare.json
@@ -0,0 +1,99 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "access_level": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "The level to set, within the scope's `minimum` and `maximum` on access-control-defaults-get, or null to remove the rule."
+ },
+ "id": {
+ "description": "Project id. If omitted, uses the active project.",
+ "maximum": 2147483647,
+ "minimum": -2147483648,
+ "type": "number"
+ },
+ "resource": {
+ "description": "The scope: `project`, a tool name such as `dashboard` or `feature_flag`, or `property_definition`. The tool names are the keys of `resources` in access-control-roles-list.",
+ "enum": [
+ "account",
+ "action",
+ "activity_log",
+ "ai_observability_clusters",
+ "customer_analytics",
+ "customer_journey",
+ "customer_task",
+ "dashboard",
+ "dashboard_template",
+ "data_catalog",
+ "data_deletion",
+ "dataset",
+ "early_access_feature",
+ "endpoint",
+ "error_tracking",
+ "evaluation",
+ "experiment",
+ "experiment_holdout",
+ "experiment_saved_metric",
+ "export",
+ "external_data_source",
+ "feature_flag",
+ "heatmap",
+ "hog_flow",
+ "insight",
+ "llm_analytics",
+ "llm_playground",
+ "llm_prompt",
+ "llm_provider_key",
+ "llm_skill",
+ "logs",
+ "marketing_analytics",
+ "mcp_analytics",
+ "metrics",
+ "notebook",
+ "project",
+ "property_definition",
+ "replay_scanner",
+ "revenue_analytics",
+ "session_recording",
+ "session_recording_playlist",
+ "sharing_configuration",
+ "stamphog",
+ "survey",
+ "tagger",
+ "ticket",
+ "toolbar",
+ "tracing",
+ "vision_alert",
+ "warehouse_objects",
+ "warehouse_table",
+ "warehouse_view",
+ "web_analytics"
+ ],
+ "type": "string"
+ },
+ "resource_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The project id for a project rule, the object's id for a rule on one object (a pk, as returned by the object's own get tool), or the property definition id for a property rule. Null only for a rule on a whole tool."
+ },
+ "role_id": {
+ "description": "The role id, as `role_id` in access-control-roles-list or `id` in roles-list.",
+ "type": "string"
+ }
+ },
+ "required": ["resource", "access_level", "role_id"],
+ "type": "object"
+}