: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(integrations): add kind filter and exclude config from MCP responses (#57135)
Vojta Bartošc67473ab466b
diff --git a/posthog/api/integration.py b/posthog/api/integration.pyindex edf61b421658..137782e23f4b 100644--- a/posthog/api/integration.py+++ b/posthog/api/integration.py@@ -16,6 +16,7 @@ from django.utils.crypto import get_random_stringimport stripeimport requestsimport structlog+from django_filters.rest_framework import DjangoFilterBackendfrom drf_spectacular.utils import extend_schema, extend_schema_serializerfrom rest_framework import mixins, serializers, viewsetsfrom rest_framework.exceptions import ValidationError@@ -581,6 +582,8 @@ class IntegrationViewSet(permission_classes = [TeamMemberStrictManagementPermission]queryset = defer_repository_cache_fields(Integration.objects.all())serializer_class = IntegrationSerializer+ filter_backends = [DjangoFilterBackend]+ filterset_fields = ["kind"]def dangerously_get_permissions(self):if self.action == "refresh_github_repos":diff --git a/posthog/api/test/test_integration.py b/posthog/api/test/test_integration.pyindex 226dd22b9e65..61c5485d5505 100644--- a/posthog/api/test/test_integration.py+++ b/posthog/api/test/test_integration.py@@ -1057,6 +1057,16 @@ class TestIntegrationAPIKeyAccess:assert "github" in kindsassert "twilio" in kinds+ def test_list_integrations_filtered_by_kind(self, client: HttpClient):+ client.force_login(self.user)++ response = client.get(f"/api/environments/{self.team.pk}/integrations/?kind=twilio")++ assert response.status_code == status.HTTP_200_OK+ results = response.json()["results"]+ assert len(results) == 1+ assert results[0]["kind"] == "twilio"+class TestGitHubIntegrationStateValidation:@pytest.fixture(autouse=True)diff --git a/products/integrations/frontend/generated/api.schemas.ts b/products/integrations/frontend/generated/api.schemas.tsindex bdfa1794773f..3476ad2c518f 100644--- a/products/integrations/frontend/generated/api.schemas.ts+++ b/products/integrations/frontend/generated/api.schemas.ts@@ -415,6 +415,43 @@ export type RoleExternalReferencesLookupRetrieveParams = {}export type IntegrationsListParams = {+ /**+ * * `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+ */+ kind?: IntegrationsListKind/*** Number of results to return per page.*/@@ -425,6 +462,45 @@ export type IntegrationsListParams = {offset?: number}+export type IntegrationsListKind = (typeof IntegrationsListKind)[keyof typeof IntegrationsListKind]++export const IntegrationsListKind = {+ Apns: 'apns',+ AzureBlob: 'azure-blob',+ BingAds: 'bing-ads',+ Clickup: 'clickup',+ CustomerioApp: 'customerio-app',+ CustomerioTrack: 'customerio-track',+ CustomerioWebhook: 'customerio-webhook',+ Databricks: 'databricks',+ Email: 'email',+ Firebase: 'firebase',+ Github: 'github',+ Gitlab: 'gitlab',+ GoogleAds: 'google-ads',+ GoogleCloudServiceAccount: 'google-cloud-service-account',+ GoogleCloudStorage: 'google-cloud-storage',+ GooglePubsub: 'google-pubsub',+ GoogleSheets: 'google-sheets',+ Hubspot: 'hubspot',+ Intercom: 'intercom',+ Jira: 'jira',+ Linear: 'linear',+ LinkedinAds: 'linkedin-ads',+ MetaAds: 'meta-ads',+ PinterestAds: 'pinterest-ads',+ Postgresql: 'postgresql',+ RedditAds: 'reddit-ads',+ Salesforce: 'salesforce',+ Slack: 'slack',+ SlackPosthogCode: 'slack-posthog-code',+ Snapchat: 'snapchat',+ Stripe: 'stripe',+ TiktokAds: 'tiktok-ads',+ Twilio: 'twilio',+ Vercel: 'vercel',+} as const+export type IntegrationsGithubBranchesRetrieveParams = {/*** Maximum number of branches to returndiff --git a/products/integrations/mcp/tools.yaml b/products/integrations/mcp/tools.yamlindex 5db31316aec8..c40862c45809 100644--- a/products/integrations/mcp/tools.yaml+++ b/products/integrations/mcp/tools.yaml@@ -33,8 +33,16 @@ tools:idempotent: truetitle: Get integrationdescription: >- Get a specific integration by ID. Returns the full integration details including kind, display name,- non-sensitive configuration, error status, and creation metadata. Does not expose sensitive credentials.+ Get a specific integration by ID. Returns full integration details including kind, display name, error+ status, and creation metadata. Does not expose sensitive credentials or raw configuration.+ response:+ include:+ - id+ - kind+ - display_name+ - errors+ - created_at+ - created_byintegrations-authorize-retrieve:operation: integrations_authorize_retrieveenabled: false@@ -132,6 +140,13 @@ tools:display name, non-sensitive configuration, error status, and creation metadata. Common kinds include slack,github, hubspot, salesforce, and various ad platforms. Sensitive credentials (access tokens, secrets) arenever serialized.+ response:+ include:+ - id+ - kind+ - display_name+ - created_at+ - created_byintegrations-twilio-phone-numbers-retrieve:operation: integrations_twilio_phone_numbers_retrieveenabled: falsediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 2f47007b6403..5c8df159f447 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -2100,7 +2100,7 @@}},"integration-get": {- "description": "Get a specific integration by ID. Returns the full integration details including kind, display name, non-sensitive configuration, error status, and creation metadata. Does not expose sensitive credentials.",+ "description": "Get a specific integration by ID. Returns full integration details including kind, display name, error status, and creation metadata. Does not expose sensitive credentials or raw configuration.","category": "Integrations","feature": "integrations","summary": "Get integration",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 743316798ed5..48e243a81b9f 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -2413,7 +2413,7 @@}},"integration-get": {- "description": "Get a specific integration by ID. Returns the full integration details including kind, display name, non-sensitive configuration, error status, and creation metadata. Does not expose sensitive credentials.",+ "description": "Get a specific integration by ID. Returns full integration details including kind, display name, error status, and creation metadata. Does not expose sensitive credentials or raw configuration.","category": "Integrations","feature": "integrations","summary": "Get integration",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex e46b6189844c..b336816309cb 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -39644,6 +39644,43 @@ export namespace Schemas {} as const;export type EnvironmentsIntegrationsListParams = {+ /**+ * * `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+ */+ kind?: EnvironmentsIntegrationsListKind;/*** Number of results to return per page.*/@@ -39654,6 +39691,46 @@ export namespace Schemas {offset?: number;};+ export type EnvironmentsIntegrationsListKind = typeof EnvironmentsIntegrationsListKind[keyof typeof EnvironmentsIntegrationsListKind];+++ export const EnvironmentsIntegrationsListKind = {+ Apns: 'apns',+ AzureBlob: 'azure-blob',+ BingAds: 'bing-ads',+ Clickup: 'clickup',+ CustomerioApp: 'customerio-app',+ CustomerioTrack: 'customerio-track',+ CustomerioWebhook: 'customerio-webhook',+ Databricks: 'databricks',+ Email: 'email',+ Firebase: 'firebase',+ Github: 'github',+ Gitlab: 'gitlab',+ GoogleAds: 'google-ads',+ GoogleCloudServiceAccount: 'google-cloud-service-account',+ GoogleCloudStorage: 'google-cloud-storage',+ GooglePubsub: 'google-pubsub',+ GoogleSheets: 'google-sheets',+ Hubspot: 'hubspot',+ Intercom: 'intercom',+ Jira: 'jira',+ Linear: 'linear',+ LinkedinAds: 'linkedin-ads',+ MetaAds: 'meta-ads',+ PinterestAds: 'pinterest-ads',+ Postgresql: 'postgresql',+ RedditAds: 'reddit-ads',+ Salesforce: 'salesforce',+ Slack: 'slack',+ SlackPosthogCode: 'slack-posthog-code',+ Snapchat: 'snapchat',+ Stripe: 'stripe',+ TiktokAds: 'tiktok-ads',+ Twilio: 'twilio',+ Vercel: 'vercel',+ } as const;+export type EnvironmentsIntegrationsGithubBranchesRetrieveParams = {/*** Maximum number of branches to return@@ -44105,6 +44182,43 @@ export namespace Schemas {} as const;export type IntegrationsListParams = {+ /**+ * * `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+ */+ kind?: IntegrationsListKind;/*** Number of results to return per page.*/@@ -44115,6 +44229,46 @@ export namespace Schemas {offset?: number;};+ export type IntegrationsListKind = typeof IntegrationsListKind[keyof typeof IntegrationsListKind];+++ export const IntegrationsListKind = {+ Apns: 'apns',+ AzureBlob: 'azure-blob',+ BingAds: 'bing-ads',+ Clickup: 'clickup',+ CustomerioApp: 'customerio-app',+ CustomerioTrack: 'customerio-track',+ CustomerioWebhook: 'customerio-webhook',+ Databricks: 'databricks',+ Email: 'email',+ Firebase: 'firebase',+ Github: 'github',+ Gitlab: 'gitlab',+ GoogleAds: 'google-ads',+ GoogleCloudServiceAccount: 'google-cloud-service-account',+ GoogleCloudStorage: 'google-cloud-storage',+ GooglePubsub: 'google-pubsub',+ GoogleSheets: 'google-sheets',+ Hubspot: 'hubspot',+ Intercom: 'intercom',+ Jira: 'jira',+ Linear: 'linear',+ LinkedinAds: 'linkedin-ads',+ MetaAds: 'meta-ads',+ PinterestAds: 'pinterest-ads',+ Postgresql: 'postgresql',+ RedditAds: 'reddit-ads',+ Salesforce: 'salesforce',+ Slack: 'slack',+ SlackPosthogCode: 'slack-posthog-code',+ Snapchat: 'snapchat',+ Stripe: 'stripe',+ TiktokAds: 'tiktok-ads',+ Twilio: 'twilio',+ Vercel: 'vercel',+ } as const;+export type IntegrationsGithubBranchesRetrieveParams = {/*** Maximum number of branches to returndiff --git a/services/mcp/src/generated/integrations/api.ts b/services/mcp/src/generated/integrations/api.tsindex 103a95a0db7c..2acf8d8fb64a 100644--- a/services/mcp/src/generated/integrations/api.ts+++ b/services/mcp/src/generated/integrations/api.ts@@ -17,6 +17,47 @@ export const IntegrationsListParams = /* @__PURE__ */ zod.object({})export const IntegrationsListQueryParams = /* @__PURE__ */ zod.object({+ kind: zod+ .enum([+ 'apns',+ 'azure-blob',+ 'bing-ads',+ 'clickup',+ 'customerio-app',+ 'customerio-track',+ 'customerio-webhook',+ 'databricks',+ 'email',+ 'firebase',+ 'github',+ 'gitlab',+ 'google-ads',+ 'google-cloud-service-account',+ 'google-cloud-storage',+ 'google-pubsub',+ 'google-sheets',+ 'hubspot',+ 'intercom',+ 'jira',+ 'linear',+ 'linkedin-ads',+ 'meta-ads',+ 'pinterest-ads',+ 'postgresql',+ 'reddit-ads',+ 'salesforce',+ 'slack',+ 'slack-posthog-code',+ 'snapchat',+ 'stripe',+ 'tiktok-ads',+ 'twilio',+ 'vercel',+ ])+ .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'+ ),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/src/tools/generated/integrations.ts b/services/mcp/src/tools/generated/integrations.tsindex 5249b014c722..0ace0730ea5e 100644--- a/services/mcp/src/tools/generated/integrations.ts+++ b/services/mcp/src/tools/generated/integrations.ts@@ -8,7 +8,7 @@ import {IntegrationsListQueryParams,IntegrationsRetrieveParams,} from '@/generated/integrations/api'-import { withPostHogUrl, type WithPostHogUrl } from '@/tools/tool-utils'+import { withPostHogUrl, pickResponseFields, type WithPostHogUrl } from '@/tools/tool-utils'import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'const IntegrationDeleteSchema = IntegrationsDestroyParams.omit({ project_id: true })@@ -37,7 +37,15 @@ const integrationGet = (): ToolBase<typeof IntegrationGetSchema, Schemas.Integramethod: 'GET',path: `/api/projects/${encodeURIComponent(String(projectId))}/integrations/${encodeURIComponent(String(params.id))}/`,})- return result+ const filtered = pickResponseFields(result, [+ 'id',+ 'kind',+ 'display_name',+ 'errors',+ 'created_at',+ 'created_by',+ ]) as typeof result+ return filtered},})@@ -73,11 +81,18 @@ const integrationsList = (): ToolBase<method: 'GET',path: `/api/projects/${encodeURIComponent(String(projectId))}/integrations/`,query: {+ kind: params.kind,limit: params.limit,offset: params.offset,},})- return await withPostHogUrl(context, result, '/settings/integrations')+ const filtered = {+ ...result,+ results: (result.results ?? []).map((item: any) =>+ pickResponseFields(item, ['id', 'kind', 'display_name', 'created_at', 'created_by'])+ ),+ } as typeof result+ return await withPostHogUrl(context, filtered, '/settings/integrations')},})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.jsonindex 8331b796ac73..0bcfce3624d7 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@@ -1,6 +1,46 @@{"$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",+ "enum": [+ "apns",+ "azure-blob",+ "bing-ads",+ "clickup",+ "customerio-app",+ "customerio-track",+ "customerio-webhook",+ "databricks",+ "email",+ "firebase",+ "github",+ "gitlab",+ "google-ads",+ "google-cloud-service-account",+ "google-cloud-storage",+ "google-pubsub",+ "google-sheets",+ "hubspot",+ "intercom",+ "jira",+ "linear",+ "linkedin-ads",+ "meta-ads",+ "pinterest-ads",+ "postgresql",+ "reddit-ads",+ "salesforce",+ "slack",+ "slack-posthog-code",+ "snapchat",+ "stripe",+ "tiktok-ads",+ "twilio",+ "vercel"+ ],+ "type": "string"+ },"limit": {"description": "Number of results to return per page.","type": "number"