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(integrations): add anthropic integration kind (#57327)

Fernando Gomesb5d98cd9d125
diff --git a/posthog/api/integration.py b/posthog/api/integration.py
index 137782e23f4b..632d4716dbc4 100644
--- a/posthog/api/integration.py
+++ b/posthog/api/integration.py
@@ -16,6 +16,7 @@ from django.utils.crypto import get_random_string
import stripe
import requests
import structlog
+from anthropic import APIConnectionError, APIStatusError, AuthenticationError, PermissionDeniedError
from django_filters.rest_framework import DjangoFilterBackend
from drf_spectacular.utils import extend_schema, extend_schema_serializer
from rest_framework import mixins, serializers, viewsets
@@ -33,9 +34,13 @@ from posthog.exceptions_capture import capture_exception
from posthog.models import User
from posthog.models.instance_setting import get_instance_setting
from posthog.models.integration import (
+ ANTHROPIC_DEFAULT_INTEGRATION_ID_PREFIX,
+ ANTHROPIC_MANAGED_AGENT_LIST_PAGE_LIMIT,
+ ANTHROPIC_WORKSPACE_LABEL_MAX_LENGTH,
ERROR_TOKEN_REFRESH_FAILED,
GITHUB_REPOSITORY_REFRESH_COOLDOWN_SECONDS,
SLACK_INTEGRATION_KINDS,
+ AnthropicIntegration,
AzureBlobIntegration,
AzureBlobIntegrationError,
ClickUpIntegration,
@@ -391,6 +396,44 @@ class IntegrationSerializer(serializers.ModelSerializer, UserAccessControlSerial
)
return instance
+ elif validated_data["kind"] == "anthropic":
+ config = validated_data.get("config", {})
+ api_key = config.get("api_key")
+ workspace_label = config.get("workspace_label")
+ force = bool(config.get("force", False))
+
+ if not isinstance(api_key, str) or not api_key.strip():
+ raise ValidationError("An Anthropic API key must be provided")
+ api_key = api_key.strip()
+ # Reject control characters / whitespace inside the key — pasted
+ # tokens with trailing newlines silently break every Anthropic call.
+ if any(ch.isspace() or ord(ch) < 0x20 for ch in api_key):
+ raise ValidationError("Anthropic API key must not contain whitespace or control characters")
+
+ if workspace_label is not None:
+ if not isinstance(workspace_label, str):
+ raise ValidationError("Workspace label must be a string")
+ workspace_label = workspace_label.strip()
+ if not workspace_label:
+ workspace_label = None
+ elif len(workspace_label) > ANTHROPIC_WORKSPACE_LABEL_MAX_LENGTH:
+ raise ValidationError(
+ f"Workspace label must be {ANTHROPIC_WORKSPACE_LABEL_MAX_LENGTH} characters or fewer"
+ )
+ elif workspace_label.startswith(ANTHROPIC_DEFAULT_INTEGRATION_ID_PREFIX):
+ raise ValidationError(
+ f"Workspace label cannot start with '{ANTHROPIC_DEFAULT_INTEGRATION_ID_PREFIX}'"
+ )
+
+ instance = AnthropicIntegration.integration_from_key(
+ api_key=api_key,
+ team_id=team_id,
+ created_by=request.user,
+ workspace_label=workspace_label,
+ force=force,
+ )
+ return instance
+
elif validated_data["kind"] == "twilio":
config = validated_data.get("config", {})
account_sid = config.get("account_sid")
@@ -568,6 +611,9 @@ class IntegrationViewSet(
"channels",
"github_repos",
"github_branches",
+ "anthropic_managed_agents",
+ "anthropic_managed_agent_environments",
+ "anthropic_managed_agent_vaults",
]
scope_object_write_actions = [
"create",
@@ -881,6 +927,111 @@ class IntegrationViewSet(
linear = LinearIntegration(instance)
return Response({"teams": linear.list_teams()})
+ @extend_schema(operation_id="integrations_anthropic_managed_agents_retrieve")
+ @action(methods=["GET"], detail=True, url_path="anthropic_managed_agents")
+ def anthropic_managed_agents(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ return self._anthropic_managed_list_response(request, resource="agents")
+
+ @extend_schema(operation_id="integrations_anthropic_managed_agent_envs_retrieve")
+ @action(methods=["GET"], detail=True, url_path="anthropic_managed_agent_environments")
+ def anthropic_managed_agent_environments(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ return self._anthropic_managed_list_response(request, resource="environments")
+
+ @extend_schema(operation_id="integrations_anthropic_managed_agent_vaults_retrieve")
+ @action(methods=["GET"], detail=True, url_path="anthropic_managed_agent_vaults")
+ def anthropic_managed_agent_vaults(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ return self._anthropic_managed_list_response(request, resource="vaults")
+
+ def _anthropic_managed_list_response(self, request: Request, *, resource: str) -> Response:
+ instance = self._get_anthropic_integration_or_400()
+
+ try:
+ limit = int(request.query_params.get("limit", ANTHROPIC_MANAGED_AGENT_LIST_PAGE_LIMIT))
+ except (TypeError, ValueError):
+ raise ValidationError("`limit` must be an integer")
+ after = request.query_params.get("after") or None
+ force_refresh = request.query_params.get("force_refresh", "false").lower() == "true"
+
+ # Cache only the default first page; paginated requests bypass the
+ # cache because the cursor reflects upstream state we shouldn't pin.
+ cache_eligible = not after and limit == ANTHROPIC_MANAGED_AGENT_LIST_PAGE_LIMIT
+ cache_key = f"anthropic/{instance.id}/{resource}"
+ if cache_eligible and not force_refresh:
+ cached = cache.get(cache_key)
+ if cached is not None:
+ return Response(cached)
+
+ try:
+ anthropic = AnthropicIntegration(instance)
+ data, next_cursor = self._anthropic_resource_list(anthropic, resource=resource, after=after, limit=limit)
+ except AuthenticationError:
+ self._record_anthropic_auth_failure(instance, "Anthropic API key is no longer valid")
+ raise ValidationError("Anthropic API key is no longer valid. Please reconnect the integration.")
+ except PermissionDeniedError:
+ self._record_anthropic_auth_failure(instance, "Anthropic API key is missing required permissions")
+ raise ValidationError(
+ "Anthropic API key is missing required permissions. Please reconnect with a key that has access "
+ "to the Managed Agents beta."
+ )
+ except APIConnectionError:
+ logger.warning("anthropic_list_connection_error", resource=resource, exc_info=True)
+ raise ValidationError("Could not reach Anthropic. Please try again.")
+ except APIStatusError as e:
+ logger.warning("anthropic_list_status_error", resource=resource, status_code=e.status_code, exc_info=True)
+ raise ValidationError(f"Anthropic returned an error (HTTP {e.status_code}). Please try again.")
+
+ body: dict[str, Any] = {"next_cursor": next_cursor, "has_more": bool(next_cursor)}
+ if resource == "agents":
+ body["agents"] = [
+ {
+ "id": agent["id"],
+ "name": agent.get("name", agent["id"]),
+ "version": agent.get("version"),
+ }
+ for agent in data
+ if "id" in agent
+ ]
+ elif resource == "environments":
+ body["environments"] = [
+ {"id": env["id"], "name": env.get("name", env["id"])} for env in data if "id" in env
+ ]
+ else: # vaults
+ body["vaults"] = [
+ {"id": vault["id"], "display_name": vault.get("display_name", vault["id"])}
+ for vault in data
+ if "id" in vault
+ ]
+
+ if cache_eligible:
+ cache.set(cache_key, body, 60 * 5) # 5 minutes — UI dropdown freshness window
+
+ return Response(body)
+
+ def _get_anthropic_integration_or_400(self) -> Integration:
+ instance = self.get_object()
+ if instance.kind != Integration.IntegrationKind.ANTHROPIC.value:
+ raise ValidationError(f"Integration {instance.id} is not an Anthropic integration (kind={instance.kind!r})")
+ return instance
+
+ @staticmethod
+ def _anthropic_resource_list(
+ anthropic: AnthropicIntegration, *, resource: str, after: str | None, limit: int
+ ) -> tuple[list[dict], str | None]:
+ if resource == "agents":
+ return anthropic.list_managed_agents(after=after, limit=limit)
+ if resource == "environments":
+ return anthropic.list_managed_agent_environments(after=after, limit=limit)
+ if resource == "vaults":
+ return anthropic.list_managed_agent_vaults(after=after, limit=limit)
+ raise ValueError(f"unknown anthropic managed-agents resource: {resource!r}")
+
+ @staticmethod
+ def _record_anthropic_auth_failure(instance: Integration, message: str) -> None:
+ if instance.errors != ERROR_TOKEN_REFRESH_FAILED:
+ instance.errors = ERROR_TOKEN_REFRESH_FAILED
+ instance.save(update_fields=["errors"])
+ logger.warning("anthropic_managed_list_auth_failure", integration_id=instance.id, message=message)
+
@extend_schema(
parameters=[GitHubReposQuerySerializer],
responses={200: GitHubReposResponseSerializer},
diff --git a/posthog/api/test/test_integration.py b/posthog/api/test/test_integration.py
index 61c5485d5505..22d03c48c409 100644
--- a/posthog/api/test/test_integration.py
+++ b/posthog/api/test/test_integration.py
@@ -18,6 +18,7 @@ from rest_framework import status
from posthog.api.integration import IntegrationViewSet
from posthog.api.oauth.test_dcr import generate_rsa_key
from posthog.models.integration import (
+ ERROR_TOKEN_REFRESH_FAILED,
GITHUB_REPOSITORY_REFRESH_COOLDOWN_SECONDS,
PRIVATE_CHANNEL_WITHOUT_ACCESS,
SLACK_INTEGRATION_KINDS,
@@ -2495,3 +2496,356 @@ class TestGitHubOAuthAuthorize:
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert "GitHub App client ID is not configured" in response.json()["detail"]
+
+
+class TestAnthropicIntegration:
+ @pytest.fixture(autouse=True)
+ def setup_integration(self, db):
+ self.organization = Organization.objects.create(name="Test Org")
+ self.team = Team.objects.create(organization=self.organization, name="Test Team")
+ self.user = User.objects.create_and_join(
+ self.organization, "[email protected]", "test", level=OrganizationMembership.Level.ADMIN
+ )
+
+ @staticmethod
+ def _mock_anthropic_validate_key(mock_anthropic_class) -> MagicMock:
+ """Configure the patched `Anthropic` class so `validate_key()` (now hits `/v1/agents`) succeeds."""
+ mock_client = MagicMock()
+ mock_anthropic_class.return_value = mock_client
+ mock_client.get.return_value = {"data": []}
+ return mock_client
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_create_with_valid_key(self, mock_anthropic_class, client: HttpClient):
+ self._mock_anthropic_validate_key(mock_anthropic_class)
+
+ client.force_login(self.user)
+ response = client.post(
+ f"/api/environments/{self.team.pk}/integrations",
+ {
+ "kind": "anthropic",
+ "config": {"api_key": "sk-ant-test", "workspace_label": "production"},
+ },
+ content_type="application/json",
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED
+ assert response.json()["kind"] == "anthropic"
+
+ integration = Integration.objects.get(id=response.json()["id"])
+ assert integration.kind == "anthropic"
+ assert integration.team == self.team
+ assert integration.config == {"workspace_label": "production"}
+ assert integration.sensitive_config == {"api_key": "sk-ant-test"}
+ assert integration.integration_id == "production"
+ assert integration.created_by == self.user
+
+ # Assert the anthropic-beta was called to validate the key during creation.
+ get_call = mock_anthropic_class.return_value.get.call_args
+ assert get_call.args[0] == "/v1/agents"
+ assert get_call.kwargs["options"]["headers"]["anthropic-beta"] == "managed-agents-2026-04-01"
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_create_strips_whitespace_from_api_key(self, mock_anthropic_class, client: HttpClient):
+ self._mock_anthropic_validate_key(mock_anthropic_class)
+
+ client.force_login(self.user)
+ response = client.post(
+ f"/api/environments/{self.team.pk}/integrations",
+ {"kind": "anthropic", "config": {"api_key": " sk-ant-test "}},
+ content_type="application/json",
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED
+ integration = Integration.objects.get(id=response.json()["id"])
+ assert integration.sensitive_config == {"api_key": "sk-ant-test"}
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_create_without_workspace_label_uses_default_id(self, mock_anthropic_class, client: HttpClient):
+ self._mock_anthropic_validate_key(mock_anthropic_class)
+
+ client.force_login(self.user)
+ response = client.post(
+ f"/api/environments/{self.team.pk}/integrations",
+ {"kind": "anthropic", "config": {"api_key": "sk-ant-test"}},
+ content_type="application/json",
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED
+ integration = Integration.objects.get(id=response.json()["id"])
+ assert integration.config == {}
+ assert integration.integration_id == f"workspace-{self.team.pk}"
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_create_rejects_existing_workspace_without_force(self, mock_anthropic_class, client: HttpClient):
+ self._mock_anthropic_validate_key(mock_anthropic_class)
+
+ client.force_login(self.user)
+ response = client.post(
+ f"/api/environments/{self.team.pk}/integrations",
+ {"kind": "anthropic", "config": {"api_key": "sk-ant-first", "workspace_label": "production"}},
+ content_type="application/json",
+ )
+ assert response.status_code == status.HTTP_201_CREATED
+ first_id = response.json()["id"]
+
+ response = client.post(
+ f"/api/environments/{self.team.pk}/integrations",
+ {"kind": "anthropic", "config": {"api_key": "sk-ant-second", "workspace_label": "production"}},
+ content_type="application/json",
+ )
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert "already exists" in str(response.json())
+ # Original key untouched.
+ integration = Integration.objects.get(id=first_id)
+ assert integration.sensitive_config == {"api_key": "sk-ant-first"}
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_create_overwrites_with_force_flag(self, mock_anthropic_class, client: HttpClient):
+ self._mock_anthropic_validate_key(mock_anthropic_class)
+
+ client.force_login(self.user)
+ response = client.post(
+ f"/api/environments/{self.team.pk}/integrations",
+ {"kind": "anthropic", "config": {"api_key": "sk-ant-first", "workspace_label": "production"}},
+ content_type="application/json",
+ )
+ first_id = response.json()["id"]
+
+ response = client.post(
+ f"/api/environments/{self.team.pk}/integrations",
+ {
+ "kind": "anthropic",
+ "config": {"api_key": "sk-ant-second", "workspace_label": "production", "force": True},
+ },
+ content_type="application/json",
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED
+ # Same row reused (same (team, kind, integration_id) tuple) with rotated key.
+ assert response.json()["id"] == first_id
+ integration = Integration.objects.get(id=first_id)
+ assert integration.sensitive_config == {"api_key": "sk-ant-second"}
+
+ @pytest.mark.parametrize(
+ "config,expected_error_substring",
+ [
+ ({}, "Anthropic API key"),
+ ({"api_key": ""}, "Anthropic API key"),
+ ({"api_key": " "}, "Anthropic API key"),
+ ({"api_key": "sk-ant-with\nnewline"}, "must not contain whitespace"),
+ ({"api_key": "sk-ant-test", "workspace_label": "x" * 200}, "characters or fewer"),
+ ({"api_key": "sk-ant-test", "workspace_label": "workspace-foo"}, "cannot start with"),
+ ({"api_key": "sk-ant-test", "workspace_label": 42}, "Workspace label must be a string"),
+ ],
+ )
+ @patch("posthog.models.integration.Anthropic")
+ def test_create_rejects_invalid_payload(
+ self,
+ mock_anthropic_class,
+ config: dict,
+ expected_error_substring: str,
+ client: HttpClient,
+ ):
+ client.force_login(self.user)
+ response = client.post(
+ f"/api/environments/{self.team.pk}/integrations",
+ {"kind": "anthropic", "config": config},
+ content_type="application/json",
+ )
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert expected_error_substring in str(response.json())
+ assert not Integration.objects.filter(kind="anthropic", team=self.team).exists()
+ # Validation never reached the SDK boundary.
+ mock_anthropic_class.assert_not_called()
+
+ @pytest.mark.parametrize(
+ "error_class_name,expected_error_substring",
+ [
+ ("AuthenticationError", "Invalid Anthropic API key"),
+ ("PermissionDeniedError", "missing required permissions"),
+ ("APIConnectionError", "Could not reach Anthropic"),
+ ],
+ )
+ @patch("posthog.models.integration.Anthropic")
+ def test_create_rejects_anthropic_failures(
+ self,
+ mock_anthropic_class,
+ error_class_name: str,
+ expected_error_substring: str,
+ client: HttpClient,
+ ):
+ import anthropic
+
+ error_class = getattr(anthropic, error_class_name)
+ mock_client = MagicMock()
+ mock_anthropic_class.return_value = mock_client
+ if error_class_name == "APIConnectionError":
+ mock_client.get.side_effect = error_class(request=MagicMock())
+ else:
+ mock_client.get.side_effect = error_class(
+ message="upstream error",
+ response=MagicMock(),
+ body=None,
+ )
+
+ client.force_login(self.user)
+ response = client.post(
+ f"/api/environments/{self.team.pk}/integrations",
+ {"kind": "anthropic", "config": {"api_key": "sk-ant-bad"}},
+ content_type="application/json",
+ )
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert expected_error_substring in str(response.json())
+ assert not Integration.objects.filter(kind="anthropic", team=self.team).exists()
+
+ def _make_integration(self, *, integration_id: str = "production") -> Integration:
+ return Integration.objects.create(
+ team=self.team,
+ kind="anthropic",
+ integration_id=integration_id,
+ config={"workspace_label": integration_id},
+ sensitive_config={"api_key": "sk-ant-test"},
+ created_by=self.user,
+ )
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_anthropic_managed_agents_action(self, mock_anthropic_class, client: HttpClient):
+ from django.core.cache import cache
+
+ cache.clear()
+ mock_client = MagicMock()
+ mock_anthropic_class.return_value = mock_client
+ mock_client.get.return_value = {
+ "data": [
+ {"id": "agt_1", "name": "Support bot", "version": "v3"},
+ {"id": "agt_2", "name": "Sales bot", "version": "v1"},
+ ],
+ "next_cursor": None,
+ }
+ integration = self._make_integration()
+ client.force_login(self.user)
+
+ response = client.get(
+ f"/api/environments/{self.team.pk}/integrations/{integration.id}/anthropic_managed_agents/"
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+ body = response.json()
+ assert body["agents"] == [
+ {"id": "agt_1", "name": "Support bot", "version": "v3"},
+ {"id": "agt_2", "name": "Sales bot", "version": "v1"},
+ ]
+ assert body["has_more"] is False
+ assert body["next_cursor"] is None
+ path_arg = mock_client.get.call_args.args[0]
+ headers = mock_client.get.call_args.kwargs["options"]["headers"]
+ assert path_arg == "/v1/agents"
+ assert headers["anthropic-beta"] == "managed-agents-2026-04-01"
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_anthropic_managed_agents_action_caches_default_page(self, mock_anthropic_class, client: HttpClient):
+ from django.core.cache import cache
+
+ cache.clear()
+ mock_client = MagicMock()
+ mock_anthropic_class.return_value = mock_client
+ mock_client.get.return_value = {"data": [{"id": "agt_1", "name": "Bot"}], "next_cursor": None}
+ integration = self._make_integration()
+ client.force_login(self.user)
+
+ url = f"/api/environments/{self.team.pk}/integrations/{integration.id}/anthropic_managed_agents/"
+ first = client.get(url)
+ second = client.get(url)
+
+ assert first.status_code == status.HTTP_200_OK
+ assert second.status_code == status.HTTP_200_OK
+ # Second hit served from cache → SDK called only once.
+ assert mock_client.get.call_count == 1
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_anthropic_managed_agents_action_translates_auth_error(self, mock_anthropic_class, client: HttpClient):
+ from django.core.cache import cache
+
+ from anthropic import AuthenticationError
+
+ cache.clear()
+ mock_client = MagicMock()
+ mock_anthropic_class.return_value = mock_client
+ mock_client.get.side_effect = AuthenticationError(message="bad key", response=MagicMock(), body=None)
+ integration = self._make_integration()
+ client.force_login(self.user)
+
+ response = client.get(
+ f"/api/environments/{self.team.pk}/integrations/{integration.id}/anthropic_managed_agents/"
+ )
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert "no longer valid" in str(response.json())
+ # Failure is recorded on the integration so the UI can surface "needs reconnect".
+ integration.refresh_from_db()
+ assert integration.errors == ERROR_TOKEN_REFRESH_FAILED
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_anthropic_managed_agents_action_rejects_wrong_kind(self, mock_anthropic_class, client: HttpClient):
+ slack_integration = Integration.objects.create(
+ team=self.team,
+ kind="slack",
+ integration_id="T123",
+ config={"team": {"id": "T123"}},
+ sensitive_config={},
+ created_by=self.user,
+ )
+ client.force_login(self.user)
+
+ response = client.get(
+ f"/api/environments/{self.team.pk}/integrations/{slack_integration.id}/anthropic_managed_agents/"
+ )
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert "is not an Anthropic integration" in str(response.json())
+ mock_anthropic_class.assert_not_called()
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_anthropic_managed_agent_environments_action(self, mock_anthropic_class, client: HttpClient):
+ from django.core.cache import cache
+
+ cache.clear()
+ mock_client = MagicMock()
+ mock_anthropic_class.return_value = mock_client
+ mock_client.get.return_value = {"data": [{"id": "env_prod", "name": "Production"}], "next_cursor": "abc"}
+ integration = self._make_integration()
+ client.force_login(self.user)
+
+ response = client.get(
+ f"/api/environments/{self.team.pk}/integrations/{integration.id}/anthropic_managed_agent_environments/"
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+ body = response.json()
+ assert body["environments"] == [{"id": "env_prod", "name": "Production"}]
+ assert body["next_cursor"] == "abc"
+ assert body["has_more"] is True
+
+ @patch("posthog.models.integration.Anthropic")
+ def test_anthropic_managed_agent_vaults_action(self, mock_anthropic_class, client: HttpClient):
+ from django.core.cache import cache
+
+ cache.clear()
+ mock_client = MagicMock()
+ mock_anthropic_class.return_value = mock_client
+ mock_client.get.return_value = {"data": [{"id": "vault_1", "display_name": "Customer secrets"}]}
+ integration = self._make_integration()
+ client.force_login(self.user)
+
+ response = client.get(
+ f"/api/environments/{self.team.pk}/integrations/{integration.id}/anthropic_managed_agent_vaults/"
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+ body = response.json()
+ assert body["vaults"] == [{"id": "vault_1", "display_name": "Customer secrets"}]
+ assert body["has_more"] is False
diff --git a/posthog/migrations/1145_alter_integration_kind.py b/posthog/migrations/1145_alter_integration_kind.py
new file mode 100644
index 000000000000..cb2258186ed0
--- /dev/null
+++ b/posthog/migrations/1145_alter_integration_kind.py
@@ -0,0 +1,56 @@
+# Generated by Django 5.2.13 on 2026-05-01 19:34
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1144_comment_task_fields"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="integration",
+ name="kind",
+ field=models.CharField(
+ choices=[
+ ("anthropic", "Anthropic"),
+ ("apns", "Apple Push"),
+ ("azure-blob", "Azure Blob"),
+ ("bing-ads", "Bing Ads"),
+ ("clickup", "Clickup"),
+ ("customerio-app", "Customerio App"),
+ ("customerio-track", "Customerio Track"),
+ ("customerio-webhook", "Customerio Webhook"),
+ ("databricks", "Databricks"),
+ ("email", "Email"),
+ ("firebase", "Firebase"),
+ ("github", "Github"),
+ ("gitlab", "Gitlab"),
+ ("google-ads", "Google Ads"),
+ ("google-cloud-service-account", "Google Cloud Service Account"),
+ ("google-cloud-storage", "Google Cloud Storage"),
+ ("google-pubsub", "Google Pubsub"),
+ ("google-sheets", "Google Sheets"),
+ ("hubspot", "Hubspot"),
+ ("intercom", "Intercom"),
+ ("jira", "Jira"),
+ ("linear", "Linear"),
+ ("linkedin-ads", "Linkedin Ads"),
+ ("meta-ads", "Meta Ads"),
+ ("pinterest-ads", "Pinterest Ads"),
+ ("postgresql", "Postgresql"),
+ ("reddit-ads", "Reddit Ads"),
+ ("salesforce", "Salesforce"),
+ ("slack", "Slack"),
+ ("slack-posthog-code", "Slack Posthog Code"),
+ ("snapchat", "Snapchat"),
+ ("stripe", "Stripe"),
+ ("tiktok-ads", "Tiktok Ads"),
+ ("twilio", "Twilio"),
+ ("vercel", "Vercel"),
+ ],
+ max_length=32,
+ ),
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index e97f32a0d6e6..bd25447b4dbe 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1144_comment_task_fields
+1145_alter_integration_kind
diff --git a/posthog/models/integration.py b/posthog/models/integration.py
index d6839e90e1a0..3d89a3d2605d 100644
--- a/posthog/models/integration.py
+++ b/posthog/models/integration.py
@@ -15,12 +15,13 @@ if TYPE_CHECKING:
import aiohttp
from django.conf import settings
-from django.db import models
+from django.db import models, transaction
from django.http import HttpRequest
from django.utils import timezone
import requests
import structlog
+from anthropic import Anthropic, APIConnectionError, APIStatusError, AuthenticationError, PermissionDeniedError
from disposable_email_domains import blocklist as disposable_email_domains_list
from free_email_domains import whitelist as free_email_domains_list
from google.auth.transport.requests import Request as GoogleRequest
@@ -42,7 +43,7 @@ from posthog.models.github_integration_base import GitHubIntegrationBase, GitHub
from posthog.models.instance_setting import get_instance_settings
from posthog.models.oauth import OAuthAccessToken, OAuthApplication, OAuthRefreshToken
from posthog.models.user import User
-from posthog.models.utils import generate_random_oauth_access_token, generate_random_oauth_refresh_token
+from posthog.models.utils import IntegrityError, generate_random_oauth_access_token, generate_random_oauth_refresh_token
from posthog.plugins.plugin_server_api import reload_integrations_on_workers
from posthog.rbac.decorators import field_access_control
from posthog.security.url_validation import is_url_allowed
@@ -144,6 +145,7 @@ ERROR_TOKEN_REFRESH_FAILED = "TOKEN_REFRESH_FAILED"
class Integration(models.Model):
class IntegrationKind(models.TextChoices):
+ ANTHROPIC = "anthropic"
APPLE_PUSH = "apns"
AZURE_BLOB = "azure-blob"
BING_ADS = "bing-ads"
@@ -3044,6 +3046,169 @@ class TwilioIntegration:
return integration
+ANTHROPIC_MANAGED_AGENTS_BETA_HEADER = "managed-agents-2026-04-01"
+ANTHROPIC_DEFAULT_INTEGRATION_ID_PREFIX = "workspace-"
+ANTHROPIC_WORKSPACE_LABEL_MAX_LENGTH = 100
+ANTHROPIC_MANAGED_AGENT_LIST_PAGE_LIMIT = 100
+# 5s connect / 15s read are aggressive enough to keep gunicorn workers from
+# being pinned for ~minutes on a slow Anthropic upstream while still leaving
+# headroom for normal API latency.
+ANTHROPIC_CLIENT_TIMEOUT_SECONDS = 15.0
+
+
+class AnthropicIntegrationError(Exception):
+ """Raised when the AnthropicIntegration is constructed with an invalid Integration row."""
+
+
+def _build_anthropic_client(api_key: str) -> Anthropic:
+ # Tight timeouts and no SDK-side retries: we don't want a slow upstream to
+ # multiply request time by 3 (default `max_retries=2`) inside a Django worker.
+ return Anthropic(api_key=api_key, timeout=ANTHROPIC_CLIENT_TIMEOUT_SECONDS, max_retries=0)
+
+
+class AnthropicIntegration:
+ integration: Integration
+ _client: Anthropic
+
+ def __init__(self, integration: Integration) -> None:
+ if integration.kind != Integration.IntegrationKind.ANTHROPIC.value:
+ # Internal misuse, not a user-input issue.
+ raise AnthropicIntegrationError(
+ f"AnthropicIntegration init called with Integration kind={integration.kind!r}"
+ )
+ self.integration = integration
+ api_key = integration.sensitive_config.get("api_key")
+ if not api_key:
+ raise AnthropicIntegrationError(f"Anthropic integration {integration.id} is missing 'api_key'")
+ self._client = _build_anthropic_client(api_key)
+
+ @staticmethod
+ def validate_key(api_key: str) -> None:
+ # Validate by hitting the actual managed-agents surface so a key without
+ # beta access fails at create time instead of silently failing later.
+ try:
+ client = _build_anthropic_client(api_key)
+ client.get(
+ "/v1/agents",
+ cast_to=dict[str, object],
+ options={
+ "headers": {"anthropic-beta": ANTHROPIC_MANAGED_AGENTS_BETA_HEADER},
+ "params": {"limit": 1},
+ },
+ )
+ except AuthenticationError:
+ raise ValidationError({"api_key": "Invalid Anthropic API key"})
+ except PermissionDeniedError:
+ raise ValidationError(
+ {
+ "api_key": (
+ "Anthropic API key is missing required permissions. Make sure the key has access to the "
+ "Managed Agents beta in your Anthropic console."
+ )
+ }
+ )
+ except APIConnectionError:
+ logger.warning("anthropic_validate_key_connection_error", exc_info=True)
+ raise ValidationError(
+ {"api_key": "Could not reach Anthropic to validate the API key. Check your network and try again."}
+ )
+ except APIStatusError as e:
+ logger.warning("anthropic_validate_key_status_error", status_code=e.status_code, exc_info=True)
+ raise ValidationError(
+ {"api_key": f"Anthropic returned an error validating the API key (HTTP {e.status_code})."}
+ )
+
+ def _managed_agents_get(self, path: str, params: dict[str, Any] | None = None) -> dict:
+ return self._client.get(
+ path,
+ cast_to=dict[str, object],
+ options={
+ "headers": {"anthropic-beta": ANTHROPIC_MANAGED_AGENTS_BETA_HEADER},
+ "params": params or {},
+ },
+ )
+
+ def _list_managed_agents_resource(self, path: str, after: str | None, limit: int) -> tuple[list[dict], str | None]:
+ params: dict[str, Any] = {"limit": min(max(int(limit), 1), ANTHROPIC_MANAGED_AGENT_LIST_PAGE_LIMIT)}
+ if after:
+ params["after"] = after
+ response = self._managed_agents_get(path, params=params)
+ raw_data = response.get("data", [])
+ data: list[dict] = [item for item in raw_data if isinstance(item, dict)] if isinstance(raw_data, list) else []
+ next_cursor = response.get("next_cursor")
+ return data, next_cursor if isinstance(next_cursor, str) else None
+
+ def list_managed_agents(
+ self, after: str | None = None, limit: int = ANTHROPIC_MANAGED_AGENT_LIST_PAGE_LIMIT
+ ) -> tuple[list[dict], str | None]:
+ return self._list_managed_agents_resource("/v1/agents", after=after, limit=limit)
+
+ def list_managed_agent_environments(
+ self, after: str | None = None, limit: int = ANTHROPIC_MANAGED_AGENT_LIST_PAGE_LIMIT
+ ) -> tuple[list[dict], str | None]:
+ return self._list_managed_agents_resource("/v1/environments", after=after, limit=limit)
+
+ def list_managed_agent_vaults(
+ self, after: str | None = None, limit: int = ANTHROPIC_MANAGED_AGENT_LIST_PAGE_LIMIT
+ ) -> tuple[list[dict], str | None]:
+ return self._list_managed_agents_resource("/v1/vaults", after=after, limit=limit)
+
+ @classmethod
+ def integration_from_key(
+ cls,
+ api_key: str,
+ team_id: int,
+ created_by: User,
+ workspace_label: str | None = None,
+ force: bool = False,
+ ) -> Integration:
+ cls.validate_key(api_key)
+
+ anthropic_kind: str = Integration.IntegrationKind.ANTHROPIC.value
+ integration_id = workspace_label or f"{ANTHROPIC_DEFAULT_INTEGRATION_ID_PREFIX}{team_id}"
+ config: dict[str, Any] = {}
+ if workspace_label:
+ config["workspace_label"] = workspace_label
+
+ if force:
+ integration, _ = Integration.objects.update_or_create(
+ team_id=team_id,
+ kind=anthropic_kind,
+ integration_id=integration_id,
+ defaults={
+ "config": config,
+ "sensitive_config": {"api_key": api_key},
+ "created_by": created_by,
+ "errors": "",
+ },
+ )
+ return integration
+
+ try:
+ # Wrap in a savepoint so the unique-constraint IntegrityError below
+ # aborts only the INSERT, not the surrounding transaction (e.g. the
+ # outer DRF request atomic block, or the test wrapper).
+ with transaction.atomic():
+ return Integration.objects.create(
+ team_id=team_id,
+ kind=anthropic_kind,
+ integration_id=integration_id,
+ config=config,
+ sensitive_config={"api_key": api_key},
+ created_by=created_by,
+ errors="",
+ )
+ except IntegrityError:
+ raise ValidationError(
+ {
+ "config": (
+ f"An integration with id '{integration_id}' already exists for this team. Choose a different "
+ "workspace label, delete the existing integration and try again, or set 'force' to true to overwrite the existing integration."
+ )
+ }
+ )
+
+
class DatabricksIntegrationError(Exception):
"""Error raised when the Databricks integration is not valid."""
diff --git a/products/integrations/frontend/generated/api.schemas.ts b/products/integrations/frontend/generated/api.schemas.ts
index 3476ad2c518f..5e729cee99d6 100644
--- a/products/integrations/frontend/generated/api.schemas.ts
+++ b/products/integrations/frontend/generated/api.schemas.ts
@@ -153,7 +153,8 @@ export interface RoleLookupResponseApi {
}
/**
- * * `apns` - Apple Push
+ * * `anthropic` - Anthropic
+ * `apns` - Apple Push
* `azure-blob` - Azure Blob
* `bing-ads` - Bing Ads
* `clickup` - Clickup
@@ -191,6 +192,7 @@ export interface RoleLookupResponseApi {
export type IntegrationKindEnumApi = (typeof IntegrationKindEnumApi)[keyof typeof IntegrationKindEnumApi]
export const IntegrationKindEnumApi = {
+ Anthropic: 'anthropic',
Apns: 'apns',
AzureBlob: 'azure-blob',
BingAds: 'bing-ads',
@@ -416,7 +418,8 @@ export type RoleExternalReferencesLookupRetrieveParams = {
export type IntegrationsListParams = {
/**
- * * `apns` - Apple Push
+ * * `anthropic` - Anthropic
+ * `apns` - Apple Push
* `azure-blob` - Azure Blob
* `bing-ads` - Bing Ads
* `clickup` - Clickup
@@ -465,6 +468,7 @@ export type IntegrationsListParams = {
export type IntegrationsListKind = (typeof IntegrationsListKind)[keyof typeof IntegrationsListKind]
export const IntegrationsListKind = {
+ Anthropic: 'anthropic',
Apns: 'apns',
AzureBlob: 'azure-blob',
BingAds: 'bing-ads',
diff --git a/products/integrations/frontend/generated/api.ts b/products/integrations/frontend/generated/api.ts
index 05033c2020d9..975f70a9ae8d 100644
--- a/products/integrations/frontend/generated/api.ts
+++ b/products/integrations/frontend/generated/api.ts
@@ -241,6 +241,51 @@ export const integrationsDestroy = async (projectId: string, id: number, options
})
}
+export const getIntegrationsAnthropicManagedAgentEnvsRetrieveUrl = (projectId: string, id: number) => {
+ return `/api/projects/${projectId}/integrations/${id}/anthropic_managed_agent_environments/`
+}
+
+export const integrationsAnthropicManagedAgentEnvsRetrieve = async (
+ projectId: string,
+ id: number,
+ options?: RequestInit
+): Promise<void> => {
+ return apiMutator<void>(getIntegrationsAnthropicManagedAgentEnvsRetrieveUrl(projectId, id), {
+ ...options,
+ method: 'GET',
+ })
+}
+
+export const getIntegrationsAnthropicManagedAgentVaultsRetrieveUrl = (projectId: string, id: number) => {
+ return `/api/projects/${projectId}/integrations/${id}/anthropic_managed_agent_vaults/`
+}
+
+export const integrationsAnthropicManagedAgentVaultsRetrieve = async (
+ projectId: string,
+ id: number,
+ options?: RequestInit
+): Promise<void> => {
+ return apiMutator<void>(getIntegrationsAnthropicManagedAgentVaultsRetrieveUrl(projectId, id), {
+ ...options,
+ method: 'GET',
+ })
+}
+
+export const getIntegrationsAnthropicManagedAgentsRetrieveUrl = (projectId: string, id: number) => {
+ return `/api/projects/${projectId}/integrations/${id}/anthropic_managed_agents/`
+}
+
+export const integrationsAnthropicManagedAgentsRetrieve = async (
+ projectId: string,
+ id: number,
+ options?: RequestInit
+): Promise<void> => {
+ return apiMutator<void>(getIntegrationsAnthropicManagedAgentsRetrieveUrl(projectId, id), {
+ ...options,
+ method: 'GET',
+ })
+}
+
export const getIntegrationsChannelsRetrieveUrl = (projectId: string, id: number) => {
return `/api/projects/${projectId}/integrations/${id}/channels/`
}
diff --git a/products/integrations/frontend/generated/api.zod.ts b/products/integrations/frontend/generated/api.zod.ts
index c003934ae443..982c0e2f02b6 100644
--- a/products/integrations/frontend/generated/api.zod.ts
+++ b/products/integrations/frontend/generated/api.zod.ts
@@ -62,6 +62,7 @@ export const IntegrationsCreateBody = /* @__PURE__ */ zod
.object({
kind: zod
.enum([
+ 'anthropic',
'apns',
'azure-blob',
'bing-ads',
@@ -98,7 +99,7 @@ export const IntegrationsCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
+ '* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -108,6 +109,7 @@ export const IntegrationsEmailPartialUpdateBody = /* @__PURE__ */ zod
.object({
kind: zod
.enum([
+ 'anthropic',
'apns',
'azure-blob',
'bing-ads',
@@ -145,7 +147,7 @@ export const IntegrationsEmailPartialUpdateBody = /* @__PURE__ */ zod
])
.optional()
.describe(
- '* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
+ '* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -155,6 +157,7 @@ export const IntegrationsEmailVerifyCreateBody = /* @__PURE__ */ zod
.object({
kind: zod
.enum([
+ 'anthropic',
'apns',
'azure-blob',
'bing-ads',
@@ -191,7 +194,7 @@ export const IntegrationsEmailVerifyCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
+ '* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -208,6 +211,7 @@ export const IntegrationsDomainConnectApplyUrlCreateBody = /* @__PURE__ */ zod
.object({
kind: zod
.enum([
+ 'anthropic',
'apns',
'azure-blob',
'bing-ads',
@@ -244,7 +248,7 @@ export const IntegrationsDomainConnectApplyUrlCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
+ '* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -257,6 +261,7 @@ export const IntegrationsGithubLinkExistingCreateBody = /* @__PURE__ */ zod
.object({
kind: zod
.enum([
+ 'anthropic',
'apns',
'azure-blob',
'bing-ads',
@@ -293,7 +298,7 @@ export const IntegrationsGithubLinkExistingCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
+ '* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -306,6 +311,7 @@ export const IntegrationsGithubOauthAuthorizeCreateBody = /* @__PURE__ */ zod
.object({
kind: zod
.enum([
+ 'anthropic',
'apns',
'azure-blob',
'bing-ads',
@@ -342,7 +348,7 @@ export const IntegrationsGithubOauthAuthorizeCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
+ '* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
diff --git a/products/integrations/mcp/tools.yaml b/products/integrations/mcp/tools.yaml
index c40862c45809..2f681c7f7228 100644
--- a/products/integrations/mcp/tools.yaml
+++ b/products/integrations/mcp/tools.yaml
@@ -43,6 +43,15 @@ tools:
- errors
- created_at
- created_by
+ integrations-anthropic-managed-agent-envs-retrieve:
+ operation: integrations_anthropic_managed_agent_envs_retrieve
+ enabled: false
+ integrations-anthropic-managed-agent-vaults-retrieve:
+ operation: integrations_anthropic_managed_agent_vaults_retrieve
+ enabled: false
+ integrations-anthropic-managed-agents-retrieve:
+ operation: integrations_anthropic_managed_agents_retrieve
+ enabled: false
integrations-authorize-retrieve:
operation: integrations_authorize_retrieve
enabled: false
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index d12500840997..560e4399cc97 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -20815,7 +20815,8 @@ export namespace Schemas {
}
/**
- * * `apns` - Apple Push
+ * * `anthropic` - Anthropic
+ * `apns` - Apple Push
* `azure-blob` - Azure Blob
* `bing-ads` - Bing Ads
* `clickup` - Clickup
@@ -20854,6 +20855,7 @@ export namespace Schemas {
export const IntegrationKindEnum = {
+ Anthropic: 'anthropic',
Apns: 'apns',
AzureBlob: 'azure-blob',
BingAds: 'bing-ads',
@@ -39823,7 +39825,8 @@ export namespace Schemas {
export type EnvironmentsIntegrationsListParams = {
/**
- * * `apns` - Apple Push
+ * * `anthropic` - Anthropic
+ * `apns` - Apple Push
* `azure-blob` - Azure Blob
* `bing-ads` - Bing Ads
* `clickup` - Clickup
@@ -39873,6 +39876,7 @@ export namespace Schemas {
export const EnvironmentsIntegrationsListKind = {
+ Anthropic: 'anthropic',
Apns: 'apns',
AzureBlob: 'azure-blob',
BingAds: 'bing-ads',
@@ -44432,7 +44436,8 @@ export namespace Schemas {
export type IntegrationsListParams = {
/**
- * * `apns` - Apple Push
+ * * `anthropic` - Anthropic
+ * `apns` - Apple Push
* `azure-blob` - Azure Blob
* `bing-ads` - Bing Ads
* `clickup` - Clickup
@@ -44482,6 +44487,7 @@ export namespace Schemas {
export const IntegrationsListKind = {
+ Anthropic: 'anthropic',
Apns: 'apns',
AzureBlob: 'azure-blob',
BingAds: 'bing-ads',
diff --git a/services/mcp/src/generated/integrations/api.ts b/services/mcp/src/generated/integrations/api.ts
index 2acf8d8fb64a..63ed1595778d 100644
--- a/services/mcp/src/generated/integrations/api.ts
+++ b/services/mcp/src/generated/integrations/api.ts
@@ -19,6 +19,7 @@ export const IntegrationsListParams = /* @__PURE__ */ zod.object({
export const IntegrationsListQueryParams = /* @__PURE__ */ zod.object({
kind: zod
.enum([
+ 'anthropic',
'apns',
'azure-blob',
'bing-ads',
@@ -56,7 +57,7 @@ export const IntegrationsListQueryParams = /* @__PURE__ */ zod.object({
])
.optional()
.describe(
- '* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
+ '* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel'
),
limit: zod.number().optional().describe('Number of results to return per page.'),
offset: zod.number().optional().describe('The initial index from which to return the results.'),
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/integrations-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/integrations-list.json
index 0bcfce3624d7..c482bae04ed7 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/integrations-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/integrations-list.json
@@ -2,8 +2,9 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"kind": {
- "description": "* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel",
+ "description": "* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel",
"enum": [
+ "anthropic",
"apns",
"azure-blob",
"bing-ads",