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 read tools (#94553)

Alex Lider80dea8ab4cc2
diff --git a/frontend/src/lib/agentScopes.generated.ts b/frontend/src/lib/agentScopes.generated.ts
index 61ea6b4f47e0..3edce00fead2 100644
--- a/frontend/src/lib/agentScopes.generated.ts
+++ b/frontend/src/lib/agentScopes.generated.ts
@@ -9,6 +9,7 @@
export const AGENT_USE_CASE_SCOPES = [
'action:read',
'action:write',
+ 'access_control:read',
'account:read',
'account:write',
'activity_log:read',
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index 1cdd5ea8f50d..44b736bf8a41 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -595,6 +595,10 @@ SPECTACULAR_SETTINGS = {
"ShiftBandKindEnum": ["inserted", "deleted"],
"ExperimentStatusEnum": ["draft", "running", "paused", "exposure_frozen", "stopped"],
"ErrorTrackingIssueStatusEnum": ["archived", "active", "resolved", "pending_release", "suppressed", "all"],
+ # ResolvedAccess types source and source_subject as literals on a dataclass, so no Choices
+ # 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",
"TaskArtifactStatusEnum": ["active", "failed"],
#
# The same choice set is declared in more than one product. A shared Choices
diff --git a/products/access_control/backend/facade/enums.py b/products/access_control/backend/facade/enums.py
index 3c5fbae44add..d058708ee6bf 100644
--- a/products/access_control/backend/facade/enums.py
+++ b/products/access_control/backend/facade/enums.py
@@ -11,3 +11,22 @@ products need to interpret contract objects also belong here.
Internal-only constants (DB magic values, feature flags, etc.)
should stay in the implementation (logic.py, models.py).
"""
+
+from typing import Literal, get_args
+
+ResolvedAccessSourceValue = Literal[
+ "object",
+ "parent_object",
+ "resource",
+ "parent_resource",
+ "system_default",
+ "org_admin",
+ "creator",
+ "org_membership",
+]
+ResolvedAccessSourceSubjectValue = Literal["member", "role", "default"]
+
+# Serializer choices for the literals above. The schema names their enum components through
+# ENUM_NAME_OVERRIDES in posthog/settings/web.py, because no Choices class carries these values.
+RESOLVED_ACCESS_SOURCE_CHOICES: list[str] = list(get_args(ResolvedAccessSourceValue))
+RESOLVED_ACCESS_SOURCE_SUBJECT_CHOICES: list[str] = list(get_args(ResolvedAccessSourceSubjectValue))
diff --git a/products/access_control/backend/facade/user_access_control.py b/products/access_control/backend/facade/user_access_control.py
index 90167946c170..184ad0b1bb2c 100644
--- a/products/access_control/backend/facade/user_access_control.py
+++ b/products/access_control/backend/facade/user_access_control.py
@@ -33,6 +33,8 @@ else:
from products.access_control.backend.models.access_control import AccessControl
+from .enums import ResolvedAccessSourceSubjectValue, ResolvedAccessSourceValue
+
class AccessSource(Enum):
"""Enum for how a user got access to a resource"""
@@ -262,19 +264,10 @@ class ResolvedAccess:
"""
access_level: AccessControlLevel
- source: Literal[
- "object",
- "parent_object",
- "resource",
- "parent_resource",
- "system_default",
- "org_admin",
- "creator",
- "org_membership",
- ]
+ source: ResolvedAccessSourceValue
# The source rule's subject: an everyone-row ("default"), a role row, or a member row.
# None when no row decided.
- source_subject: Optional[Literal["member", "role", "default"]]
+ source_subject: Optional[ResolvedAccessSourceSubjectValue]
# The resource the source rule belongs to — a table resolved through its source reports the
# source's resource, and the system default reports the resource whose rules would apply
# (the RESOURCE_INHERITANCE_MAP umbrella), not necessarily the object's own.
diff --git a/products/access_control/backend/presentation/access_control.py b/products/access_control/backend/presentation/access_control.py
index a4b5d5da6ba4..930c8cbe08ac 100644
--- a/products/access_control/backend/presentation/access_control.py
+++ b/products/access_control/backend/presentation/access_control.py
@@ -18,6 +18,10 @@ from posthog.models.team.team import Team
from posthog.scopes import API_SCOPE_OBJECTS, INTERNAL_API_SCOPE_OBJECTS, APIScopeObjectOrNotSupported
from posthog.synthetic_user import SyntheticUser
+from products.access_control.backend.facade.enums import (
+ RESOLVED_ACCESS_SOURCE_CHOICES,
+ RESOLVED_ACCESS_SOURCE_SUBJECT_CHOICES,
+)
from products.access_control.backend.facade.object_names import display_model
from products.access_control.backend.facade.subject_access_control import SubjectAccessControl
from products.access_control.backend.facade.user_access_control import (
@@ -78,23 +82,15 @@ class ResolvedAccessSerializer(serializers.Serializer):
access_level = serializers.CharField(help_text="The access level that applies.")
source = serializers.ChoiceField( # type: ignore[assignment] # field named `source` shadows DRF Field.source
- choices=[
- "object",
- "parent_object",
- "resource",
- "parent_resource",
- "system_default",
- "org_admin",
- "creator",
- "org_membership",
- ],
+ choices=RESOLVED_ACCESS_SOURCE_CHOICES,
help_text="How the level was derived: a rule on the object, its parent object, the resource, the parent "
- "resource, the built-in default, or one of the bypasses (org admin, creator, organization membership).",
+ "resource, the PostHog default, an organization admin's or a creator's full access, or organization "
+ "membership when the object is the organization itself.",
)
source_subject = serializers.ChoiceField(
- choices=["member", "role", "default"],
+ choices=RESOLVED_ACCESS_SOURCE_SUBJECT_CHOICES,
allow_null=True,
- help_text="Whose rule decided: a member's own, a role's, or the default for everyone. Null when no rule did.",
+ help_text="Whose rule decided: a member's own, a role's, or the default for everyone in the project. Null when no rule did.",
)
source_resource = serializers.CharField(help_text="The resource the deciding rule belongs to.")
source_resource_id = serializers.CharField(
diff --git a/products/access_control/backend/presentation/access_control_settings.py b/products/access_control/backend/presentation/access_control_settings.py
index 6578f757cb32..b5d50bf47fe6 100644
--- a/products/access_control/backend/presentation/access_control_settings.py
+++ b/products/access_control/backend/presentation/access_control_settings.py
@@ -15,6 +15,7 @@ from django.core.exceptions import ValidationError as DjangoValidationError
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.decorators import action
from rest_framework.generics import get_object_or_404
@@ -22,7 +23,7 @@ from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet
-from posthog.api.documentation import extend_schema
+from posthog.api.documentation import OpenApiParameter, extend_schema
from posthog.models import PropertyDefinition
from posthog.models.organization import OrganizationMembership
from posthog.models.team.team import Team
@@ -50,13 +51,39 @@ 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, ResolvedAccessSerializer, upsert_access_control
+from .access_control import AccessControlSerializer, upsert_access_control
+from .serializers import (
+ AccessControlDefaultsResponseSerializer,
+ AccessControlMembersResponseSerializer,
+ AccessControlObjectRulesResponseSerializer,
+ AccessControlPropertyRulesResponseSerializer,
+ AccessControlRolesResponseSerializer,
+)
if TYPE_CHECKING:
_GenericViewSet = GenericViewSet
else:
_GenericViewSet = object
+# 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"}
+
+_MEMBER_ID_PARAM = OpenApiParameter(
+ name="member_id",
+ type=OpenApiTypes.UUID,
+ location=OpenApiParameter.QUERY,
+ required=True,
+ description="The organization membership id, as `organization_membership_id` in the members endpoint.",
+)
+_ROLE_ID_PARAM = OpenApiParameter(
+ name="role_id",
+ type=OpenApiTypes.UUID,
+ location=OpenApiParameter.QUERY,
+ required=True,
+ description="The role id, as `role_id` in the roles endpoint.",
+)
+
def _project_entry(subject: SubjectAccessControl, team: Team) -> dict[str, Any]:
"""Project access is an object-level question (the team is the object), never resource-wide."""
@@ -64,7 +91,7 @@ def _project_entry(subject: SubjectAccessControl, team: Team) -> dict[str, Any]:
return {
"access_level": subject.stored_level("project", str(team.id)),
"effective_access_level": subject.get_user_access_level(team),
- "inherited_access": ResolvedAccessSerializer(asdict(inherited)).data if inherited else None,
+ "inherited_access": asdict(inherited) if inherited else None,
"minimum": minimum_access_level("project"),
"maximum": highest_access_level("project"),
}
@@ -76,7 +103,7 @@ def _resource_entry(subject: SubjectAccessControl, resource: APIScopeObject) ->
return {
"access_level": subject.stored_level(resource, None),
"effective_access_level": effective.access_level if effective else None,
- "inherited_access": ResolvedAccessSerializer(asdict(inherited)).data if inherited else None,
+ "inherited_access": asdict(inherited) if inherited else None,
"minimum": minimum_access_level(resource),
"maximum": highest_access_level(resource),
}
@@ -189,7 +216,13 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
django_cache.set(cache_key, payload, timeout=300)
return Response(payload)
- @extend_schema(exclude=True)
+ @extend_schema(
+ description="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.",
+ responses={200: AccessControlDefaultsResponseSerializer},
+ extensions=_SCHEMA_EXTENSIONS,
+ )
@action(methods=["GET"], detail=True, url_path="access_control_defaults")
def access_control_defaults(self, request: Request, *args, **kwargs):
team = cast(Team, self.team) # type: ignore
@@ -215,30 +248,42 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
for r in ACCESS_CONTROL_RESOURCES
}
- # nosemgrep: api-response-must-match-schema -- unchanged response shape moved into the product boundary
- return Response(
- {
- "available_project_levels": list(ordered_access_levels("project")),
- "available_resource_levels": list(ACCESS_CONTROL_LEVELS_RESOURCE),
- "can_edit": user_access_control.check_can_modify_access_levels_for_object(team),
- "project_access_level": project_access_level,
- "resource_access_levels": resource_access_levels,
- # The resources the settings UI can search and rule on; every entry works with
- # access_control_object_search and access_control_object_rules. Levels ride along
- # per resource, like the per-resource access_controls endpoint returns them, so the
- # picker can only offer what a write would accept
- "object_rule_resources": [
- {
- "resource": r,
- "available_access_levels": list(ordered_access_levels(r)),
- "minimum_access_level": minimum_access_level(r),
- }
- for r in sorted(r for r in resources_with_object_access_controls() if display_model(r) is not None)
- ],
- }
- )
-
- @extend_schema(exclude=True)
+ payload = {
+ "available_project_levels": list(ordered_access_levels("project")),
+ "available_resource_levels": list(ACCESS_CONTROL_LEVELS_RESOURCE),
+ "can_edit": user_access_control.check_can_modify_access_levels_for_object(team),
+ "project_access_level": project_access_level,
+ "resource_access_levels": resource_access_levels,
+ # The resources the settings UI can search and rule on; every entry works with
+ # access_control_object_search and access_control_object_rules. Levels ride along
+ # per resource, like the per-resource access_controls endpoint returns them, so the
+ # picker can only offer what a write would accept
+ "object_rule_resources": [
+ {
+ "resource": r,
+ "available_access_levels": list(ordered_access_levels(r)),
+ "minimum_access_level": minimum_access_level(r),
+ }
+ for r in sorted(r for r in resources_with_object_access_controls() if display_model(r) is not None)
+ ],
+ }
+ return Response(AccessControlDefaultsResponseSerializer(payload).data)
+
+ @extend_schema(
+ description="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.",
+ parameters=[
+ OpenApiParameter(
+ name="role_id",
+ type=OpenApiTypes.UUID,
+ location=OpenApiParameter.QUERY,
+ required=False,
+ description="Narrow the list to one role.",
+ )
+ ],
+ responses={200: AccessControlRolesResponseSerializer},
+ extensions=_SCHEMA_EXTENSIONS,
+ )
@action(methods=["GET"], detail=True, url_path="access_control_roles")
def access_control_roles(self, request: Request, *args, **kwargs):
team = cast(Team, self.team) # type: ignore
@@ -269,17 +314,31 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
}
)
- # nosemgrep: api-response-must-match-schema -- unchanged response shape moved into the product boundary
- return Response(
- {
- "available_project_levels": list(ordered_access_levels("project")),
- "available_resource_levels": list(ACCESS_CONTROL_LEVELS_RESOURCE),
- "can_edit": user_access_control.check_can_modify_access_levels_for_object(team),
- "results": results,
- }
- )
-
- @extend_schema(exclude=True)
+ payload = {
+ "available_project_levels": list(ordered_access_levels("project")),
+ "available_resource_levels": list(ACCESS_CONTROL_LEVELS_RESOURCE),
+ "can_edit": user_access_control.check_can_modify_access_levels_for_object(team),
+ "results": results,
+ }
+ return Response(AccessControlRolesResponseSerializer(payload).data)
+
+ @extend_schema(
+ description="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.",
+ parameters=[
+ OpenApiParameter(
+ name="member_id",
+ type=OpenApiTypes.UUID,
+ location=OpenApiParameter.QUERY,
+ required=False,
+ description="Narrow the list to one organization membership id.",
+ )
+ ],
+ responses={200: AccessControlMembersResponseSerializer},
+ extensions=_SCHEMA_EXTENSIONS,
+ )
@action(methods=["GET"], detail=True, url_path="access_control_members")
def access_control_members(self, request: Request, *args, **kwargs):
team = cast(Team, self.team) # type: ignore
@@ -327,6 +386,7 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
"email": user.email,
},
"organization_level": member.level,
+ "role_ids": role_ids,
"project": _project_entry(subject, team),
"resources": {
resource: _resource_entry(subject, resource) for resource in ACCESS_CONTROL_RESOURCES
@@ -334,15 +394,13 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
}
)
- # nosemgrep: api-response-must-match-schema -- unchanged response shape moved into the product boundary
- return Response(
- {
- "available_project_levels": list(ordered_access_levels("project")),
- "available_resource_levels": list(ACCESS_CONTROL_LEVELS_RESOURCE),
- "can_edit": can_edit,
- "results": results,
- }
- )
+ payload = {
+ "available_project_levels": list(ordered_access_levels("project")),
+ "available_resource_levels": list(ACCESS_CONTROL_LEVELS_RESOURCE),
+ "can_edit": can_edit,
+ "results": results,
+ }
+ return Response(AccessControlMembersResponseSerializer(payload).data)
def _get_membership(self, request: Request, team: Team) -> OrganizationMembership:
member_id = request.query_params.get("member_id")
@@ -396,7 +454,7 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
)
)
if not rows:
- return Response({"results": []})
+ return Response(AccessControlObjectRulesResponseSerializer({"results": []}).data)
ids_by_resource: dict[str, list[str]] = defaultdict(list)
for ac in rows:
@@ -421,7 +479,7 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
}
)
results.sort(key=lambda r: (r["resource"], (r["name"] or "").lower()))
- return Response({"results": results})
+ return Response(AccessControlObjectRulesResponseSerializer({"results": results}).data)
def _property_rules_response(
self,
@@ -461,23 +519,37 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
}
)
results.sort(key=lambda r: (r["property_type"], (r["property"] or "").lower()))
- return Response({"results": results})
+ return Response(AccessControlPropertyRulesResponseSerializer({"results": results}).data)
- @extend_schema(exclude=True)
+ @extend_schema(
+ description="Object rules that apply to everyone in the project without a rule of their own on that object.",
+ responses={200: AccessControlObjectRulesResponseSerializer},
+ extensions=_SCHEMA_EXTENSIONS,
+ )
@action(methods=["GET"], detail=True, url_path="access_control_default_objects")
def access_control_default_objects(self, request: Request, *args, **kwargs) -> Response:
- """Object-level access rules that apply to everyone without a rule of their own."""
+ """Object-level access rules that apply to everyone in the project without a rule of their own."""
team = cast(Team, self.team) # type: ignore
return self._object_rules_response(team)
- @extend_schema(exclude=True)
+ @extend_schema(
+ description="Property rules that apply to everyone in the project without a rule of their own on that property.",
+ responses={200: AccessControlPropertyRulesResponseSerializer},
+ extensions=_SCHEMA_EXTENSIONS,
+ )
@action(methods=["GET"], detail=True, url_path="access_control_default_properties")
def access_control_default_properties(self, request: Request, *args, **kwargs) -> Response:
- """Property restrictions that apply to everyone without a rule of their own."""
+ """Property restrictions that apply to everyone in the project without a rule of their own."""
team = cast(Team, self.team) # type: ignore
return self._property_rules_response(team)
- @extend_schema(exclude=True)
+ @extend_schema(
+ description="Object rules configured for a member: the single objects, for example a dashboard or a notebook, "
+ "the member is granted or denied, regardless of the resource-level rules.",
+ parameters=[_MEMBER_ID_PARAM],
+ responses={200: AccessControlObjectRulesResponseSerializer},
+ extensions=_SCHEMA_EXTENSIONS,
+ )
@action(methods=["GET"], detail=True, url_path="access_control_member_objects")
def access_control_member_objects(self, request: Request, *args, **kwargs) -> Response:
"""Object-level access rules configured for a member."""
@@ -485,7 +557,13 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
membership = self._get_membership(request, team)
return self._object_rules_response(team, membership=membership)
- @extend_schema(exclude=True)
+ @extend_schema(
+ description="Property rules configured for a member: the person and event properties the member can "
+ "read, read and write, or not see.",
+ parameters=[_MEMBER_ID_PARAM],
+ responses={200: AccessControlPropertyRulesResponseSerializer},
+ extensions=_SCHEMA_EXTENSIONS,
+ )
@action(methods=["GET"], detail=True, url_path="access_control_member_properties")
def access_control_member_properties(self, request: Request, *args, **kwargs) -> Response:
"""Property restrictions configured for a member."""
@@ -493,7 +571,13 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
membership = self._get_membership(request, team)
return self._property_rules_response(team, organization_member=membership)
- @extend_schema(exclude=True)
+ @extend_schema(
+ description="Object rules configured for a role: the single objects the role's members are granted or "
+ "denied, regardless of the resource-level rules.",
+ parameters=[_ROLE_ID_PARAM],
+ responses={200: AccessControlObjectRulesResponseSerializer},
+ extensions=_SCHEMA_EXTENSIONS,
+ )
@action(methods=["GET"], detail=True, url_path="access_control_role_objects")
def access_control_role_objects(self, request: Request, *args, **kwargs) -> Response:
"""Object-level access rules configured for a role."""
@@ -501,7 +585,13 @@ class AccessControlSettingsViewSetMixin(_GenericViewSet):
role = self._get_role(request, team)
return self._object_rules_response(team, role=role)
- @extend_schema(exclude=True)
+ @extend_schema(
+ description="Property rules configured for a role: the person and event properties the role's members "
+ "can read, read and write, or not see.",
+ parameters=[_ROLE_ID_PARAM],
+ responses={200: AccessControlPropertyRulesResponseSerializer},
+ extensions=_SCHEMA_EXTENSIONS,
+ )
@action(methods=["GET"], detail=True, url_path="access_control_role_properties")
def access_control_role_properties(self, request: Request, *args, **kwargs) -> Response:
"""Property restrictions configured for a role."""
diff --git a/products/access_control/backend/presentation/serializers.py b/products/access_control/backend/presentation/serializers.py
index e665c35a37f3..db0dc6bb529d 100644
--- a/products/access_control/backend/presentation/serializers.py
+++ b/products/access_control/backend/presentation/serializers.py
@@ -8,8 +8,11 @@ talks to the facade.
from rest_framework import serializers
+from posthog.models.organization import OrganizationMembership
+
from ..facade import contracts
from ..facade.contracts import PropertyAccessLevel
+from .access_control import ResolvedAccessSerializer
_ACCESS_LEVEL_CHOICES = [(e.value, e.value) for e in PropertyAccessLevel]
@@ -123,3 +126,152 @@ class PropertyAccessControlDeleteSerializer(serializers.Serializer):
default=None,
help_text="The role UUID whose override should be deleted.",
)
+
+
+class SubjectAccessEntrySerializer(serializers.Serializer):
+ """One subject's access to one scope (the project, or a whole resource type): what is stored,
+ what is enforced, and where the enforced level comes from."""
+
+ access_level = serializers.CharField(
+ allow_null=True,
+ help_text="The subject's own stored rule for this scope. Null when the subject has no rule of its own here.",
+ )
+ effective_access_level = serializers.CharField(
+ allow_null=True,
+ help_text="The level that is enforced for the subject after defaults, roles and bypasses are resolved. "
+ "Null when nothing resolves for this scope.",
+ )
+ inherited_access = ResolvedAccessSerializer(
+ allow_null=True,
+ help_text="The level the subject falls back to without a rule of its own, with the rule that supplies it. "
+ "Read `source` and `source_subject` to tell a role rule from the project default, or an organization admin's full access.",
+ )
+ minimum = serializers.CharField(help_text="The lowest level this scope allows.")
+ maximum = serializers.CharField(help_text="The highest level this scope allows.")
+
+
+class AccessControlMemberUserSerializer(serializers.Serializer):
+ uuid = serializers.UUIDField(help_text="The user's UUID.")
+ first_name = serializers.CharField(help_text="The user's first name.")
+ last_name = serializers.CharField(help_text="The user's last name.")
+ email = serializers.EmailField(help_text="The user's email.")
+
+
+class AccessControlMemberAccessSerializer(serializers.Serializer):
+ """A member's resolved access to the project and to every resource type in it."""
+
+ organization_membership_id = serializers.UUIDField(
+ help_text="The organization membership id. Use it as `member_id` on the member rule endpoints.",
+ )
+ user = AccessControlMemberUserSerializer(help_text="The member's identity.")
+ organization_level = serializers.ChoiceField(
+ choices=OrganizationMembership.Level.choices,
+ help_text="The member's organization level: 1 member, 8 admin, 15 owner. Admins and owners have full access to everything.",
+ )
+ role_ids = serializers.ListField(
+ child=serializers.UUIDField(),
+ help_text="The roles the member is in. Use them as `role_id` on the role rule endpoints.",
+ )
+ project = SubjectAccessEntrySerializer(help_text="Access to the project itself.")
+ resources = serializers.DictField(
+ child=SubjectAccessEntrySerializer(),
+ help_text="Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`).",
+ )
+
+
+class AccessControlRoleAccessSerializer(serializers.Serializer):
+ """A role's resolved access to the project and to every resource type in it."""
+
+ role_id = serializers.UUIDField(help_text="The role id. Use it as `role_id` on the role rule endpoints.")
+ role_name = serializers.CharField(help_text="The role's name.")
+ project = SubjectAccessEntrySerializer(help_text="Access to the project itself.")
+ resources = serializers.DictField(
+ child=SubjectAccessEntrySerializer(),
+ help_text="Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`).",
+ )
+
+
+class _AccessControlSettingsResponseSerializer(serializers.Serializer):
+ available_project_levels = serializers.ListField(
+ child=serializers.CharField(),
+ help_text="The project access levels, lowest first.",
+ )
+ available_resource_levels = serializers.ListField(
+ child=serializers.CharField(),
+ help_text="The resource access levels, lowest first.",
+ )
+ can_edit = serializers.BooleanField(help_text="Whether the caller may change access rules in this project.")
+
+
+class AccessControlMembersResponseSerializer(_AccessControlSettingsResponseSerializer):
+ results = AccessControlMemberAccessSerializer(many=True, help_text="One entry per organization member.")
+
+
+class AccessControlRolesResponseSerializer(_AccessControlSettingsResponseSerializer):
+ results = AccessControlRoleAccessSerializer(many=True, help_text="One entry per role in the organization.")
+
+
+class AccessControlResourceDefaultSerializer(serializers.Serializer):
+ access_level = serializers.CharField(
+ allow_null=True,
+ help_text="The stored default level for this resource type. Null when the PostHog default applies.",
+ )
+ minimum = serializers.CharField(help_text="The lowest level this resource type allows.")
+ maximum = serializers.CharField(help_text="The highest level this resource type allows.")
+
+
+class AccessControlObjectRuleResourceSerializer(serializers.Serializer):
+ resource = serializers.CharField(help_text="A resource type that supports rules on single objects.")
+ available_access_levels = serializers.ListField(
+ child=serializers.CharField(),
+ help_text="The levels an object rule on this resource type accepts, lowest first.",
+ )
+ minimum_access_level = serializers.CharField(help_text="The lowest level an object rule on this resource can set.")
+
+
+class AccessControlDefaultsResponseSerializer(_AccessControlSettingsResponseSerializer):
+ """The project's defaults: what everyone without a rule of their own gets."""
+
+ project_access_level = serializers.CharField(help_text="The default project access level for members.")
+ resource_access_levels = serializers.DictField(
+ child=AccessControlResourceDefaultSerializer(),
+ help_text="The default level per resource type, keyed by resource name.",
+ )
+ object_rule_resources = AccessControlObjectRuleResourceSerializer(
+ many=True,
+ help_text="The resource types that accept rules on single objects, with the levels each accepts.",
+ )
+
+
+class AccessControlObjectRuleSerializer(serializers.Serializer):
+ """A stored rule on one object, as configured for a subject."""
+
+ resource = serializers.CharField(help_text="The object's resource type, for example `dashboard`.")
+ resource_id = serializers.CharField(help_text="The object's primary key.")
+ name = serializers.CharField(help_text="The object's display name. Falls back to the id when it has no name.")
+ short_id = serializers.CharField(
+ allow_null=True,
+ help_text="The object's short id, for models that link by one (insights, notebooks).",
+ )
+ access_level = serializers.CharField(help_text="The level the rule grants or restricts to.")
+
+
+class AccessControlObjectRulesResponseSerializer(serializers.Serializer):
+ results = AccessControlObjectRuleSerializer(
+ many=True, help_text="The subject's object rules, sorted by resource and name."
+ )
+
+
+class AccessControlPropertyRuleSerializer(serializers.Serializer):
+ """A stored rule on one property definition, as configured for a subject."""
+
+ property_definition_id = serializers.UUIDField(help_text="The property definition id.")
+ property = serializers.CharField(help_text="The property name.")
+ property_type = serializers.CharField(help_text="Whether the property is a `person` or an `event` property.")
+ access_level = serializers.CharField(help_text="The rule's level: `none`, `read` or `read_write`.")
+
+
+class AccessControlPropertyRulesResponseSerializer(serializers.Serializer):
+ results = AccessControlPropertyRuleSerializer(
+ many=True, help_text="The subject's property rules, sorted by property type and name."
+ )
diff --git a/products/access_control/backend/tests/test_access_control.py b/products/access_control/backend/tests/test_access_control.py
index 506100a4baab..989a6572ad16 100644
--- a/products/access_control/backend/tests/test_access_control.py
+++ b/products/access_control/backend/tests/test_access_control.py
@@ -2025,9 +2025,17 @@ class TestAccessControlMembersEndpoint(BaseAccessControlTest):
# Member entry: user info, org level, project access, per-resource access
member_data = self._find_member(data["results"], self.user2_membership.id)
assert member_data is not None
- expected_member_keys = {"organization_membership_id", "user", "organization_level", "project", "resources"}
+ expected_member_keys = {
+ "organization_membership_id",
+ "user",
+ "organization_level",
+ "role_ids",
+ "project",
+ "resources",
+ }
assert expected_member_keys <= set(member_data.keys())
assert member_data["organization_membership_id"] == str(self.user2_membership.id)
+ assert member_data["role_ids"] == []
# User object: identity fields
expected_user_keys = {"uuid", "first_name", "last_name", "email"}
@@ -2088,6 +2096,7 @@ class TestAccessControlMembersEndpoint(BaseAccessControlTest):
assert member_data["project"]["effective_access_level"] == "admin"
assert member_data["project"]["inherited_access"]["access_level"] == "admin"
assert member_data["project"]["inherited_access"]["source_subject"] == "role"
+ assert member_data["role_ids"] == [str(self.role.id)]
def test_project_admin_does_not_affect_resource_effective_level(self):
"""Project-level admin default does not grant resource-level access."""
diff --git a/products/access_control/frontend/generated/api.schemas.ts b/products/access_control/frontend/generated/api.schemas.ts
index 656332d3daa2..7630fb533bc7 100644
--- a/products/access_control/frontend/generated/api.schemas.ts
+++ b/products/access_control/frontend/generated/api.schemas.ts
@@ -7,6 +7,278 @@
* PostHog API - generated
* OpenAPI spec version: 1.0.0
*/
+/**
+ * A stored rule on one object, as configured for a subject.
+ */
+export interface AccessControlObjectRuleApi {
+ /** The object's resource type, for example `dashboard`. */
+ resource: string
+ /** The object's primary key. */
+ resource_id: string
+ /** The object's display name. Falls back to the id when it has no name. */
+ name: string
+ /**
+ * The object's short id, for models that link by one (insights, notebooks).
+ * @nullable
+ */
+ short_id: string | null
+ /** The level the rule grants or restricts to. */
+ access_level: string
+}
+
+export interface AccessControlObjectRulesResponseApi {
+ /** The subject's object rules, sorted by resource and name. */
+ results: AccessControlObjectRuleApi[]
+}
+
+/**
+ * A stored rule on one property definition, as configured for a subject.
+ */
+export interface AccessControlPropertyRuleApi {
+ /** The property definition id. */
+ property_definition_id: string
+ /** The property name. */
+ property: string
+ /** Whether the property is a `person` or an `event` property. */
+ property_type: string
+ /** The rule's level: `none`, `read` or `read_write`. */
+ access_level: string
+}
+
+export interface AccessControlPropertyRulesResponseApi {
+ /** The subject's property rules, sorted by property type and name. */
+ results: AccessControlPropertyRuleApi[]
+}
+
+export interface AccessControlResourceDefaultApi {
+ /**
+ * The stored default level for this resource type. Null when the PostHog default applies.
+ * @nullable
+ */
+ access_level: string | null
+ /** The lowest level this resource type allows. */
+ minimum: string
+ /** The highest level this resource type allows. */
+ maximum: string
+}
+
+/**
+ * The default level per resource type, keyed by resource name.
+ */
+export type AccessControlDefaultsResponseApiResourceAccessLevels = { [key: string]: AccessControlResourceDefaultApi }
+
+export interface AccessControlObjectRuleResourceApi {
+ /** A resource type that supports rules on single objects. */
+ resource: string
+ /** The levels an object rule on this resource type accepts, lowest first. */
+ available_access_levels: string[]
+ /** The lowest level an object rule on this resource can set. */
+ minimum_access_level: string
+}
+
+/**
+ * The project's defaults: what everyone without a rule of their own gets.
+ */
+export interface AccessControlDefaultsResponseApi {
+ /** The project access levels, lowest first. */
+ available_project_levels: string[]
+ /** The resource access levels, lowest first. */
+ available_resource_levels: string[]
+ /** Whether the caller may change access rules in this project. */
+ can_edit: boolean
+ /** The default project access level for members. */
+ project_access_level: string
+ /** The default level per resource type, keyed by resource name. */
+ resource_access_levels: AccessControlDefaultsResponseApiResourceAccessLevels
+ /** The resource types that accept rules on single objects, with the levels each accepts. */
+ object_rule_resources: AccessControlObjectRuleResourceApi[]
+}
+
+export interface AccessControlMemberUserApi {
+ /** The user's UUID. */
+ uuid: string
+ /** The user's first name. */
+ first_name: string
+ /** The user's last name. */
+ last_name: string
+ /** The user's email. */
+ email: string
+}
+
+/**
+ * * `1` - member
+ * * `8` - administrator
+ * * `15` - owner
+ */
+export type OrganizationMembershipLevelEnumApi =
+ (typeof OrganizationMembershipLevelEnumApi)[keyof typeof OrganizationMembershipLevelEnumApi]
+
+export const OrganizationMembershipLevelEnumApi = {
+ Number1: 1,
+ Number8: 8,
+ Number15: 15,
+} as const
+
+/**
+ * * `object` - object
+ * * `parent_object` - parent_object
+ * * `resource` - resource
+ * * `parent_resource` - parent_resource
+ * * `system_default` - system_default
+ * * `org_admin` - org_admin
+ * * `creator` - creator
+ * * `org_membership` - org_membership
+ */
+export type ResolvedAccessSourceEnumApi = (typeof ResolvedAccessSourceEnumApi)[keyof typeof ResolvedAccessSourceEnumApi]
+
+export const ResolvedAccessSourceEnumApi = {
+ Object: 'object',
+ ParentObject: 'parent_object',
+ Resource: 'resource',
+ ParentResource: 'parent_resource',
+ SystemDefault: 'system_default',
+ OrgAdmin: 'org_admin',
+ Creator: 'creator',
+ OrgMembership: 'org_membership',
+} as const
+
+/**
+ * * `member` - member
+ * * `role` - role
+ * * `default` - default
+ */
+export type ResolvedAccessSourceSubjectEnumApi =
+ (typeof ResolvedAccessSourceSubjectEnumApi)[keyof typeof ResolvedAccessSourceSubjectEnumApi]
+
+export const ResolvedAccessSourceSubjectEnumApi = {
+ Member: 'member',
+ Role: 'role',
+ Default: 'default',
+} as const
+
+/**
+ * A resolved access level with the rule that supplied it — the wire form of `ResolvedAccess`.
+ */
+export interface ResolvedAccessApi {
+ /** The access level that applies. */
+ access_level: string
+ /** How the level was derived: a rule on the object, its parent object, the resource, the parent resource, the PostHog default, an organization admin's or a creator's full access, or organization membership when the object is the organization itself.
+ *
+ * * `object` - object
+ * * `parent_object` - parent_object
+ * * `resource` - resource
+ * * `parent_resource` - parent_resource
+ * * `system_default` - system_default
+ * * `org_admin` - org_admin
+ * * `creator` - creator
+ * * `org_membership` - org_membership */
+ source: ResolvedAccessSourceEnumApi
+ /** Whose rule decided: a member's own, a role's, or the default for everyone in the project. Null when no rule did.
+ *
+ * * `member` - member
+ * * `role` - role
+ * * `default` - default */
+ source_subject: ResolvedAccessSourceSubjectEnumApi | null
+ /** The resource the deciding rule belongs to. */
+ source_resource: string
+ /**
+ * The deciding rule's object id, when it is an object-level rule (e.g. the source a table inherits from).
+ * @nullable
+ */
+ source_resource_id: string | null
+}
+
+/**
+ * One subject's access to one scope (the project, or a whole resource type): what is stored,
+ * what is enforced, and where the enforced level comes from.
+ */
+export interface SubjectAccessEntryApi {
+ /**
+ * The subject's own stored rule for this scope. Null when the subject has no rule of its own here.
+ * @nullable
+ */
+ access_level: string | null
+ /**
+ * The level that is enforced for the subject after defaults, roles and bypasses are resolved. Null when nothing resolves for this scope.
+ * @nullable
+ */
+ effective_access_level: string | null
+ /** The level the subject falls back to without a rule of its own, with the rule that supplies it. Read `source` and `source_subject` to tell a role rule from the project default, or an organization admin's full access. */
+ inherited_access: ResolvedAccessApi | null
+ /** The lowest level this scope allows. */
+ minimum: string
+ /** The highest level this scope allows. */
+ maximum: string
+}
+
+/**
+ * Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`).
+ */
+export type AccessControlMemberAccessApiResources = { [key: string]: SubjectAccessEntryApi }
+
+/**
+ * A member's resolved access to the project and to every resource type in it.
+ */
+export interface AccessControlMemberAccessApi {
+ /** The organization membership id. Use it as `member_id` on the member rule endpoints. */
+ organization_membership_id: string
+ /** The member's identity. */
+ user: AccessControlMemberUserApi
+ /** The member's organization level: 1 member, 8 admin, 15 owner. Admins and owners have full access to everything.
+ *
+ * * `1` - member
+ * * `8` - administrator
+ * * `15` - owner */
+ organization_level: OrganizationMembershipLevelEnumApi
+ /** The roles the member is in. Use them as `role_id` on the role rule endpoints. */
+ role_ids: string[]
+ /** Access to the project itself. */
+ project: SubjectAccessEntryApi
+ /** Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`). */
+ resources: AccessControlMemberAccessApiResources
+}
+
+export interface AccessControlMembersResponseApi {
+ /** The project access levels, lowest first. */
+ available_project_levels: string[]
+ /** The resource access levels, lowest first. */
+ available_resource_levels: string[]
+ /** Whether the caller may change access rules in this project. */
+ can_edit: boolean
+ /** One entry per organization member. */
+ results: AccessControlMemberAccessApi[]
+}
+
+/**
+ * Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`).
+ */
+export type AccessControlRoleAccessApiResources = { [key: string]: SubjectAccessEntryApi }
+
+/**
+ * A role's resolved access to the project and to every resource type in it.
+ */
+export interface AccessControlRoleAccessApi {
+ /** The role id. Use it as `role_id` on the role rule endpoints. */
+ role_id: string
+ /** The role's name. */
+ role_name: string
+ /** Access to the project itself. */
+ project: SubjectAccessEntryApi
+ /** Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`). */
+ resources: AccessControlRoleAccessApiResources
+}
+
+export interface AccessControlRolesResponseApi {
+ /** The project access levels, lowest first. */
+ available_project_levels: string[]
+ /** The resource access levels, lowest first. */
+ available_resource_levels: string[]
+ /** Whether the caller may change access rules in this project. */
+ can_edit: boolean
+ /** One entry per role in the organization. */
+ results: AccessControlRoleAccessApi[]
+}
+
/**
* * `read_write` - read_write
* * `read` - read
@@ -86,6 +358,48 @@ export interface PropertyAccessControlUpdateApi {
role?: string | null
}
+export type OrganizationsProjectsAccessControlMemberObjectsRetrieveParams = {
+ /**
+ * The organization membership id, as `organization_membership_id` in the members endpoint.
+ */
+ member_id: string
+}
+
+export type OrganizationsProjectsAccessControlMemberPropertiesRetrieveParams = {
+ /**
+ * The organization membership id, as `organization_membership_id` in the members endpoint.
+ */
+ member_id: string
+}
+
+export type OrganizationsProjectsAccessControlMembersRetrieveParams = {
+ /**
+ * Narrow the list to one organization membership id.
+ */
+ member_id?: string
+}
+
+export type OrganizationsProjectsAccessControlRoleObjectsRetrieveParams = {
+ /**
+ * The role id, as `role_id` in the roles endpoint.
+ */
+ role_id: string
+}
+
+export type OrganizationsProjectsAccessControlRolePropertiesRetrieveParams = {
+ /**
+ * The role id, as `role_id` in the roles endpoint.
+ */
+ role_id: string
+}
+
+export type OrganizationsProjectsAccessControlRolesRetrieveParams = {
+ /**
+ * Narrow the list to one role.
+ */
+ role_id?: string
+}
+
export type PropertyAccessControlsRetrieveParams = {
/**
* The property definition ID to fetch access control rules for.
diff --git a/products/access_control/frontend/generated/api.ts b/products/access_control/frontend/generated/api.ts
index 737420707285..15f381a464c7 100644
--- a/products/access_control/frontend/generated/api.ts
+++ b/products/access_control/frontend/generated/api.ts
@@ -9,6 +9,17 @@ import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
* OpenAPI spec version: 1.0.0
*/
import type {
+ AccessControlDefaultsResponseApi,
+ AccessControlMembersResponseApi,
+ AccessControlObjectRulesResponseApi,
+ AccessControlPropertyRulesResponseApi,
+ AccessControlRolesResponseApi,
+ OrganizationsProjectsAccessControlMemberObjectsRetrieveParams,
+ OrganizationsProjectsAccessControlMemberPropertiesRetrieveParams,
+ OrganizationsProjectsAccessControlMembersRetrieveParams,
+ OrganizationsProjectsAccessControlRoleObjectsRetrieveParams,
+ OrganizationsProjectsAccessControlRolePropertiesRetrieveParams,
+ OrganizationsProjectsAccessControlRolesRetrieveParams,
PropertyAccessControlRuleApi,
PropertyAccessControlStateApi,
PropertyAccessControlUpdateApi,
@@ -16,6 +27,300 @@ import type {
PropertyAccessControlsRetrieveParams,
} from './api.schemas'
+export const getOrganizationsProjectsAccessControlDefaultObjectsRetrieveUrl = (organizationId: string, id: number) => {
+ return `/api/organizations/${organizationId}/projects/${id}/access_control_default_objects/`
+}
+
+/**
+ * Object rules that apply to everyone in the project without a rule of their own on that object.
+ */
+export const organizationsProjectsAccessControlDefaultObjectsRetrieve = async (
+ organizationId: string,
+ id: number,
+ options?: RequestInit
+): Promise<AccessControlObjectRulesResponseApi> => {
+ return apiMutator<AccessControlObjectRulesResponseApi>(
+ getOrganizationsProjectsAccessControlDefaultObjectsRetrieveUrl(organizationId, id),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
+export const getOrganizationsProjectsAccessControlDefaultPropertiesRetrieveUrl = (
+ organizationId: string,
+ id: number
+) => {
+ return `/api/organizations/${organizationId}/projects/${id}/access_control_default_properties/`
+}
+
+/**
+ * Property rules that apply to everyone in the project without a rule of their own on that property.
+ */
+export const organizationsProjectsAccessControlDefaultPropertiesRetrieve = async (
+ organizationId: string,
+ id: number,
+ options?: RequestInit
+): Promise<AccessControlPropertyRulesResponseApi> => {
+ return apiMutator<AccessControlPropertyRulesResponseApi>(
+ getOrganizationsProjectsAccessControlDefaultPropertiesRetrieveUrl(organizationId, id),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
+export const getOrganizationsProjectsAccessControlDefaultsRetrieveUrl = (organizationId: string, id: number) => {
+ return `/api/organizations/${organizationId}/projects/${id}/access_control_defaults/`
+}
+
+/**
+ * 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.
+ */
+export const organizationsProjectsAccessControlDefaultsRetrieve = async (
+ organizationId: string,
+ id: number,
+ options?: RequestInit
+): Promise<AccessControlDefaultsResponseApi> => {
+ return apiMutator<AccessControlDefaultsResponseApi>(
+ getOrganizationsProjectsAccessControlDefaultsRetrieveUrl(organizationId, id),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
+export const getOrganizationsProjectsAccessControlMemberObjectsRetrieveUrl = (
+ organizationId: string,
+ id: number,
+ params: OrganizationsProjectsAccessControlMemberObjectsRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/organizations/${organizationId}/projects/${id}/access_control_member_objects/?${stringifiedParams}`
+ : `/api/organizations/${organizationId}/projects/${id}/access_control_member_objects/`
+}
+
+/**
+ * Object rules configured for a member: the single objects, for example a dashboard or a notebook, the member is granted or denied, regardless of the resource-level rules.
+ */
+export const organizationsProjectsAccessControlMemberObjectsRetrieve = async (
+ organizationId: string,
+ id: number,
+ params: OrganizationsProjectsAccessControlMemberObjectsRetrieveParams,
+ options?: RequestInit
+): Promise<AccessControlObjectRulesResponseApi> => {
+ return apiMutator<AccessControlObjectRulesResponseApi>(
+ getOrganizationsProjectsAccessControlMemberObjectsRetrieveUrl(organizationId, id, params),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
+export const getOrganizationsProjectsAccessControlMemberPropertiesRetrieveUrl = (
+ organizationId: string,
+ id: number,
+ params: OrganizationsProjectsAccessControlMemberPropertiesRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/organizations/${organizationId}/projects/${id}/access_control_member_properties/?${stringifiedParams}`
+ : `/api/organizations/${organizationId}/projects/${id}/access_control_member_properties/`
+}
+
+/**
+ * Property rules configured for a member: the person and event properties the member can read, read and write, or not see.
+ */
+export const organizationsProjectsAccessControlMemberPropertiesRetrieve = async (
+ organizationId: string,
+ id: number,
+ params: OrganizationsProjectsAccessControlMemberPropertiesRetrieveParams,
+ options?: RequestInit
+): Promise<AccessControlPropertyRulesResponseApi> => {
+ return apiMutator<AccessControlPropertyRulesResponseApi>(
+ getOrganizationsProjectsAccessControlMemberPropertiesRetrieveUrl(organizationId, id, params),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
+export const getOrganizationsProjectsAccessControlMembersRetrieveUrl = (
+ organizationId: string,
+ id: number,
+ params?: OrganizationsProjectsAccessControlMembersRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/organizations/${organizationId}/projects/${id}/access_control_members/?${stringifiedParams}`
+ : `/api/organizations/${organizationId}/projects/${id}/access_control_members/`
+}
+
+/**
+ * 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.
+ */
+export const organizationsProjectsAccessControlMembersRetrieve = async (
+ organizationId: string,
+ id: number,
+ params?: OrganizationsProjectsAccessControlMembersRetrieveParams,
+ options?: RequestInit
+): Promise<AccessControlMembersResponseApi> => {
+ return apiMutator<AccessControlMembersResponseApi>(
+ getOrganizationsProjectsAccessControlMembersRetrieveUrl(organizationId, id, params),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
+export const getOrganizationsProjectsAccessControlRoleObjectsRetrieveUrl = (
+ organizationId: string,
+ id: number,
+ params: OrganizationsProjectsAccessControlRoleObjectsRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/organizations/${organizationId}/projects/${id}/access_control_role_objects/?${stringifiedParams}`
+ : `/api/organizations/${organizationId}/projects/${id}/access_control_role_objects/`
+}
+
+/**
+ * Object rules configured for a role: the single objects the role's members are granted or denied, regardless of the resource-level rules.
+ */
+export const organizationsProjectsAccessControlRoleObjectsRetrieve = async (
+ organizationId: string,
+ id: number,
+ params: OrganizationsProjectsAccessControlRoleObjectsRetrieveParams,
+ options?: RequestInit
+): Promise<AccessControlObjectRulesResponseApi> => {
+ return apiMutator<AccessControlObjectRulesResponseApi>(
+ getOrganizationsProjectsAccessControlRoleObjectsRetrieveUrl(organizationId, id, params),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
+export const getOrganizationsProjectsAccessControlRolePropertiesRetrieveUrl = (
+ organizationId: string,
+ id: number,
+ params: OrganizationsProjectsAccessControlRolePropertiesRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/organizations/${organizationId}/projects/${id}/access_control_role_properties/?${stringifiedParams}`
+ : `/api/organizations/${organizationId}/projects/${id}/access_control_role_properties/`
+}
+
+/**
+ * Property rules configured for a role: the person and event properties the role's members can read, read and write, or not see.
+ */
+export const organizationsProjectsAccessControlRolePropertiesRetrieve = async (
+ organizationId: string,
+ id: number,
+ params: OrganizationsProjectsAccessControlRolePropertiesRetrieveParams,
+ options?: RequestInit
+): Promise<AccessControlPropertyRulesResponseApi> => {
+ return apiMutator<AccessControlPropertyRulesResponseApi>(
+ getOrganizationsProjectsAccessControlRolePropertiesRetrieveUrl(organizationId, id, params),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
+export const getOrganizationsProjectsAccessControlRolesRetrieveUrl = (
+ organizationId: string,
+ id: number,
+ params?: OrganizationsProjectsAccessControlRolesRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/organizations/${organizationId}/projects/${id}/access_control_roles/?${stringifiedParams}`
+ : `/api/organizations/${organizationId}/projects/${id}/access_control_roles/`
+}
+
+/**
+ * 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.
+ */
+export const organizationsProjectsAccessControlRolesRetrieve = async (
+ organizationId: string,
+ id: number,
+ params?: OrganizationsProjectsAccessControlRolesRetrieveParams,
+ options?: RequestInit
+): Promise<AccessControlRolesResponseApi> => {
+ return apiMutator<AccessControlRolesResponseApi>(
+ getOrganizationsProjectsAccessControlRolesRetrieveUrl(organizationId, id, params),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
export const getPropertyAccessControlsRetrieveUrl = (
projectId: string,
params: PropertyAccessControlsRetrieveParams
diff --git a/products/access_control/mcp/tools.yaml b/products/access_control/mcp/tools.yaml
index 7bc0244e2d92..c3fd9872d3a4 100644
--- a/products/access_control/mcp/tools.yaml
+++ b/products/access_control/mcp/tools.yaml
@@ -6,9 +6,258 @@
# All other fields (title, description, enrich_url, etc.) are yours to configure.
category: Access control
feature: access_control
-url_prefix: /
+url_prefix: /settings/environment-access-control
ui_apps: {}
tools:
+ access-control-default-objects-list:
+ operation: organizations_projects_access_control_default_objects_retrieve
+ enabled: true
+ scopes:
+ - access_control:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ list: true
+ title: List the project's object-level default rules
+ description: >
+ Rules on single objects (for example a dashboard, a notebook or a warehouse table) that apply to everyone in
+ the project without a rule of their own on that object. Each rule names the object and the level it sets.
+ param_overrides:
+ id:
+ description: |
+ Project id. If omitted, uses the active project.
+ optional: true
+ fallback: projectId
+ access-control-default-properties-list:
+ operation: organizations_projects_access_control_default_properties_retrieve
+ enabled: true
+ scopes:
+ - access_control:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ list: true
+ title: List the project's property default rules
+ description: >
+ Property rules that apply to everyone in the project without a rule of their own on that property: which
+ person and event properties are hidden (`none`), read-only (`read`), or open (`read_write`). Every property
+ is `read_write` unless a rule says otherwise.
+ param_overrides:
+ id:
+ description: |
+ Project id. If omitted, uses the active project.
+ optional: true
+ fallback: projectId
+ access-control-defaults-get:
+ operation: organizations_projects_access_control_defaults_retrieve
+ enabled: true
+ scopes:
+ - access_control:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ title: Get the project's default access
+ 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.
+ agent_note: >
+ access-control-members-list or access-control-roles-list show who deviates from this baseline.
+ access-control-default-objects-list and access-control-default-properties-list show defaults set on single
+ objects or properties.
+ param_overrides:
+ id:
+ description: |
+ Project id. If omitted, uses the active project.
+ optional: true
+ fallback: projectId
+ response:
+ exclude:
+ - can_edit
+ access-control-member-objects-list:
+ operation: organizations_projects_access_control_member_objects_retrieve
+ enabled: true
+ scopes:
+ - access_control:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ list: true
+ title: List a member's object-level rules
+ description: >
+ The rules configured for a member on single objects, for example a dashboard, a notebook or a warehouse
+ table they are given access to, or blocked from, regardless of their tool-level access. Only the member's
+ own rules are returned. An empty list means the member has no object rules of their own. Their tool-level
+ access still applies.
+ agent_note: >
+ The member's tool-level access and their `role_ids` are on access-control-members-list. Object rules from
+ the member's roles are on access-control-role-objects-list, one call per role 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.
+ access-control-member-properties-list:
+ operation: organizations_projects_access_control_member_properties_retrieve
+ enabled: true
+ scopes:
+ - access_control:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ list: true
+ title: List a member's property rules
+ description: >
+ The property rules configured for a member: which person and event properties they cannot see (`none`), can
+ only read (`read`), or can read and write (`read_write`). Every property is `read_write` unless a rule says
+ otherwise. Only the member's own rules are returned.
+ agent_note: >
+ Property rules from the member's roles are on access-control-role-properties-list, one call per id in the
+ member's `role_ids` from access-control-members-list. Rules for everyone in the project are on
+ access-control-default-properties-list.
+ 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.
+ access-control-members-list:
+ operation: organizations_projects_access_control_members_retrieve
+ enabled: true
+ scopes:
+ - access_control:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ list: true
+ title: Resolve every member's access in the project
+ 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.
+ agent_note: >
+ For a question about one object, for example a dashboard or a table, call
+ access-control-member-objects-list; for a person or event property, access-control-member-properties-list.
+ Rules a role sets on objects or properties are only on the role-objects and role-properties tools. Level
+ bounds per tool are on access-control-defaults-get.
+ param_overrides:
+ id:
+ description: |
+ Project id. If omitted, uses the active project.
+ optional: true
+ fallback: projectId
+ member_id:
+ description: |
+ Optional. Narrow the result to one member, by organization membership id.
+ response:
+ exclude:
+ - project.minimum
+ - project.maximum
+ - resources.*.minimum
+ - resources.*.maximum
+ access-control-role-objects-list:
+ operation: organizations_projects_access_control_role_objects_retrieve
+ enabled: true
+ scopes:
+ - access_control:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ list: true
+ title: List a role's object-level rules
+ description: >
+ The rules configured for a role on single objects, for example a dashboard, a notebook or a warehouse table
+ the role's members are given access to, or blocked from, regardless of their tool-level access.
+ 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 an entry of `role_ids` in
+ access-control-members-list.
+ access-control-role-properties-list:
+ operation: organizations_projects_access_control_role_properties_retrieve
+ enabled: true
+ scopes:
+ - access_control:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ list: true
+ title: List a role's property rules
+ description: >
+ The property rules configured for a role: which person and event properties the role's members cannot see
+ (`none`), can only read (`read`), or can read and write (`read_write`).
+ 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 an entry of `role_ids` in
+ access-control-members-list.
+ access-control-roles-list:
+ operation: organizations_projects_access_control_roles_retrieve
+ enabled: true
+ scopes:
+ - access_control:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ list: true
+ title: Resolve every role's access in the project
+ 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.
+ agent_note: >
+ A member's enforced level already includes their roles, so for a person use access-control-members-list. For
+ a role's rules on one object or property, call access-control-role-objects-list or
+ access-control-role-properties-list. A member's roles are `role_ids` on access-control-members-list, and
+ role-members-list gives who is in a role.
+ param_overrides:
+ id:
+ description: |
+ Project id. If omitted, uses the active project.
+ optional: true
+ fallback: projectId
+ role_id:
+ description: |
+ Optional. Narrow the result to one role, by role id.
+ response:
+ exclude:
+ - project.minimum
+ - project.maximum
+ - resources.*.minimum
+ - resources.*.maximum
property-access-controls-create:
operation: property_access_controls_create
enabled: false
diff --git a/products/access_control/skills/checking-member-access/SKILL.md b/products/access_control/skills/checking-member-access/SKILL.md
new file mode 100644
index 000000000000..7baaede51d7e
--- /dev/null
+++ b/products/access_control/skills/checking-member-access/SKILL.md
@@ -0,0 +1,147 @@
+---
+name: checking-member-access
+description: >
+ Explains what a member or a role can do in a PostHog project, using the access control MCP tools.
+ Use when the user asks what someone can see or edit, who can edit dashboards or feature flags, why a
+ member can or cannot open a dashboard, notebook or table, what a role grants, which properties are hidden
+ from someone, or how the project's default access is set. Covers what each level means, how the stored
+ rule, the enforced level and the inherited access relate, what the null values mean, which tool answers
+ which question, and when the answer needs the role tools too.
+---
+
+# Checking member access
+
+Use this skill to answer "what can this person do here?" from the access control tools. The tools return
+the enforced level and where it comes from. This skill is for reading them correctly.
+
+## When to use this skill
+
+- "What can this member do in this project?" / "Can this member edit feature flags?"
+- "Who can edit dashboards?" / "Who has no access to experiments?"
+- "Why can't this member open this dashboard?" / "Which tables is this role restricted from?"
+- "Which properties are hidden from the support role?"
+- "What does the `analyst` role grant?" / "What is the default access in this project?"
+
+Not for changing rules. The read tools cannot write, and the settings page is where rules are edited.
+
+## Plan availability
+
+- Free and pay-as-you-go plans have no access control. Every level resolves to the PostHog default with
+ `source` `system_default`, and any rule the tools return has no effect. Say so, and stop.
+- Boost and Scale include the default levels and rules for single members on the project, on tools, on
+ objects and on properties.
+- Roles exist on every plan, but role rules count for access only on Enterprise. On other plans a role
+ rule the tools return has no effect, and a member's roles never change the enforced level.
+- The tools do not say which plan the organization is on. A `source_subject` of `role` anywhere in a
+ `members-list` result proves that role rules count. Without that, ask the user whether the organization
+ is on Enterprise before walking roles in step 4 of the workflow.
+
+## How access resolves
+
+- **Scopes.** The project itself, then each tool (`dashboard`, `insight`, `feature_flag`, `notebook`,
+ `experiment`, `warehouse_objects`, and so on), then single objects inside a tool, then person and event
+ properties. The tool names are the keys of `resources` in a members-list entry.
+- **Project levels.** `member` can view and edit the resources their other rules permit. `admin` can also
+ edit project settings, manage the project's access rules, and delete the project.
+- **Tool and object levels.** `none` cannot view. `viewer` can view but not change. `editor` can view and
+ change. `manager` can also manage the access rules of the tool or object. Order: `none` < `viewer` <
+ `editor` < `manager`.
+- **Property levels.** `none` hides the property. `read` shows it. `read_write` also allows edits. Every
+ property is `read_write` unless a rule exists.
+- **Bounds.** `minimum` and `maximum` per tool, on `defaults-get`, are the levels a rule can set. A tool
+ with `minimum` `viewer` can never be set to `none`.
+- **Subjects.** A rule belongs to one member, one role, or everyone in the project (the default).
+- **Organization admins and owners** have full access to everything in every project. No rule applies to
+ them. `organization_level` is a number: 1 member, 8 admin, 15 owner.
+- **Creators** have full access to the objects they created, and only those. A member with `viewer` on
+ dashboards can still edit the dashboard they created, and cannot edit the others.
+- **Two resolution modes.** Organizations resolve rules either most-specific-first (member rule, then
+ role rules, then default, and object rule before tool rule) or legacy (the highest of the member's own
+ rule and role rules wins). The tools do not say which mode applies. The server already applied it. So
+ **trust `effective_access_level` and never recompute it from the stored rules.** If the user asks why,
+ explain from `inherited_access`, not from your own precedence.
+
+## Available tools
+
+| Tool | Returns |
+| ------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
+| `posthog:access-control-members-list` | Every member's enforced access to the project and to each tool. `member_id` narrows to a member. |
+| `posthog:access-control-roles-list` | The same per role. `role_id` narrows to a role. |
+| `posthog:access-control-defaults-get` | The project baseline, and which tools accept rules on single objects. |
+| `posthog:access-control-member-objects-list` | The object rules set for a member: every object with a rule for that member. |
+| `posthog:access-control-member-properties-list` | The property rules set for a member. |
+| `posthog:access-control-role-objects-list` | The object rules set for a role. |
+| `posthog:access-control-role-properties-list` | The property rules set for a role. |
+| `posthog:access-control-default-objects-list` | The object rules that apply to everyone in the project. |
+| `posthog:access-control-default-properties-list` | The property rules that apply to everyone in the project. |
+| `posthog:org-members-list` | Membership ids, names and organization levels. No project access details. |
+| `posthog:roles-list`, `posthog:role-members-list` | Role names by id, and who is in a role. |
+
+All access control tools take an optional project id and default to the active project.
+
+## Workflow
+
+1. **Find the subject id.** `member_id` is the organization membership id: the `id` from
+ `org-members-list`, or `organization_membership_id` from `members-list`. It is not the user id and not
+ the user uuid. `role_id` is the `id` from `roles-list`.
+2. **Tool-level questions need one call.** "Can this member view dashboards?" or "What access to feature
+ flags does this member have?" is `members-list` with `member_id`. `effective_access_level` for that tool
+ is the complete answer. It already includes the member's roles, the project default and the bypasses.
+3. **Explain the level from `inherited_access`.** See the table below. Only mention the stored
+ `access_level` when it differs from the enforced level.
+4. **Object questions need the object and its rules.** "Can this member open dashboard 42?" cannot be
+ answered from the tool level alone. Check in this order, and stop at the first hit:
+ 1. `organization_level` is 8 or 15 on the member's entry: full access, no rule applies.
+ 2. The member created the object: full access, no rule applies. The rule tools do not say who created
+ an object, so fetch it with its own get tool, for example `dashboard-get` or `insight-get`, and
+ compare `created_by.uuid` with `user.uuid` on the member's entry.
+ 3. A rule on that object. The member tools return only the rules set for that member, so collect
+ `member-objects-list`, `role-objects-list` for each id in the member's `role_ids`, and
+ `default-objects-list`, and pick out the rows for this object. Tell the user how many roles you
+ would walk and ask before doing it for a member in many roles.
+ 4. No rule on the object: the tool-level answer from step 2 applies.
+5. **Several rules on one object.** When the member, a role and the default each set a level on the
+ same object, the server picks one by the organization's resolution mode, and no tool returns that
+ pick for another member. Report every rule you found with its subject, say the enforced one depends
+ on the mode, and do not guess. Property questions work like step 4 with the properties tools, minus
+ the creator check, since properties have no creator.
+6. **"Who can ..." questions** are `members-list` without `member_id`, filtered on
+ `resources.<tool>.effective_access_level`. The response is every member times every tool and has no
+ pagination. For a large organization, ask which people the user cares about first, or answer per
+ member.
+
+## Reading one entry
+
+| Field | Meaning |
+| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `access_level` | The subject's own stored rule for this scope. `null` means no rule of its own. |
+| `effective_access_level` | What is enforced. `null` means nothing resolves for this scope. It is not "no access". |
+| `inherited_access` | The level the subject falls back to without a rule of its own, and where it comes from. `null` when nothing supplies one. |
+| `inherited_access.source` | `resource` or `parent_resource` for a tool rule, `object` or `parent_object` for an object rule, `system_default` for the PostHog default. `org_admin` and `creator` are the bypasses described above. `org_membership` appears only when the object is the organization itself. |
+| `inherited_access.source_subject` | `member`, `role` or `default`: whose rule supplied it. `null` when a bypass or the PostHog default did. |
+
+How to phrase the answer:
+
+- `source` is `org_admin`: "This member is an organization admin and has full access to everything." The
+ stored rules do not apply to them.
+- `access_level` is set and equals `effective_access_level`: "This member has an explicit rule: editor."
+- `access_level` is `null` and `source_subject` is `role`: "This member has editor access, based on a role."
+ The role's name is not in the entry; `roles-list` has it if the user wants it.
+- `access_level` is `null` and `source_subject` is `default`: "This member has viewer access, based on the
+ project default."
+- `source` is `system_default`: "No rule is set anywhere, so the PostHog default applies."
+- `effective_access_level` is `null`: "Nothing resolves for this tool here." Do not read it as no access.
+
+## Gotchas
+
+- An empty object or property list means no rules of that kind, not no access. The tool-level entry
+ still applies.
+- A member missing from `members-list` is not proof of no access. A caller who is not an organization
+ admin, in an organization where members cannot see each other, only sees members with project-scoped
+ access.
+- `can_edit` on the members and roles lists describes the caller, not the subject: whether the person
+ running the tool may change rules.
+- `available_project_levels` and `available_resource_levels` are the vocabulary, lowest first. Use them
+ to compare levels instead of assuming an order.
+- `object_rule_resources` on `defaults-get` lists the tools that accept rules on single objects. A tool
+ not in that list has no object rules to look for.
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 80b79182d7d9..10df7d49833d 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -1,4 +1,130 @@
{
+ "access-control-default-objects-list": {
+ "description": "Rules on single objects (for example a dashboard, a notebook or a warehouse table) that apply to everyone in the project without a rule of their own on that object. Each rule names the object and the level it sets.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List the project's object-level default rules",
+ "title": "List the project's object-level default rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "access-control-default-properties-list": {
+ "description": "Property rules that apply to everyone in the project without a rule of their own on that property: which person and event properties are hidden (`none`), read-only (`read`), or open (`read_write`). Every property is `read_write` unless a rule says otherwise.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List the project's property default rules",
+ "title": "List the project's property default rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "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",
+ "feature": "access_control",
+ "summary": "Get the project's default access",
+ "title": "Get the project's default access",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "access-control-member-objects-list": {
+ "description": "The rules configured for a member on single objects, for example a dashboard, a notebook or a warehouse table they are given access to, or blocked from, regardless of their tool-level access. Only the member's own rules are returned. An empty list means the member has no object rules of their own. Their tool-level access still applies.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List a member's object-level rules",
+ "title": "List a member's object-level rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "access-control-member-properties-list": {
+ "description": "The property rules configured for a member: which person and event properties they cannot see (`none`), can only read (`read`), or can read and write (`read_write`). Every property is `read_write` unless a rule says otherwise. Only the member's own rules are returned.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List a member's property rules",
+ "title": "List a member's property rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "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",
+ "feature": "access_control",
+ "summary": "Resolve every member's access in the project",
+ "title": "Resolve every member's access in the project",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "access-control-role-objects-list": {
+ "description": "The rules configured for a role on single objects, for example a dashboard, a notebook or a warehouse table the role's members are given access to, or blocked from, regardless of their tool-level access.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List a role's object-level rules",
+ "title": "List a role's object-level rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "access-control-role-properties-list": {
+ "description": "The property rules configured for a role: which person and event properties the role's members cannot see (`none`), can only read (`read`), or can read and write (`read_write`).",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List a role's property rules",
+ "title": "List a role's property rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "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",
+ "feature": "access_control",
+ "summary": "Resolve every role's access in the project",
+ "title": "Resolve every role's access in the project",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
"account-relationship-definitions-create": {
"description": "Create a Customer Analytics account relationship definition — a team-defined relationship type between a PostHog user and an account, such as CSM or Onboarding manager. Provide `name` (required, unique within the team), optional `description` explaining what the relationship means, and `is_single_holder` (default true) controlling whether only one user can hold the relationship per account at a time. Definitions are team-scoped and shared across all accounts; assign a user to a specific account with `accounts-relationships-create`.",
"category": "Customer analytics",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index a4b0a12d62f9..a4aba32e7db9 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -1,4 +1,130 @@
{
+ "access-control-default-objects-list": {
+ "description": "Rules on single objects (for example a dashboard, a notebook or a warehouse table) that apply to everyone in the project without a rule of their own on that object. Each rule names the object and the level it sets.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List the project's object-level default rules",
+ "title": "List the project's object-level default rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "access-control-default-properties-list": {
+ "description": "Property rules that apply to everyone in the project without a rule of their own on that property: which person and event properties are hidden (`none`), read-only (`read`), or open (`read_write`). Every property is `read_write` unless a rule says otherwise.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List the project's property default rules",
+ "title": "List the project's property default rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "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",
+ "feature": "access_control",
+ "summary": "Get the project's default access",
+ "title": "Get the project's default access",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "access-control-member-objects-list": {
+ "description": "The rules configured for a member on single objects, for example a dashboard, a notebook or a warehouse table they are given access to, or blocked from, regardless of their tool-level access. Only the member's own rules are returned. An empty list means the member has no object rules of their own. Their tool-level access still applies.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List a member's object-level rules",
+ "title": "List a member's object-level rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "access-control-member-properties-list": {
+ "description": "The property rules configured for a member: which person and event properties they cannot see (`none`), can only read (`read`), or can read and write (`read_write`). Every property is `read_write` unless a rule says otherwise. Only the member's own rules are returned.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List a member's property rules",
+ "title": "List a member's property rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "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",
+ "feature": "access_control",
+ "summary": "Resolve every member's access in the project",
+ "title": "Resolve every member's access in the project",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "access-control-role-objects-list": {
+ "description": "The rules configured for a role on single objects, for example a dashboard, a notebook or a warehouse table the role's members are given access to, or blocked from, regardless of their tool-level access.",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List a role's object-level rules",
+ "title": "List a role's object-level rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "access-control-role-properties-list": {
+ "description": "The property rules configured for a role: which person and event properties the role's members cannot see (`none`), can only read (`read`), or can read and write (`read_write`).",
+ "category": "Access control",
+ "feature": "access_control",
+ "summary": "List a role's property rules",
+ "title": "List a role's property rules",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "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",
+ "feature": "access_control",
+ "summary": "Resolve every role's access in the project",
+ "title": "Resolve every role's access in the project",
+ "required_scopes": ["access_control:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
"account-relationship-definitions-create": {
"description": "Create a Customer Analytics account relationship definition — a team-defined relationship type between a PostHog user and an account, such as CSM or Onboarding manager. Provide `name` (required, unique within the team), optional `description` explaining what the relationship means, and `is_single_holder` (default true) controlling whether only one user can hold the relationship per account at a time. Definitions are team-scoped and shared across all accounts; assign a user to a specific account with `accounts-relationships-create`.",
"category": "Customer analytics",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index ca3f2ad2e9ce..41c2a52404ac 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -134,6 +134,50 @@ export namespace Schemas {
human_readable_error?: string | null;
}
+ export interface AccessControlResourceDefault {
+ /**
+ * The stored default level for this resource type. Null when the PostHog default applies.
+ * @nullable
+ */
+ access_level: string | null;
+ /** The lowest level this resource type allows. */
+ minimum: string;
+ /** The highest level this resource type allows. */
+ maximum: string;
+ }
+
+ /**
+ * The default level per resource type, keyed by resource name.
+ */
+ export type AccessControlDefaultsResponseResourceAccessLevels = {[key: string]: AccessControlResourceDefault};
+
+ export interface AccessControlObjectRuleResource {
+ /** A resource type that supports rules on single objects. */
+ resource: string;
+ /** The levels an object rule on this resource type accepts, lowest first. */
+ available_access_levels: string[];
+ /** The lowest level an object rule on this resource can set. */
+ minimum_access_level: string;
+ }
+
+ /**
+ * The project's defaults: what everyone without a rule of their own gets.
+ */
+ export interface AccessControlDefaultsResponse {
+ /** The project access levels, lowest first. */
+ available_project_levels: string[];
+ /** The resource access levels, lowest first. */
+ available_resource_levels: string[];
+ /** Whether the caller may change access rules in this project. */
+ can_edit: boolean;
+ /** The default project access level for members. */
+ project_access_level: string;
+ /** The default level per resource type, keyed by resource name. */
+ resource_access_levels: AccessControlDefaultsResponseResourceAccessLevels;
+ /** The resource types that accept rules on single objects, with the levels each accepts. */
+ object_rule_resources: AccessControlObjectRuleResource[];
+ }
+
export interface AccessControlFilterWarning {
/** Human-readable warning shown to the user */
message: string;
@@ -155,6 +199,235 @@ export namespace Schemas {
Manager: 'manager',
} as const;
+ /**
+ * * `object` - object
+ * * `parent_object` - parent_object
+ * * `resource` - resource
+ * * `parent_resource` - parent_resource
+ * * `system_default` - system_default
+ * * `org_admin` - org_admin
+ * * `creator` - creator
+ * * `org_membership` - org_membership
+ */
+ export type ResolvedAccessSourceEnum = typeof ResolvedAccessSourceEnum[keyof typeof ResolvedAccessSourceEnum];
+
+
+ export const ResolvedAccessSourceEnum = {
+ Object: 'object',
+ ParentObject: 'parent_object',
+ Resource: 'resource',
+ ParentResource: 'parent_resource',
+ SystemDefault: 'system_default',
+ OrgAdmin: 'org_admin',
+ Creator: 'creator',
+ OrgMembership: 'org_membership',
+ } as const;
+
+ /**
+ * * `member` - member
+ * * `role` - role
+ * * `default` - default
+ */
+ export type ResolvedAccessSourceSubjectEnum = typeof ResolvedAccessSourceSubjectEnum[keyof typeof ResolvedAccessSourceSubjectEnum];
+
+
+ export const ResolvedAccessSourceSubjectEnum = {
+ Member: 'member',
+ Role: 'role',
+ Default: 'default',
+ } as const;
+
+ /**
+ * A resolved access level with the rule that supplied it — the wire form of `ResolvedAccess`.
+ */
+ export interface ResolvedAccess {
+ /** The access level that applies. */
+ access_level: string;
+ /** How the level was derived: a rule on the object, its parent object, the resource, the parent resource, the PostHog default, an organization admin's or a creator's full access, or organization membership when the object is the organization itself.
+ *
+ * * `object` - object
+ * * `parent_object` - parent_object
+ * * `resource` - resource
+ * * `parent_resource` - parent_resource
+ * * `system_default` - system_default
+ * * `org_admin` - org_admin
+ * * `creator` - creator
+ * * `org_membership` - org_membership */
+ source: ResolvedAccessSourceEnum;
+ /** Whose rule decided: a member's own, a role's, or the default for everyone in the project. Null when no rule did.
+ *
+ * * `member` - member
+ * * `role` - role
+ * * `default` - default */
+ source_subject: ResolvedAccessSourceSubjectEnum | null;
+ /** The resource the deciding rule belongs to. */
+ source_resource: string;
+ /**
+ * The deciding rule's object id, when it is an object-level rule (e.g. the source a table inherits from).
+ * @nullable
+ */
+ source_resource_id: string | null;
+ }
+
+ /**
+ * One subject's access to one scope (the project, or a whole resource type): what is stored,
+ * what is enforced, and where the enforced level comes from.
+ */
+ export interface SubjectAccessEntry {
+ /**
+ * The subject's own stored rule for this scope. Null when the subject has no rule of its own here.
+ * @nullable
+ */
+ access_level: string | null;
+ /**
+ * The level that is enforced for the subject after defaults, roles and bypasses are resolved. Null when nothing resolves for this scope.
+ * @nullable
+ */
+ effective_access_level: string | null;
+ /** The level the subject falls back to without a rule of its own, with the rule that supplies it. Read `source` and `source_subject` to tell a role rule from the project default, or an organization admin's full access. */
+ inherited_access: ResolvedAccess | null;
+ /** The lowest level this scope allows. */
+ minimum: string;
+ /** The highest level this scope allows. */
+ maximum: string;
+ }
+
+ /**
+ * Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`).
+ */
+ export type AccessControlMemberAccessResources = {[key: string]: SubjectAccessEntry};
+
+ export interface AccessControlMemberUser {
+ /** The user's UUID. */
+ uuid: string;
+ /** The user's first name. */
+ first_name: string;
+ /** The user's last name. */
+ last_name: string;
+ /** The user's email. */
+ email: string;
+ }
+
+ /**
+ * * `1` - member
+ * * `8` - administrator
+ * * `15` - owner
+ */
+ export type OrganizationMembershipLevelEnum = typeof OrganizationMembershipLevelEnum[keyof typeof OrganizationMembershipLevelEnum];
+
+
+ export const OrganizationMembershipLevelEnum = {
+ Number1: 1,
+ Number8: 8,
+ Number15: 15,
+ } as const;
+
+ /**
+ * A member's resolved access to the project and to every resource type in it.
+ */
+ export interface AccessControlMemberAccess {
+ /** The organization membership id. Use it as `member_id` on the member rule endpoints. */
+ organization_membership_id: string;
+ /** The member's identity. */
+ user: AccessControlMemberUser;
+ /** The member's organization level: 1 member, 8 admin, 15 owner. Admins and owners have full access to everything.
+ *
+ * * `1` - member
+ * * `8` - administrator
+ * * `15` - owner */
+ organization_level: OrganizationMembershipLevelEnum;
+ /** The roles the member is in. Use them as `role_id` on the role rule endpoints. */
+ role_ids: string[];
+ /** Access to the project itself. */
+ project: SubjectAccessEntry;
+ /** Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`). */
+ resources: AccessControlMemberAccessResources;
+ }
+
+ export interface AccessControlMembersResponse {
+ /** The project access levels, lowest first. */
+ available_project_levels: string[];
+ /** The resource access levels, lowest first. */
+ available_resource_levels: string[];
+ /** Whether the caller may change access rules in this project. */
+ can_edit: boolean;
+ /** One entry per organization member. */
+ results: AccessControlMemberAccess[];
+ }
+
+ /**
+ * A stored rule on one object, as configured for a subject.
+ */
+ export interface AccessControlObjectRule {
+ /** The object's resource type, for example `dashboard`. */
+ resource: string;
+ /** The object's primary key. */
+ resource_id: string;
+ /** The object's display name. Falls back to the id when it has no name. */
+ name: string;
+ /**
+ * The object's short id, for models that link by one (insights, notebooks).
+ * @nullable
+ */
+ short_id: string | null;
+ /** The level the rule grants or restricts to. */
+ access_level: string;
+ }
+
+ export interface AccessControlObjectRulesResponse {
+ /** The subject's object rules, sorted by resource and name. */
+ results: AccessControlObjectRule[];
+ }
+
+ /**
+ * A stored rule on one property definition, as configured for a subject.
+ */
+ export interface AccessControlPropertyRule {
+ /** The property definition id. */
+ property_definition_id: string;
+ /** The property name. */
+ property: string;
+ /** Whether the property is a `person` or an `event` property. */
+ property_type: string;
+ /** The rule's level: `none`, `read` or `read_write`. */
+ access_level: string;
+ }
+
+ export interface AccessControlPropertyRulesResponse {
+ /** The subject's property rules, sorted by property type and name. */
+ results: AccessControlPropertyRule[];
+ }
+
+ /**
+ * Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`).
+ */
+ export type AccessControlRoleAccessResources = {[key: string]: SubjectAccessEntry};
+
+ /**
+ * A role's resolved access to the project and to every resource type in it.
+ */
+ export interface AccessControlRoleAccess {
+ /** The role id. Use it as `role_id` on the role rule endpoints. */
+ role_id: string;
+ /** The role's name. */
+ role_name: string;
+ /** Access to the project itself. */
+ project: SubjectAccessEntry;
+ /** Access per resource type, keyed by resource name (for example `dashboard`, `feature_flag`). */
+ resources: AccessControlRoleAccessResources;
+ }
+
+ export interface AccessControlRolesResponse {
+ /** The project access levels, lowest first. */
+ available_project_levels: string[];
+ /** The resource access levels, lowest first. */
+ available_resource_levels: string[];
+ /** Whether the caller may change access rules in this project. */
+ can_edit: boolean;
+ /** One entry per role in the organization. */
+ results: AccessControlRoleAccess[];
+ }
+
/**
* * `read_write` - read_write
* * `read` - read
@@ -54494,20 +54767,6 @@ export namespace Schemas {
export type OrganizationMetadata = {[key: string]: string};
- /**
- * * `1` - member
- * * `8` - administrator
- * * `15` - owner
- */
- export type OrganizationMembershipLevelEnum = typeof OrganizationMembershipLevelEnum[keyof typeof OrganizationMembershipLevelEnum];
-
-
- export const OrganizationMembershipLevelEnum = {
- Number1: 1,
- Number8: 8,
- Number15: 15,
- } as const;
-
/**
* * `0` - none
* * `3` - config
@@ -92594,6 +92853,48 @@ export namespace Schemas {
Any: 'any',
} as const;
+ export type OrganizationsProjectsAccessControlMemberObjectsRetrieveParams = {
+ /**
+ * The organization membership id, as `organization_membership_id` in the members endpoint.
+ */
+ member_id: string;
+ };
+
+ export type OrganizationsProjectsAccessControlMemberPropertiesRetrieveParams = {
+ /**
+ * The organization membership id, as `organization_membership_id` in the members endpoint.
+ */
+ member_id: string;
+ };
+
+ export type OrganizationsProjectsAccessControlMembersRetrieveParams = {
+ /**
+ * Narrow the list to one organization membership id.
+ */
+ member_id?: string;
+ };
+
+ export type OrganizationsProjectsAccessControlRoleObjectsRetrieveParams = {
+ /**
+ * The role id, as `role_id` in the roles endpoint.
+ */
+ role_id: string;
+ };
+
+ export type OrganizationsProjectsAccessControlRolePropertiesRetrieveParams = {
+ /**
+ * The role id, as `role_id` in the roles endpoint.
+ */
+ role_id: string;
+ };
+
+ export type OrganizationsProjectsAccessControlRolesRetrieveParams = {
+ /**
+ * Narrow the list to one role.
+ */
+ role_id?: string;
+ };
+
export type OrganizationsProjectsEvaluationContextSuggestionsDestroyParams = {
/**
* Name of the evaluation context to restore to suggestions.
diff --git a/services/mcp/src/generated/access_control/api.ts b/services/mcp/src/generated/access_control/api.ts
new file mode 100644
index 000000000000..eebd9dc3aef4
--- /dev/null
+++ b/services/mcp/src/generated/access_control/api.ts
@@ -0,0 +1,208 @@
+/**
+ * Auto-generated from the Django backend OpenAPI schema.
+ * MCP service uses these Zod schemas for generated tool handlers.
+ * To regenerate: hogli build:openapi
+ *
+ * PostHog API - MCP 9 enabled ops
+ * OpenAPI spec version: 1.0.0
+ */
+import * as zod from 'zod'
+
+/**
+ * Object rules that apply to everyone in the project without a rule of their own on that object.
+ */
+export const organizationsProjectsAccessControlDefaultObjectsRetrievePathIdMin = -2147483648
+export const organizationsProjectsAccessControlDefaultObjectsRetrievePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlDefaultObjectsRetrieveParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlDefaultObjectsRetrievePathIdMin)
+ .max(organizationsProjectsAccessControlDefaultObjectsRetrievePathIdMax)
+ .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\/."
+ ),
+})
+
+/**
+ * Property rules that apply to everyone in the project without a rule of their own on that property.
+ */
+export const organizationsProjectsAccessControlDefaultPropertiesRetrievePathIdMin = -2147483648
+export const organizationsProjectsAccessControlDefaultPropertiesRetrievePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlDefaultPropertiesRetrieveParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlDefaultPropertiesRetrievePathIdMin)
+ .max(organizationsProjectsAccessControlDefaultPropertiesRetrievePathIdMax)
+ .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\/."
+ ),
+})
+
+/**
+ * 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.
+ */
+export const organizationsProjectsAccessControlDefaultsRetrievePathIdMin = -2147483648
+export const organizationsProjectsAccessControlDefaultsRetrievePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlDefaultsRetrieveParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlDefaultsRetrievePathIdMin)
+ .max(organizationsProjectsAccessControlDefaultsRetrievePathIdMax)
+ .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\/."
+ ),
+})
+
+/**
+ * Object rules configured for a member: the single objects, for example a dashboard or a notebook, the member is granted or denied, regardless of the resource-level rules.
+ */
+export const organizationsProjectsAccessControlMemberObjectsRetrievePathIdMin = -2147483648
+export const organizationsProjectsAccessControlMemberObjectsRetrievePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlMemberObjectsRetrieveParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlMemberObjectsRetrievePathIdMin)
+ .max(organizationsProjectsAccessControlMemberObjectsRetrievePathIdMax)
+ .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 OrganizationsProjectsAccessControlMemberObjectsRetrieveQueryParams = () => zod.object({
+ member_id: zod
+ .string()
+ .describe('The organization membership id, as `organization_membership_id` in the members endpoint.'),
+})
+
+/**
+ * Property rules configured for a member: the person and event properties the member can read, read and write, or not see.
+ */
+export const organizationsProjectsAccessControlMemberPropertiesRetrievePathIdMin = -2147483648
+export const organizationsProjectsAccessControlMemberPropertiesRetrievePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlMemberPropertiesRetrieveParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlMemberPropertiesRetrievePathIdMin)
+ .max(organizationsProjectsAccessControlMemberPropertiesRetrievePathIdMax)
+ .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 OrganizationsProjectsAccessControlMemberPropertiesRetrieveQueryParams = () => zod.object({
+ member_id: zod
+ .string()
+ .describe('The organization membership id, as `organization_membership_id` in the members endpoint.'),
+})
+
+/**
+ * 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.
+ */
+export const organizationsProjectsAccessControlMembersRetrievePathIdMin = -2147483648
+export const organizationsProjectsAccessControlMembersRetrievePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlMembersRetrieveParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlMembersRetrievePathIdMin)
+ .max(organizationsProjectsAccessControlMembersRetrievePathIdMax)
+ .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 OrganizationsProjectsAccessControlMembersRetrieveQueryParams = () => zod.object({
+ member_id: zod.string().optional().describe('Narrow the list to one organization membership id.'),
+})
+
+/**
+ * Object rules configured for a role: the single objects the role's members are granted or denied, regardless of the resource-level rules.
+ */
+export const organizationsProjectsAccessControlRoleObjectsRetrievePathIdMin = -2147483648
+export const organizationsProjectsAccessControlRoleObjectsRetrievePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlRoleObjectsRetrieveParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlRoleObjectsRetrievePathIdMin)
+ .max(organizationsProjectsAccessControlRoleObjectsRetrievePathIdMax)
+ .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 OrganizationsProjectsAccessControlRoleObjectsRetrieveQueryParams = () => zod.object({
+ role_id: zod.string().describe('The role id, as `role_id` in the roles endpoint.'),
+})
+
+/**
+ * Property rules configured for a role: the person and event properties the role's members can read, read and write, or not see.
+ */
+export const organizationsProjectsAccessControlRolePropertiesRetrievePathIdMin = -2147483648
+export const organizationsProjectsAccessControlRolePropertiesRetrievePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlRolePropertiesRetrieveParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlRolePropertiesRetrievePathIdMin)
+ .max(organizationsProjectsAccessControlRolePropertiesRetrievePathIdMax)
+ .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 OrganizationsProjectsAccessControlRolePropertiesRetrieveQueryParams = () => zod.object({
+ role_id: zod.string().describe('The role id, as `role_id` in the roles endpoint.'),
+})
+
+/**
+ * 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.
+ */
+export const organizationsProjectsAccessControlRolesRetrievePathIdMin = -2147483648
+export const organizationsProjectsAccessControlRolesRetrievePathIdMax = 2147483647
+
+export const OrganizationsProjectsAccessControlRolesRetrieveParams = () => zod.object({
+ id: zod
+ .number()
+ .min(organizationsProjectsAccessControlRolesRetrievePathIdMin)
+ .max(organizationsProjectsAccessControlRolesRetrievePathIdMax)
+ .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 OrganizationsProjectsAccessControlRolesRetrieveQueryParams = () => zod.object({
+ role_id: zod.string().optional().describe('Narrow the list to one role.'),
+})
diff --git a/services/mcp/src/tools/generated/access_control.ts b/services/mcp/src/tools/generated/access_control.ts
new file mode 100644
index 000000000000..0477a7afe0b0
--- /dev/null
+++ b/services/mcp/src/tools/generated/access_control.ts
@@ -0,0 +1,395 @@
+// AUTO-GENERATED from products/access_control/mcp/tools.yaml + OpenAPI — do not edit
+import { z } from 'zod'
+
+import type { Schemas } from '@/api/generated'
+import * as orvalSchemas from '@/generated/access_control/api'
+import {
+ withPostHogUrl,
+ withAgentNote,
+ omitResponseFields,
+ type WithPostHogUrl,
+ type WithAgentNote,
+} from '@/tools/tool-utils'
+import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
+
+const AccessControlDefaultObjectsListSchema = () => {
+ const OrganizationsProjectsAccessControlDefaultObjectsRetrieveParams =
+ orvalSchemas.OrganizationsProjectsAccessControlDefaultObjectsRetrieveParams()
+ return OrganizationsProjectsAccessControlDefaultObjectsRetrieveParams.omit({ organization_id: true }).extend({
+ id: OrganizationsProjectsAccessControlDefaultObjectsRetrieveParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ })
+}
+
+const accessControlDefaultObjectsList = (): ToolBase<
+ ReturnType<typeof AccessControlDefaultObjectsListSchema>,
+ WithPostHogUrl<Schemas.AccessControlObjectRulesResponse>
+> => ({
+ name: 'access-control-default-objects-list',
+ schema: AccessControlDefaultObjectsListSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlDefaultObjectsListSchema>>) => {
+ const orgId = 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.')
+ }
+ const result = await context.api.request<Schemas.AccessControlObjectRulesResponse>({
+ method: 'GET',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_default_objects/`,
+ })
+ return await withPostHogUrl(context, result, '/settings/environment-access-control')
+ },
+})
+
+const AccessControlDefaultPropertiesListSchema = () => {
+ const OrganizationsProjectsAccessControlDefaultPropertiesRetrieveParams =
+ orvalSchemas.OrganizationsProjectsAccessControlDefaultPropertiesRetrieveParams()
+ return OrganizationsProjectsAccessControlDefaultPropertiesRetrieveParams.omit({ organization_id: true }).extend({
+ id: OrganizationsProjectsAccessControlDefaultPropertiesRetrieveParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ })
+}
+
+const accessControlDefaultPropertiesList = (): ToolBase<
+ ReturnType<typeof AccessControlDefaultPropertiesListSchema>,
+ WithPostHogUrl<Schemas.AccessControlPropertyRulesResponse>
+> => ({
+ name: 'access-control-default-properties-list',
+ schema: AccessControlDefaultPropertiesListSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlDefaultPropertiesListSchema>>) => {
+ const orgId = 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.')
+ }
+ const result = await context.api.request<Schemas.AccessControlPropertyRulesResponse>({
+ method: 'GET',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_default_properties/`,
+ })
+ return await withPostHogUrl(context, result, '/settings/environment-access-control')
+ },
+})
+
+const AccessControlDefaultsGetSchema = () => {
+ const OrganizationsProjectsAccessControlDefaultsRetrieveParams =
+ orvalSchemas.OrganizationsProjectsAccessControlDefaultsRetrieveParams()
+ return OrganizationsProjectsAccessControlDefaultsRetrieveParams.omit({ organization_id: true }).extend({
+ id: OrganizationsProjectsAccessControlDefaultsRetrieveParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ })
+}
+
+const accessControlDefaultsGet = (): ToolBase<
+ ReturnType<typeof AccessControlDefaultsGetSchema>,
+ WithAgentNote<Schemas.AccessControlDefaultsResponse>
+> => ({
+ name: 'access-control-defaults-get',
+ schema: AccessControlDefaultsGetSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlDefaultsGetSchema>>) => {
+ const orgId = 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.')
+ }
+ const result = await context.api.request<Schemas.AccessControlDefaultsResponse>({
+ method: 'GET',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_defaults/`,
+ })
+ const filtered = omitResponseFields(result, ['can_edit']) as typeof result
+ return withAgentNote(
+ filtered,
+ 'access-control-members-list or access-control-roles-list show who deviates from this baseline. access-control-default-objects-list and access-control-default-properties-list show defaults set on single objects or properties.\n'
+ )
+ },
+})
+
+const AccessControlMemberObjectsListSchema = () => {
+ const OrganizationsProjectsAccessControlMemberObjectsRetrieveParams =
+ orvalSchemas.OrganizationsProjectsAccessControlMemberObjectsRetrieveParams()
+ const OrganizationsProjectsAccessControlMemberObjectsRetrieveQueryParams =
+ orvalSchemas.OrganizationsProjectsAccessControlMemberObjectsRetrieveQueryParams()
+ return OrganizationsProjectsAccessControlMemberObjectsRetrieveParams.omit({ organization_id: true })
+ .extend(OrganizationsProjectsAccessControlMemberObjectsRetrieveQueryParams.shape)
+ .extend({
+ id: OrganizationsProjectsAccessControlMemberObjectsRetrieveParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ member_id: OrganizationsProjectsAccessControlMemberObjectsRetrieveQueryParams.shape['member_id'].describe(
+ 'The organization membership id, as `organization_membership_id` in access-control-members-list.'
+ ),
+ })
+}
+
+const accessControlMemberObjectsList = (): ToolBase<
+ ReturnType<typeof AccessControlMemberObjectsListSchema>,
+ WithAgentNote<WithPostHogUrl<Schemas.AccessControlObjectRulesResponse>>
+> => ({
+ name: 'access-control-member-objects-list',
+ schema: AccessControlMemberObjectsListSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlMemberObjectsListSchema>>) => {
+ const orgId = 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.')
+ }
+ const result = await context.api.request<Schemas.AccessControlObjectRulesResponse>({
+ method: 'GET',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_member_objects/`,
+ query: {
+ member_id: params.member_id,
+ },
+ })
+ return withAgentNote(
+ await withPostHogUrl(context, result, '/settings/environment-access-control'),
+ "The member's tool-level access and their `role_ids` are on access-control-members-list. Object rules from the member's roles are on access-control-role-objects-list, one call per role id.\n"
+ )
+ },
+})
+
+const AccessControlMemberPropertiesListSchema = () => {
+ const OrganizationsProjectsAccessControlMemberPropertiesRetrieveParams =
+ orvalSchemas.OrganizationsProjectsAccessControlMemberPropertiesRetrieveParams()
+ const OrganizationsProjectsAccessControlMemberPropertiesRetrieveQueryParams =
+ orvalSchemas.OrganizationsProjectsAccessControlMemberPropertiesRetrieveQueryParams()
+ return OrganizationsProjectsAccessControlMemberPropertiesRetrieveParams.omit({ organization_id: true })
+ .extend(OrganizationsProjectsAccessControlMemberPropertiesRetrieveQueryParams.shape)
+ .extend({
+ id: OrganizationsProjectsAccessControlMemberPropertiesRetrieveParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ member_id: OrganizationsProjectsAccessControlMemberPropertiesRetrieveQueryParams.shape[
+ 'member_id'
+ ].describe(
+ 'The organization membership id, as `organization_membership_id` in access-control-members-list.'
+ ),
+ })
+}
+
+const accessControlMemberPropertiesList = (): ToolBase<
+ ReturnType<typeof AccessControlMemberPropertiesListSchema>,
+ WithAgentNote<WithPostHogUrl<Schemas.AccessControlPropertyRulesResponse>>
+> => ({
+ name: 'access-control-member-properties-list',
+ schema: AccessControlMemberPropertiesListSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlMemberPropertiesListSchema>>) => {
+ const orgId = 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.')
+ }
+ const result = await context.api.request<Schemas.AccessControlPropertyRulesResponse>({
+ method: 'GET',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_member_properties/`,
+ query: {
+ member_id: params.member_id,
+ },
+ })
+ return withAgentNote(
+ await withPostHogUrl(context, result, '/settings/environment-access-control'),
+ "Property rules from the member's roles are on access-control-role-properties-list, one call per id in the member's `role_ids` from access-control-members-list. Rules for everyone in the project are on access-control-default-properties-list.\n"
+ )
+ },
+})
+
+const AccessControlMembersListSchema = () => {
+ const OrganizationsProjectsAccessControlMembersRetrieveParams =
+ orvalSchemas.OrganizationsProjectsAccessControlMembersRetrieveParams()
+ const OrganizationsProjectsAccessControlMembersRetrieveQueryParams =
+ orvalSchemas.OrganizationsProjectsAccessControlMembersRetrieveQueryParams()
+ return OrganizationsProjectsAccessControlMembersRetrieveParams.omit({ organization_id: true })
+ .extend(OrganizationsProjectsAccessControlMembersRetrieveQueryParams.shape)
+ .extend({
+ id: OrganizationsProjectsAccessControlMembersRetrieveParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ member_id: OrganizationsProjectsAccessControlMembersRetrieveQueryParams.shape['member_id'].describe(
+ 'Optional. Narrow the result to one member, by organization membership id.'
+ ),
+ })
+}
+
+const accessControlMembersList = (): ToolBase<
+ ReturnType<typeof AccessControlMembersListSchema>,
+ WithAgentNote<WithPostHogUrl<Schemas.AccessControlMembersResponse>>
+> => ({
+ name: 'access-control-members-list',
+ schema: AccessControlMembersListSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlMembersListSchema>>) => {
+ const orgId = 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.')
+ }
+ const result = await context.api.request<Schemas.AccessControlMembersResponse>({
+ method: 'GET',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_members/`,
+ query: {
+ member_id: params.member_id,
+ },
+ })
+ const filtered = {
+ ...result,
+ results: (result.results ?? []).map((item: any) =>
+ omitResponseFields(item, [
+ 'project.minimum',
+ 'project.maximum',
+ 'resources.*.minimum',
+ 'resources.*.maximum',
+ ])
+ ),
+ } as typeof result
+ return withAgentNote(
+ await withPostHogUrl(context, filtered, '/settings/environment-access-control'),
+ 'For a question about one object, for example a dashboard or a table, call access-control-member-objects-list; for a person or event property, access-control-member-properties-list. Rules a role sets on objects or properties are only on the role-objects and role-properties tools. Level bounds per tool are on access-control-defaults-get.\n'
+ )
+ },
+})
+
+const AccessControlRoleObjectsListSchema = () => {
+ const OrganizationsProjectsAccessControlRoleObjectsRetrieveParams =
+ orvalSchemas.OrganizationsProjectsAccessControlRoleObjectsRetrieveParams()
+ const OrganizationsProjectsAccessControlRoleObjectsRetrieveQueryParams =
+ orvalSchemas.OrganizationsProjectsAccessControlRoleObjectsRetrieveQueryParams()
+ return OrganizationsProjectsAccessControlRoleObjectsRetrieveParams.omit({ organization_id: true })
+ .extend(OrganizationsProjectsAccessControlRoleObjectsRetrieveQueryParams.shape)
+ .extend({
+ id: OrganizationsProjectsAccessControlRoleObjectsRetrieveParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ role_id: OrganizationsProjectsAccessControlRoleObjectsRetrieveQueryParams.shape['role_id'].describe(
+ 'The role id, as `role_id` in access-control-roles-list or an entry of `role_ids` in access-control-members-list.'
+ ),
+ })
+}
+
+const accessControlRoleObjectsList = (): ToolBase<
+ ReturnType<typeof AccessControlRoleObjectsListSchema>,
+ WithPostHogUrl<Schemas.AccessControlObjectRulesResponse>
+> => ({
+ name: 'access-control-role-objects-list',
+ schema: AccessControlRoleObjectsListSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlRoleObjectsListSchema>>) => {
+ const orgId = 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.')
+ }
+ const result = await context.api.request<Schemas.AccessControlObjectRulesResponse>({
+ method: 'GET',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_role_objects/`,
+ query: {
+ role_id: params.role_id,
+ },
+ })
+ return await withPostHogUrl(context, result, '/settings/environment-access-control')
+ },
+})
+
+const AccessControlRolePropertiesListSchema = () => {
+ const OrganizationsProjectsAccessControlRolePropertiesRetrieveParams =
+ orvalSchemas.OrganizationsProjectsAccessControlRolePropertiesRetrieveParams()
+ const OrganizationsProjectsAccessControlRolePropertiesRetrieveQueryParams =
+ orvalSchemas.OrganizationsProjectsAccessControlRolePropertiesRetrieveQueryParams()
+ return OrganizationsProjectsAccessControlRolePropertiesRetrieveParams.omit({ organization_id: true })
+ .extend(OrganizationsProjectsAccessControlRolePropertiesRetrieveQueryParams.shape)
+ .extend({
+ id: OrganizationsProjectsAccessControlRolePropertiesRetrieveParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ role_id: OrganizationsProjectsAccessControlRolePropertiesRetrieveQueryParams.shape['role_id'].describe(
+ 'The role id, as `role_id` in access-control-roles-list or an entry of `role_ids` in access-control-members-list.'
+ ),
+ })
+}
+
+const accessControlRolePropertiesList = (): ToolBase<
+ ReturnType<typeof AccessControlRolePropertiesListSchema>,
+ WithPostHogUrl<Schemas.AccessControlPropertyRulesResponse>
+> => ({
+ name: 'access-control-role-properties-list',
+ schema: AccessControlRolePropertiesListSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlRolePropertiesListSchema>>) => {
+ const orgId = 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.')
+ }
+ const result = await context.api.request<Schemas.AccessControlPropertyRulesResponse>({
+ method: 'GET',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_role_properties/`,
+ query: {
+ role_id: params.role_id,
+ },
+ })
+ return await withPostHogUrl(context, result, '/settings/environment-access-control')
+ },
+})
+
+const AccessControlRolesListSchema = () => {
+ const OrganizationsProjectsAccessControlRolesRetrieveParams =
+ orvalSchemas.OrganizationsProjectsAccessControlRolesRetrieveParams()
+ const OrganizationsProjectsAccessControlRolesRetrieveQueryParams =
+ orvalSchemas.OrganizationsProjectsAccessControlRolesRetrieveQueryParams()
+ return OrganizationsProjectsAccessControlRolesRetrieveParams.omit({ organization_id: true })
+ .extend(OrganizationsProjectsAccessControlRolesRetrieveQueryParams.shape)
+ .extend({
+ id: OrganizationsProjectsAccessControlRolesRetrieveParams.shape['id']
+ .describe('Project id. If omitted, uses the active project.')
+ .optional(),
+ role_id: OrganizationsProjectsAccessControlRolesRetrieveQueryParams.shape['role_id'].describe(
+ 'Optional. Narrow the result to one role, by role id.'
+ ),
+ })
+}
+
+const accessControlRolesList = (): ToolBase<
+ ReturnType<typeof AccessControlRolesListSchema>,
+ WithAgentNote<WithPostHogUrl<Schemas.AccessControlRolesResponse>>
+> => ({
+ name: 'access-control-roles-list',
+ schema: AccessControlRolesListSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof AccessControlRolesListSchema>>) => {
+ const orgId = 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.')
+ }
+ const result = await context.api.request<Schemas.AccessControlRolesResponse>({
+ method: 'GET',
+ path: `/api/organizations/${encodeURIComponent(String(orgId))}/projects/${encodeURIComponent(String(id))}/access_control_roles/`,
+ query: {
+ role_id: params.role_id,
+ },
+ })
+ const filtered = {
+ ...result,
+ results: (result.results ?? []).map((item: any) =>
+ omitResponseFields(item, [
+ 'project.minimum',
+ 'project.maximum',
+ 'resources.*.minimum',
+ 'resources.*.maximum',
+ ])
+ ),
+ } as typeof result
+ return withAgentNote(
+ await withPostHogUrl(context, filtered, '/settings/environment-access-control'),
+ "A member's enforced level already includes their roles, so for a person use access-control-members-list. For a role's rules on one object or property, call access-control-role-objects-list or access-control-role-properties-list. A member's roles are `role_ids` on access-control-members-list, and role-members-list gives who is in a role.\n"
+ )
+ },
+})
+
+export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
+ 'access-control-default-objects-list': accessControlDefaultObjectsList,
+ 'access-control-default-properties-list': accessControlDefaultPropertiesList,
+ 'access-control-defaults-get': accessControlDefaultsGet,
+ 'access-control-member-objects-list': accessControlMemberObjectsList,
+ 'access-control-member-properties-list': accessControlMemberPropertiesList,
+ 'access-control-members-list': accessControlMembersList,
+ 'access-control-role-objects-list': accessControlRoleObjectsList,
+ 'access-control-role-properties-list': accessControlRolePropertiesList,
+ 'access-control-roles-list': accessControlRolesList,
+}
diff --git a/services/mcp/src/tools/generated/index.ts b/services/mcp/src/tools/generated/index.ts
index 8600cbc12c0c..053dfc862381 100644
--- a/services/mcp/src/tools/generated/index.ts
+++ b/services/mcp/src/tools/generated/index.ts
@@ -1,6 +1,7 @@
// AUTO-GENERATED — do not edit
import type { ToolBase, ZodObjectAny } from '@/tools/types'
+import { GENERATED_TOOLS as access_control } from './access_control'
import { GENERATED_TOOLS as actions } from './actions'
import { GENERATED_TOOLS as ai_observability } from './ai_observability'
import { GENERATED_TOOLS as alerts } from './alerts'
@@ -66,6 +67,7 @@ import { GENERATED_TOOLS as web_analytics } from './web_analytics'
import { GENERATED_TOOLS as workflows } from './workflows'
export const GENERATED_TOOL_MAP: Record<string, () => ToolBase<ZodObjectAny>> = {
+ ...access_control,
...actions,
...ai_observability,
...alerts,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-objects-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-objects-list.json
new file mode 100644
index 000000000000..6a9ba5e5c796
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-objects-list.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "Project id. If omitted, uses the active project.",
+ "maximum": 2147483647,
+ "minimum": -2147483648,
+ "type": "number"
+ }
+ },
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-properties-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-properties-list.json
new file mode 100644
index 000000000000..6a9ba5e5c796
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-default-properties-list.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "Project id. If omitted, uses the active project.",
+ "maximum": 2147483647,
+ "minimum": -2147483648,
+ "type": "number"
+ }
+ },
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-defaults-get.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-defaults-get.json
new file mode 100644
index 000000000000..6a9ba5e5c796
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-defaults-get.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "Project id. If omitted, uses the active project.",
+ "maximum": 2147483647,
+ "minimum": -2147483648,
+ "type": "number"
+ }
+ },
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-objects-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-objects-list.json
new file mode 100644
index 000000000000..5220ea53b5da
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-objects-list.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "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"
+ }
+ },
+ "required": ["member_id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-properties-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-properties-list.json
new file mode 100644
index 000000000000..5220ea53b5da
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-member-properties-list.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "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"
+ }
+ },
+ "required": ["member_id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-members-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-members-list.json
new file mode 100644
index 000000000000..e22eeb053411
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-members-list.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "Project id. If omitted, uses the active project.",
+ "maximum": 2147483647,
+ "minimum": -2147483648,
+ "type": "number"
+ },
+ "member_id": {
+ "description": "Optional. Narrow the result to one member, by organization membership id.",
+ "type": "string"
+ }
+ },
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-objects-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-objects-list.json
new file mode 100644
index 000000000000..5796fe6e078a
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-objects-list.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "Project id. If omitted, uses the active project.",
+ "maximum": 2147483647,
+ "minimum": -2147483648,
+ "type": "number"
+ },
+ "role_id": {
+ "description": "The role id, as `role_id` in access-control-roles-list or an entry of `role_ids` in access-control-members-list.",
+ "type": "string"
+ }
+ },
+ "required": ["role_id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-properties-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-properties-list.json
new file mode 100644
index 000000000000..5796fe6e078a
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-role-properties-list.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "Project id. If omitted, uses the active project.",
+ "maximum": 2147483647,
+ "minimum": -2147483648,
+ "type": "number"
+ },
+ "role_id": {
+ "description": "The role id, as `role_id` in access-control-roles-list or an entry of `role_ids` in access-control-members-list.",
+ "type": "string"
+ }
+ },
+ "required": ["role_id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-roles-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-roles-list.json
new file mode 100644
index 000000000000..d1a6fcfaa64d
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/access-control-roles-list.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "Project id. If omitted, uses the active project.",
+ "maximum": 2147483647,
+ "minimum": -2147483648,
+ "type": "number"
+ },
+ "role_id": {
+ "description": "Optional. Narrow the result to one role, by role id.",
+ "type": "string"
+ }
+ },
+ "type": "object"
+}