:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(signals): add inbox:write to server-minted sandbox tokens (#119449)
posthog[bot]b7af690a0430
diff --git a/posthog/temporal/oauth.py b/posthog/temporal/oauth.pyindex 70b08e06efaf..5df6000084c8 100644--- a/posthog/temporal/oauth.py+++ b/posthog/temporal/oauth.py@@ -128,6 +128,8 @@ INTERACTIVE_RUN_SCOPE = "interactive_run:read"INTERNAL_SCOPES: list[str] = ["task:write",+ # Inbox endpoints move from `task:*` to `inbox:*` scopes, so a run carries both until the move ends.+ "inbox:write","llm_gateway:read",# Provenance marker: proves a token was minted here (server-side), not obtained by a# user via the consent flow or a personal API key. `internal_run` is an internal scope,@@ -346,12 +348,12 @@ MCP_SCOPE_PRESETS = ()# Withheld from `signals_research`, which is otherwise the `read_only` resolution.-# `task:write` reaches every posture through `INTERNAL_SCOPES`, but it is inert wherever the-# MCP server runs in read-only mode, which strips every tool not annotated read-only.+# `task:write` and `inbox:write` reach every posture through `INTERNAL_SCOPES`, but they are inert+# wherever the MCP server runs in read-only mode, which strips every tool not annotated read-only.# `signals_research` turns that mode off so its two scratchpad tools survive, and that alone-# would hand the research stage the whole task-write toolset — including setting a report's-# state. The stage reads data and returns findings; the pipeline persists them afterwards.-RESEARCH_WITHHELD_SCOPES: frozenset[str] = frozenset({"task:write"})+# would hand the research stage the whole task-write and inbox-write toolset — including setting+# a report's state. The stage reads data and returns findings; the pipeline persists them afterwards.+RESEARCH_WITHHELD_SCOPES: frozenset[str] = frozenset({"task:write", "inbox:write"})def scout_scope_posture(@@ -442,7 +444,7 @@ def resolve_scopes(resolved = [*MCP_READ_SCOPES, *MCP_WRITE_SCOPES, *internal, *scratchpad]elif scopes == "signals_research":# The report research run: reads, plus durable memory, and nothing else. See- # `RESEARCH_WITHHELD_SCOPES` for why `task:write` comes back out.+ # `RESEARCH_WITHHELD_SCOPES` for why `task:write` and `inbox:write` come back out.reads = [scope for scope in (*MCP_READ_SCOPES, *internal) if scope not in RESEARCH_WITHHELD_SCOPES]if include_internal_scopes:reads.append("signal_scout_internal:read")diff --git a/posthog/temporal/tests/test_oauth.py b/posthog/temporal/tests/test_oauth.pyindex 064b68e3fbca..747c8d9d2869 100644--- a/posthog/temporal/tests/test_oauth.py+++ b/posthog/temporal/tests/test_oauth.py@@ -18,6 +18,7 @@ from posthog.temporal.oauth import (CONTEXT_LAYER_INTERNAL_SCOPE,INTERNAL_SCOPES,MCP_READ_SCOPES,+ MCP_SCOPE_PRESETS,MCP_WRITE_SCOPES,POSTHOG_AI_APP_CLIENT_ID_DEV,RESEARCH_WITHHELD_SCOPES,@@ -103,10 +104,17 @@ class TestResolveScopes(SimpleTestCase):assert set(result) == expectedassert "signal_scratchpad_internal:write" in resultassert "task:write" not in result+ assert "inbox:write" not in result+ assert "inbox:read" in resultassert "action:write" not in resultassert "signal_scout_internal:read" not in resolve_scopes("signals_research", include_internal_scopes=False)+ @parameterized.expand([(preset, preset) for preset in MCP_SCOPE_PRESETS] + [("custom", ["feature_flag:read"])])+ def test_inbox_write_travels_with_task_write(self, _name: str, scopes: PosthogMcpScopes) -> None:+ result = resolve_scopes(scopes)+ assert ("task:write" in result) == ("inbox:write" in result)+def test_signals_implementation_preset_is_full_plus_the_scratchpad(self) -> None:result = resolve_scopes("signals_implementation")assert set(result) == set(diff --git a/products/tasks/backend/facade/onboarding.py b/products/tasks/backend/facade/onboarding.pyindex f5a8918ece45..13bc7e5e9355 100644--- a/products/tasks/backend/facade/onboarding.py+++ b/products/tasks/backend/facade/onboarding.py@@ -47,7 +47,7 @@ ONBOARDING_SESSION_TITLE = "Getting set up"ONBOARDING_SESSION_PAID_MODEL = "claude-opus-4-8"ONBOARDING_SESSION_FREE_MODEL = "zai-org/glm-5.3-flash"ONBOARDING_SESSION_EFFORT = "medium"-ONBOARDING_SESSION_SCOPES = [*MCP_READ_SCOPES, "task:write"]+ONBOARDING_SESSION_SCOPES = [*MCP_READ_SCOPES, "task:write", "inbox:write"]SPACES_FLAGS = ("code-spaces-layout", "project-bluebird")ONBOARDING_TEST_TOOLS_FLAG = "posthog-desktop-onboarding-test-tools"diff --git a/products/tasks/backend/temporal/tests/test_oauth.py b/products/tasks/backend/temporal/tests/test_oauth.pyindex ddb44d464d1f..e68a738dff59 100644--- a/products/tasks/backend/temporal/tests/test_oauth.py+++ b/products/tasks/backend/temporal/tests/test_oauth.py@@ -8,7 +8,7 @@ from django.utils import timezonefrom posthog.models import OAuthAccessToken, Organization, Teamfrom posthog.models.organization import OrganizationMembershipfrom posthog.models.user import User-from posthog.temporal.oauth import PosthogMcpScopes, resolve_scopes+from posthog.temporal.oauth import RESEARCH_WITHHELD_SCOPES, PosthogMcpScopes, resolve_scopesfrom products.tasks.backend.exceptions import TaskInvalidStateErrorfrom products.tasks.backend.models import (@@ -566,7 +566,7 @@ def test_workflow_run_scopes_never_exceed_request_or_snapshot(Task.OriginProduct.SIGNAL_REPORT,{"pending_dispatch": {"posthog_mcp_scopes": "signals_research"}},None,- [*resolve_scopes("signals_research"), "task:write"],+ [*resolve_scopes("signals_research"), *RESEARCH_WITHHELD_SCOPES],),(Task.OriginProduct.SIGNAL_REPORT,diff --git a/products/tasks/backend/tests/test_onboarding_session.py b/products/tasks/backend/tests/test_onboarding_session.pyindex af46828c3645..0591effc698b 100644--- a/products/tasks/backend/tests/test_onboarding_session.py+++ b/products/tasks/backend/tests/test_onboarding_session.py@@ -145,9 +145,12 @@ class TestOnboardingSessionIdempotency(TestCase):self.assertIn("info channel-instructions-retrieve", kwargs["description"])self.assertIn("call channel-instructions-retrieve", kwargs["description"])self.assertIn("info channel-instructions-update", kwargs["description"])- self.assertEqual(set(kwargs["posthog_mcp_scopes"]), {*MCP_READ_SCOPES, "task:write"})+ self.assertEqual(set(kwargs["posthog_mcp_scopes"]), {*MCP_READ_SCOPES, "task:write", "inbox:write"})self.assertFalse(- any(scope.endswith(":write") and scope != "task:write" for scope in kwargs["posthog_mcp_scopes"])+ any(+ scope.endswith(":write") and scope not in {"task:write", "inbox:write"}+ for scope in kwargs["posthog_mcp_scopes"]+ ))return contracts.CreatedTaskDTO(task_id=task_id, team_id=self.team.id, latest_run=None)