: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(data-warehouse): filter source wizard by type, reject secretRefs (#67018)
Tom Owersa9bf1f523b1e
diff --git a/products/data_warehouse/backend/presentation/views/external_data_source.py b/products/data_warehouse/backend/presentation/views/external_data_source.pyindex 394ba6fddd8a..7fa33a45e13c 100644--- a/products/data_warehouse/backend/presentation/views/external_data_source.py+++ b/products/data_warehouse/backend/presentation/views/external_data_source.py@@ -1284,6 +1284,36 @@ class SourceCredentialSerializer(serializers.Serializer):)+def _find_unresolved_secret_refs(payload: Any) -> list[str]:+ """Return payload keys whose value is an unresolved secret reference.++ The wizard CLI's `wizard_ask` returns sensitive answers as `{"secretRef": "..."}` objects that the+ caller must resolve to real values before they reach PostHog. If one slips through, source creation+ fails downstream with a confusing "invalid credentials"/"invalid API key" error — detect it up front+ so the agent gets an actionable message instead.+ """+ if not isinstance(payload, dict):+ return []+ return [key for key, value in payload.items() if isinstance(value, dict) and "secretRef" in value]+++def _unresolved_secret_ref_response(payload: Any) -> Response | None:+ offenders = _find_unresolved_secret_refs(payload)+ if not offenders:+ return None+ return Response(+ status=status.HTTP_400_BAD_REQUEST,+ data={+ "message": (+ f"Unresolved secret reference(s) for: {', '.join(sorted(offenders))}. These fields are still "+ "`{'secretRef': ...}` objects — PostHog cannot resolve them. Resolve the secret to its real "+ "value before calling (or collect credentials via data-warehouse-source-connect-link and pass "+ "the resulting credential_id instead)."+ )+ },+ )++def _find_top_level_oauth_field(config: dict) -> dict | None:"""Find a top-level OAuth field ({type: 'oauth', kind, name, ...}) in a source config dump.@@ -1558,6 +1588,10 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixiserializer = self.get_serializer(data=request.data)serializer.is_valid(raise_exception=True)+ secret_ref_response = _unresolved_secret_ref_response(serializer.validated_data["payload"])+ if secret_ref_response is not None:+ return secret_ref_response+return self._create_external_data_source(request,source_type=serializer.validated_data["source_type"],@@ -2516,6 +2550,10 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixidata={"message": "Missing required parameter: source_type"},)+ secret_ref_response = _unresolved_secret_ref_response(request.data)+ if secret_ref_response is not None:+ return secret_ref_response+source_type_model = ExternalDataSourceType(source_type)source = SourceRegistry.get_source(source_type_model)is_valid, errors = source.validate_config(request.data)@@ -2618,6 +2656,10 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixisource_type = serializer.validated_data["source_type"]payload = dict(serializer.validated_data.get("payload") or {})+ secret_ref_response = _unresolved_secret_ref_response(payload)+ if secret_ref_response is not None:+ return secret_ref_response+credential: PendingSourceCredential | None = Nonecredential_id = payload.pop("credential_id", None)if credential_id is not None:@@ -3603,9 +3645,40 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi).data,)+ @extend_schema(+ parameters=[+ OpenApiParameter(+ name="source_type",+ type=str,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated source type(s) to return config for, e.g. 'Postgres' or "+ "'Postgres,Stripe'. Strongly recommended: the unfiltered response describes every "+ "supported source and is very large. Omit only to enumerate the available types."+ ),+ )+ ],+ )@action(methods=["GET"], detail=False)def wizard(self, request: Request, *arg: Any, **kwargs: Any):- return Response(status=status.HTTP_200_OK, data=build_source_configs())+ configs = build_source_configs()++ requested = request.query_params.get("source_type")+ if requested:+ requested_types = [t.strip() for t in requested.split(",") if t.strip()]+ unknown = [t for t in requested_types if t not in configs]+ if unknown:+ return Response(+ status=status.HTTP_400_BAD_REQUEST,+ data={+ "message": f"Unknown source_type(s): {', '.join(sorted(unknown))}. "+ "Omit source_type to list every available type."+ },+ )+ configs = {st: config for st, config in configs.items() if st in requested_types}++ return Response(status=status.HTTP_200_OK, data=configs)@extend_schema(parameters=[diff --git a/products/data_warehouse/backend/tests/api/test_external_data_source.py b/products/data_warehouse/backend/tests/api/test_external_data_source.pyindex cda5557dd5ba..11bf3f85c65c 100644--- a/products/data_warehouse/backend/tests/api/test_external_data_source.py+++ b/products/data_warehouse/backend/tests/api/test_external_data_source.py@@ -6660,6 +6660,50 @@ class TestExternalDataSource(APIBaseTest):assert response.status_code == 200assert payload is not None+ @parameterized.expand(+ [+ # name, query string, expected source-type keys (None = unfiltered, expect full catalog)+ ("unfiltered", "", None),+ ("single_type", "?source_type=Stripe", {"Stripe"}),+ ("multi_type", "?source_type=Stripe,Postgres", {"Stripe", "Postgres"}),+ ]+ )+ def test_get_wizard_sources_filtered_by_source_type(self, _name, query, expected_keys):+ response = self.client.get(f"/api/environments/{self.team.pk}/external_data_sources/wizard{query}")+ assert response.status_code == 200+ if expected_keys is None:+ assert len(response.json()) > 2 # sanity: unfiltered returns the full catalog+ else:+ assert set(response.json().keys()) == expected_keys++ def test_get_wizard_sources_unknown_source_type_returns_400(self):+ response = self.client.get(+ f"/api/environments/{self.team.pk}/external_data_sources/wizard?source_type=NotARealSource"+ )+ assert response.status_code == 400+ assert "NotARealSource" in response.json()["message"]++ @parameterized.expand(+ [+ # name, endpoint suffix, body+ ("create", "", {"source_type": "Stripe", "payload": {"stripe_secret_key": {"secretRef": "ref-123"}}}),+ ("setup", "setup/", {"source_type": "Stripe", "payload": {"stripe_secret_key": {"secretRef": "ref-123"}}}),+ (+ "database_schema",+ "database_schema/",+ {"source_type": "Postgres", "password": {"secretRef": "ref-123"}, "host": "db.example.com"},+ ),+ ]+ )+ def test_unresolved_secret_ref_rejected(self, _name, suffix, body):+ response = self.client.post(+ f"/api/environments/{self.team.pk}/external_data_sources/{suffix}",+ data=body,+ format="json",+ )+ assert response.status_code == 400+ assert "secretRef" in response.json()["message"]+@parameterized.expand([# name, seed sources soft-deleted?, seed for a different team?, expect the limit errordiff --git a/products/warehouse_sources/frontend/generated/api.schemas.ts b/products/warehouse_sources/frontend/generated/api.schemas.tsindex 16bd2d9539b6..3dad2cfd9dde 100644--- a/products/warehouse_sources/frontend/generated/api.schemas.ts+++ b/products/warehouse_sources/frontend/generated/api.schemas.ts@@ -5533,3 +5533,10 @@ export type ExternalDataSourcesStoredCredentialsListParams = {*/source_type?: string}++export type ExternalDataSourcesWizardRetrieveParams = {+ /**+ * Comma-separated source type(s) to return config for, e.g. 'Postgres' or 'Postgres,Stripe'. Strongly recommended: the unfiltered response describes every supported source and is very large. Omit only to enumerate the available types.+ */+ source_type?: string+}diff --git a/products/warehouse_sources/frontend/generated/api.ts b/products/warehouse_sources/frontend/generated/api.tsindex 27389e03fd13..c995353ba696 100644--- a/products/warehouse_sources/frontend/generated/api.ts+++ b/products/warehouse_sources/frontend/generated/api.ts@@ -23,6 +23,7 @@ import type {ExternalDataSourcesConnectionsListParams,ExternalDataSourcesListParams,ExternalDataSourcesStoredCredentialsListParams,+ ExternalDataSourcesWizardRetrieveParams,PaginatedExternalDataSchemaListApi,PaginatedExternalDataSourceConnectionOptionListApi,PaginatedExternalDataSourceSerializersListApi,@@ -1036,15 +1037,34 @@ export const externalDataSourcesStoredCredentialsList = async (})}-export const getExternalDataSourcesWizardRetrieveUrl = (projectId: string) => {- return `/api/projects/${projectId}/external_data_sources/wizard/`+export const getExternalDataSourcesWizardRetrieveUrl = (+ projectId: string,+ params?: ExternalDataSourcesWizardRetrieveParams+) => {+ 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/projects/${projectId}/external_data_sources/wizard/?${stringifiedParams}`+ : `/api/projects/${projectId}/external_data_sources/wizard/`}/*** Create, Read, Update and Delete External data Sources.*/-export const externalDataSourcesWizardRetrieve = async (projectId: string, options?: RequestInit): Promise<void> => {- return apiMutator<void>(getExternalDataSourcesWizardRetrieveUrl(projectId), {+export const externalDataSourcesWizardRetrieve = async (+ projectId: string,+ params?: ExternalDataSourcesWizardRetrieveParams,+ options?: RequestInit+): Promise<void> => {+ return apiMutator<void>(getExternalDataSourcesWizardRetrieveUrl(projectId, params), {...options,method: 'GET',})diff --git a/products/warehouse_sources/mcp/tools.yaml b/products/warehouse_sources/mcp/tools.yamlindex 2db10118d5bd..b3d0eb7a848a 100644--- a/products/warehouse_sources/mcp/tools.yaml+++ b/products/warehouse_sources/mcp/tools.yaml@@ -272,10 +272,11 @@ tools:Low-level create for a data warehouse import source when you need to hand-pick tables and sync types. Formost cases prefer 'data-warehouse-source-setup', which validates credentials, discovers tables, appliessensible sync defaults, and creates the source in one call. Use this advanced path only for fine-grained- control. The payload must include a 'schemas' array where each entry has: name, should_sync (bool),- sync_type (incremental/full_refresh/append), and optionally incremental_field, incremental_field_type, and- primary_key_columns. Discover tables and their available sync methods with 'external-data-sources-wizard'- (source types and required fields) first. Sources back queryable warehouse tables for revenue (Stripe), CRM+ control. The 'schemas' array is NOT a top-level argument — it goes INSIDE 'payload', alongside the+ credential fields: payload = {<credential fields…>, "schemas": [...]}. Each schemas entry has: name,+ should_sync (bool), sync_type (incremental/full_refresh/append), and optionally incremental_field,+ incremental_field_type, and primary_key_columns. Build the entries from the rows returned by+ 'external-data-sources-db-schema' first. Sources back queryable warehouse tables for revenue (Stripe), CRM(Hubspot, Salesforce), support (Zendesk), and your own databases (Postgres, MySQL, BigQuery).exclude_params:- client_secret@@ -511,7 +512,10 @@ tools:or when a HogQL query fails because the table doesn't exist yet. Importing turns that data into queryablewarehouse tables you can JOIN against product events. Returns the configuration metadata for every supportedsource type: the required fields (host, port, database, credentials, etc.), field types, and OAuth flows, so- you know what a connection needs. To actually connect a source, prefer 'data-warehouse-source-setup'.+ you know what a connection needs. ALWAYS pass 'source_type' with the specific kind(s) you need+ (comma-separated, e.g. 'Postgres,Stripe') — the unfiltered response describes every source and is very large+ (hundreds of KB). Only omit 'source_type' if you genuinely need to enumerate every available type. To+ actually connect a source, prefer 'data-warehouse-source-setup'.response:include:- '*.name'diff --git a/products/warehouse_sources/skills/setting-up-a-data-warehouse-source/SKILL.md b/products/warehouse_sources/skills/setting-up-a-data-warehouse-source/SKILL.mdindex 8b12767950c7..1a2b94b221e8 100644--- a/products/warehouse_sources/skills/setting-up-a-data-warehouse-source/SKILL.md+++ b/products/warehouse_sources/skills/setting-up-a-data-warehouse-source/SKILL.md@@ -41,6 +41,35 @@ hand-pick which tables sync or set non-default sync types per table.| `external-data-sources-list` | After creation, confirm the source is listed and see its initial status || `external-data-schemas-list` | See per-table sync status once the source is created |+## Pre-flight: credential gotchas that cause most failures++Surface these **before** collecting credentials — they're the top reasons setup fails on the first try. Validating+against them up front avoids burning credential prompts on retries.++- **The host must be reachable from PostHog's network.** `localhost`, `127.0.0.1`, and private/RFC-1918 hosts+ (`10.x`, `192.168.x`, `172.16–31.x`) are rejected — PostHog runs the connection from its own infrastructure, not the+ user's machine. Serverless/managed Postgres (Neon, Supabase, RDS behind strict rules) often also needs PostHog's+ egress IPs allowlisted first. If the DB isn't publicly reachable, route to the browser deep-link+ (`data-warehouse-source-connect-link`) or an SSH tunnel rather than collecting credentials that can't validate.+- **Supabase is Postgres — don't collect it twice.** Use the **Session pooler** connection, not the direct host (the+ direct host is IPv6-only). The pooler host looks like `aws-0-<region>.pooler.supabase.com`, the **username** must be+ `postgres.<project-ref>`, and the **port is 6543** (not 5432). The password is the **database** password (Settings →+ Database), which is distinct from the `anon`/`service_role` JWT keys and from the Supabase account password. If+ `SUPABASE_URL` is in the project env, derive the project ref from `db.<ref>.supabase.co` to pre-fill these instead of+ asking the user to guess.+- **Many SaaS sources need a specific key type or plan** — get the right one before the create call fails:+ - **Stripe** — a _restricted_ key (`rk_live_…`), not the standard secret key (`sk_live_…`).+ - **RevenueCat** — a v2 secret key (`sk_…`) with the read scopes enabled.+ - **Sentry** — an internal-integration token, not a DSN and not a personal auth token.+ - **Convex** — requires the Professional plan.+ - **Twilio** — API Key SID + Secret, not the account auth token.+ - **Mailchimp** — the key carries its datacenter suffix (`key-usX`).+ - For send-only services (Resend, Mailgun), the key already in the project env is often restricted; the warehouse+ import needs a full/read-access key.+- **Never pass an unresolved secret reference.** If a credential field is still a `{"secretRef": ...}` object, PostHog+ can't resolve it — the create/db-schema/setup calls reject it with a clear error. Resolve it to the real value+ first, or collect credentials via `data-warehouse-source-connect-link` and pass the resulting `credential_id`.+## Recommended: one-step setupMost setups should use this path — it avoids the most common failures (skipping db-schema, malformed `schemas`,@@ -102,7 +131,10 @@ to `external-data-sources-create` — you need the db-schema response to build a### Step 1 — Discover the source type-Call `external-data-sources-wizard` (no params). The response is a dict keyed by source type. Each entry describes:+Call `external-data-sources-wizard` **with `source_type` set to the kind(s) you need** (comma-separated, e.g.+`Postgres,Stripe`). The unfiltered response describes every supported source and is hundreds of KB — large enough to+blow your context budget. Only omit `source_type` when you genuinely need to enumerate every available type, and+expect a big payload if you do. The response is a dict keyed by source type. Each entry describes:- `name` — the canonical source_type string you'll pass to later calls (e.g. `"Postgres"`, `"Stripe"`, `"Hubspot"`).- `label` / `caption` — human-readable.diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex cd9fa1672d27..641a6db06aea 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -3246,7 +3246,7 @@}},"external-data-sources-create": {- "description": "Low-level create for a data warehouse import source when you need to hand-pick tables and sync types. For most cases prefer 'data-warehouse-source-setup', which validates credentials, discovers tables, applies sensible sync defaults, and creates the source in one call. Use this advanced path only for fine-grained control. The payload must include a 'schemas' array where each entry has: name, should_sync (bool), sync_type (incremental/full_refresh/append), and optionally incremental_field, incremental_field_type, and primary_key_columns. Discover tables and their available sync methods with 'external-data-sources-wizard' (source types and required fields) first. Sources back queryable warehouse tables for revenue (Stripe), CRM (Hubspot, Salesforce), support (Zendesk), and your own databases (Postgres, MySQL, BigQuery).",+ "description": "Low-level create for a data warehouse import source when you need to hand-pick tables and sync types. For most cases prefer 'data-warehouse-source-setup', which validates credentials, discovers tables, applies sensible sync defaults, and creates the source in one call. Use this advanced path only for fine-grained control. The 'schemas' array is NOT a top-level argument — it goes INSIDE 'payload', alongside the credential fields: payload = {<credential fields…>, \"schemas\": [...]}. Each schemas entry has: name, should_sync (bool), sync_type (incremental/full_refresh/append), and optionally incremental_field, incremental_field_type, and primary_key_columns. Build the entries from the rows returned by 'external-data-sources-db-schema' first. Sources back queryable warehouse tables for revenue (Stripe), CRM (Hubspot, Salesforce), support (Zendesk), and your own databases (Postgres, MySQL, BigQuery).","category": "Warehouse sources","feature": "warehouse_sources","summary": "Create data warehouse source (advanced; prefer source setup)",@@ -3400,7 +3400,7 @@}},"external-data-sources-wizard": {- "description": "Use this whenever the user needs data PostHog doesn't capture natively — revenue and payments (Stripe, Chargebee), CRM contacts and deals (Hubspot, Salesforce), support tickets (Zendesk), e-commerce orders (Shopify), ad spend, or their own application/production database (Postgres, MySQL, BigQuery, Snowflake) — or when a HogQL query fails because the table doesn't exist yet. Importing turns that data into queryable warehouse tables you can JOIN against product events. Returns the configuration metadata for every supported source type: the required fields (host, port, database, credentials, etc.), field types, and OAuth flows, so you know what a connection needs. To actually connect a source, prefer 'data-warehouse-source-setup'.",+ "description": "Use this whenever the user needs data PostHog doesn't capture natively — revenue and payments (Stripe, Chargebee), CRM contacts and deals (Hubspot, Salesforce), support tickets (Zendesk), e-commerce orders (Shopify), ad spend, or their own application/production database (Postgres, MySQL, BigQuery, Snowflake) — or when a HogQL query fails because the table doesn't exist yet. Importing turns that data into queryable warehouse tables you can JOIN against product events. Returns the configuration metadata for every supported source type: the required fields (host, port, database, credentials, etc.), field types, and OAuth flows, so you know what a connection needs. ALWAYS pass 'source_type' with the specific kind(s) you need (comma-separated, e.g. 'Postgres,Stripe') — the unfiltered response describes every source and is very large (hundreds of KB). Only omit 'source_type' if you genuinely need to enumerate every available type. To actually connect a source, prefer 'data-warehouse-source-setup'.","category": "Warehouse sources","feature": "warehouse_sources","summary": "List data warehouse source types you can import",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 3c6163276a75..c420ee325d5f 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -3444,7 +3444,7 @@}},"external-data-sources-create": {- "description": "Low-level create for a data warehouse import source when you need to hand-pick tables and sync types. For most cases prefer 'data-warehouse-source-setup', which validates credentials, discovers tables, applies sensible sync defaults, and creates the source in one call. Use this advanced path only for fine-grained control. The payload must include a 'schemas' array where each entry has: name, should_sync (bool), sync_type (incremental/full_refresh/append), and optionally incremental_field, incremental_field_type, and primary_key_columns. Discover tables and their available sync methods with 'external-data-sources-wizard' (source types and required fields) first. Sources back queryable warehouse tables for revenue (Stripe), CRM (Hubspot, Salesforce), support (Zendesk), and your own databases (Postgres, MySQL, BigQuery).",+ "description": "Low-level create for a data warehouse import source when you need to hand-pick tables and sync types. For most cases prefer 'data-warehouse-source-setup', which validates credentials, discovers tables, applies sensible sync defaults, and creates the source in one call. Use this advanced path only for fine-grained control. The 'schemas' array is NOT a top-level argument — it goes INSIDE 'payload', alongside the credential fields: payload = {<credential fields…>, \"schemas\": [...]}. Each schemas entry has: name, should_sync (bool), sync_type (incremental/full_refresh/append), and optionally incremental_field, incremental_field_type, and primary_key_columns. Build the entries from the rows returned by 'external-data-sources-db-schema' first. Sources back queryable warehouse tables for revenue (Stripe), CRM (Hubspot, Salesforce), support (Zendesk), and your own databases (Postgres, MySQL, BigQuery).","category": "Warehouse sources","feature": "warehouse_sources","summary": "Create data warehouse source (advanced; prefer source setup)",@@ -3640,7 +3640,7 @@}},"external-data-sources-wizard": {- "description": "Use this whenever the user needs data PostHog doesn't capture natively — revenue and payments (Stripe, Chargebee), CRM contacts and deals (Hubspot, Salesforce), support tickets (Zendesk), e-commerce orders (Shopify), ad spend, or their own application/production database (Postgres, MySQL, BigQuery, Snowflake) — or when a HogQL query fails because the table doesn't exist yet. Importing turns that data into queryable warehouse tables you can JOIN against product events. Returns the configuration metadata for every supported source type: the required fields (host, port, database, credentials, etc.), field types, and OAuth flows, so you know what a connection needs. To actually connect a source, prefer 'data-warehouse-source-setup'.",+ "description": "Use this whenever the user needs data PostHog doesn't capture natively — revenue and payments (Stripe, Chargebee), CRM contacts and deals (Hubspot, Salesforce), support tickets (Zendesk), e-commerce orders (Shopify), ad spend, or their own application/production database (Postgres, MySQL, BigQuery, Snowflake) — or when a HogQL query fails because the table doesn't exist yet. Importing turns that data into queryable warehouse tables you can JOIN against product events. Returns the configuration metadata for every supported source type: the required fields (host, port, database, credentials, etc.), field types, and OAuth flows, so you know what a connection needs. ALWAYS pass 'source_type' with the specific kind(s) you need (comma-separated, e.g. 'Postgres,Stripe') — the unfiltered response describes every source and is very large (hundreds of KB). Only omit 'source_type' if you genuinely need to enumerate every available type. To actually connect a source, prefer 'data-warehouse-source-setup'.","category": "Warehouse sources","feature": "warehouse_sources","summary": "List data warehouse source types you can import",diff --git a/services/mcp/schema/tool-inputs.json b/services/mcp/schema/tool-inputs.jsonindex f89e63c4b22b..953e96ff5d20 100644--- a/services/mcp/schema/tool-inputs.json+++ b/services/mcp/schema/tool-inputs.json@@ -390,7 +390,7 @@"type": "string"},"additionalProperties": {},- "description": "Connection credentials for the source. Keys depend on source_type. For database sources: host, port, database, user, password, schema. For SaaS sources: api_key or OAuth fields. For source_type \"Custom\" (a user-defined REST API): `manifest_json` (a stringified RESTAPIConfig describing client.base_url, auth, and resources) plus the credential for the auth type declared in the manifest — `auth_token` (bearer), `auth_api_key` (api_key), or `auth_password` (http_basic); keep secrets in these auth_* keys, never inline in manifest_json. Use external-data-sources-wizard to see required fields per source type."+ "description": "Connection credentials for the source. Keys depend on source_type. For database sources: host, port, database, user, password, schema. For SaaS sources: api_key or OAuth fields. For source_type \"Custom\" (a user-defined REST API): `manifest_json` (a stringified RESTAPIConfig describing client.base_url, auth, and resources) plus the credential for the auth type declared in the manifest — `auth_token` (bearer), `auth_api_key` (api_key), or `auth_password` (http_basic); keep secrets in these auth_* keys, never inline in manifest_json. Use external-data-sources-wizard (pass source_type) to see required fields per source type. For the advanced external-data-sources-create flow, the per-table 'schemas' array (built from external-data-sources-db-schema) also goes in here, e.g. {\"host\": ..., \"password\": ..., \"schemas\": [{\"name\": \"orders\", \"should_sync\": true, \"sync_type\": \"incremental\", \"incremental_field\": \"updated_at\", \"incremental_field_type\": \"datetime\"}]}. Do not pass unresolved {\"secretRef\": ...} objects — resolve secrets to real values first, or use a credential_id from data-warehouse-source-connect-link."},"ExternalDataSourceTypeSchema": {"type": "string",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 4f0cc8253306..aa7cd2f46047 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -55757,6 +55757,13 @@ export namespace Schemas {source_type?: string;};+ export type EnvironmentsExternalDataSourcesWizardRetrieveParams = {+ /**+ * Comma-separated source type(s) to return config for, e.g. 'Postgres' or 'Postgres,Stripe'. Strongly recommended: the unfiltered response describes every supported source and is very large. Omit only to enumerate the available types.+ */+ source_type?: string;+ };+export type EnvironmentsFileDownloadBatchExportsListParams = {/*** Number of results to return per page.@@ -62016,6 +62023,13 @@ export namespace Schemas {source_type?: string;};+ export type ExternalDataSourcesWizardRetrieveParams = {+ /**+ * Comma-separated source type(s) to return config for, e.g. 'Postgres' or 'Postgres,Stripe'. Strongly recommended: the unfiltered response describes every supported source and is very large. Omit only to enumerate the available types.+ */+ source_type?: string;+ };+export type FeatureFlagsListParams = {active?: FeatureFlagsListActive;/**diff --git a/services/mcp/src/generated/warehouse_sources/api.ts b/services/mcp/src/generated/warehouse_sources/api.tsindex 3d9c8cfe64b4..e71faec5f68c 100644--- a/services/mcp/src/generated/warehouse_sources/api.ts+++ b/services/mcp/src/generated/warehouse_sources/api.ts@@ -2374,3 +2374,12 @@ export const ExternalDataSourcesWizardRetrieveParams = /* @__PURE__ */ zod.objec"Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/."),})++export const ExternalDataSourcesWizardRetrieveQueryParams = /* @__PURE__ */ zod.object({+ source_type: zod+ .string()+ .optional()+ .describe(+ "Comma-separated source type(s) to return config for, e.g. 'Postgres' or 'Postgres,Stripe'. Strongly recommended: the unfiltered response describes every supported source and is very large. Omit only to enumerate the available types."+ ),+})diff --git a/services/mcp/src/schema/tool-inputs.ts b/services/mcp/src/schema/tool-inputs.tsindex adddcc6b3db5..645b44dfbce6 100644--- a/services/mcp/src/schema/tool-inputs.ts+++ b/services/mcp/src/schema/tool-inputs.ts@@ -48,7 +48,7 @@ export const ExternalDataJobsSchemasSchema = zexport const ExternalDataSourcePayloadSchema = z.record(z.string(), z.unknown()).describe(- 'Connection credentials for the source. Keys depend on source_type. For database sources: host, port, database, user, password, schema. For SaaS sources: api_key or OAuth fields. For source_type "Custom" (a user-defined REST API): `manifest_json` (a stringified RESTAPIConfig describing client.base_url, auth, and resources) plus the credential for the auth type declared in the manifest — `auth_token` (bearer), `auth_api_key` (api_key), or `auth_password` (http_basic); keep secrets in these auth_* keys, never inline in manifest_json. Use external-data-sources-wizard to see required fields per source type.'+ 'Connection credentials for the source. Keys depend on source_type. For database sources: host, port, database, user, password, schema. For SaaS sources: api_key or OAuth fields. For source_type "Custom" (a user-defined REST API): `manifest_json` (a stringified RESTAPIConfig describing client.base_url, auth, and resources) plus the credential for the auth type declared in the manifest — `auth_token` (bearer), `auth_api_key` (api_key), or `auth_password` (http_basic); keep secrets in these auth_* keys, never inline in manifest_json. Use external-data-sources-wizard (pass source_type) to see required fields per source type. For the advanced external-data-sources-create flow, the per-table \'schemas\' array (built from external-data-sources-db-schema) also goes in here, e.g. {"host": ..., "password": ..., "schemas": [{"name": "orders", "should_sync": true, "sync_type": "incremental", "incremental_field": "updated_at", "incremental_field_type": "datetime"}]}. Do not pass unresolved {"secretRef": ...} objects — resolve secrets to real values first, or use a credential_id from data-warehouse-source-connect-link.')export const ExternalDataSourceTypeSchema = zdiff --git a/services/mcp/src/tools/generated/warehouse_sources.ts b/services/mcp/src/tools/generated/warehouse_sources.tsindex 6900b1f4df1c..f5beda35c309 100644--- a/services/mcp/src/tools/generated/warehouse_sources.ts+++ b/services/mcp/src/tools/generated/warehouse_sources.ts@@ -37,6 +37,7 @@ import {ExternalDataSourcesUpdateWebhookInputsCreateBody,ExternalDataSourcesUpdateWebhookInputsCreateParams,ExternalDataSourcesWebhookInfoRetrieveParams,+ ExternalDataSourcesWizardRetrieveQueryParams,} from '@/generated/warehouse_sources/api'import { ExternalDataSourcePayloadSchema, ExternalDataSourceTypeSchema } from '@/schema/tool-inputs'import { withPostHogUrl, omitResponseFields, pickResponseFields, type WithPostHogUrl } from '@/tools/tool-utils'@@ -843,17 +844,19 @@ const externalDataSourcesWebhookInfoRetrieve = (): ToolBase<},})-const ExternalDataSourcesWizardSchema = z.object({})+const ExternalDataSourcesWizardSchema = ExternalDataSourcesWizardRetrieveQueryParamsconst externalDataSourcesWizard = (): ToolBase<typeof ExternalDataSourcesWizardSchema, unknown> => ({name: 'external-data-sources-wizard',schema: ExternalDataSourcesWizardSchema,- // eslint-disable-next-line no-unused-varshandler: async (context: Context, params: z.infer<typeof ExternalDataSourcesWizardSchema>) => {const projectId = await context.stateManager.getProjectId()const result = await context.api.request<unknown>({method: 'GET',path: `/api/projects/${encodeURIComponent(String(projectId))}/external_data_sources/wizard/`,+ query: {+ source_type: params.source_type,+ },})const filtered = pickResponseFields(result, ['*.name',diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-create.jsonindex beddee0d6158..63ad18fda34d 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-create.json@@ -26,7 +26,7 @@},"payload": {"additionalProperties": {},- "description": "Connection credentials for the source. Keys depend on source_type. For database sources: host, port, database, user, password, schema. For SaaS sources: api_key or OAuth fields. For source_type \"Custom\" (a user-defined REST API): `manifest_json` (a stringified RESTAPIConfig describing client.base_url, auth, and resources) plus the credential for the auth type declared in the manifest — `auth_token` (bearer), `auth_api_key` (api_key), or `auth_password` (http_basic); keep secrets in these auth_* keys, never inline in manifest_json. Use external-data-sources-wizard to see required fields per source type.",+ "description": "Connection credentials for the source. Keys depend on source_type. For database sources: host, port, database, user, password, schema. For SaaS sources: api_key or OAuth fields. For source_type \"Custom\" (a user-defined REST API): `manifest_json` (a stringified RESTAPIConfig describing client.base_url, auth, and resources) plus the credential for the auth type declared in the manifest — `auth_token` (bearer), `auth_api_key` (api_key), or `auth_password` (http_basic); keep secrets in these auth_* keys, never inline in manifest_json. Use external-data-sources-wizard (pass source_type) to see required fields per source type. For the advanced external-data-sources-create flow, the per-table 'schemas' array (built from external-data-sources-db-schema) also goes in here, e.g. {\"host\": ..., \"password\": ..., \"schemas\": [{\"name\": \"orders\", \"should_sync\": true, \"sync_type\": \"incremental\", \"incremental_field\": \"updated_at\", \"incremental_field_type\": \"datetime\"}]}. Do not pass unresolved {\"secretRef\": ...} objects — resolve secrets to real values first, or use a credential_id from data-warehouse-source-connect-link.","propertyNames": {"type": "string"},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-db-schema.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-db-schema.jsonindex e19908df4044..f6cdf3c2ad98 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-db-schema.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-db-schema.json@@ -3,7 +3,7 @@"properties": {"payload": {"additionalProperties": {},- "description": "Connection credentials for the source. Keys depend on source_type. For database sources: host, port, database, user, password, schema. For SaaS sources: api_key or OAuth fields. For source_type \"Custom\" (a user-defined REST API): `manifest_json` (a stringified RESTAPIConfig describing client.base_url, auth, and resources) plus the credential for the auth type declared in the manifest — `auth_token` (bearer), `auth_api_key` (api_key), or `auth_password` (http_basic); keep secrets in these auth_* keys, never inline in manifest_json. Use external-data-sources-wizard to see required fields per source type.",+ "description": "Connection credentials for the source. Keys depend on source_type. For database sources: host, port, database, user, password, schema. For SaaS sources: api_key or OAuth fields. For source_type \"Custom\" (a user-defined REST API): `manifest_json` (a stringified RESTAPIConfig describing client.base_url, auth, and resources) plus the credential for the auth type declared in the manifest — `auth_token` (bearer), `auth_api_key` (api_key), or `auth_password` (http_basic); keep secrets in these auth_* keys, never inline in manifest_json. Use external-data-sources-wizard (pass source_type) to see required fields per source type. For the advanced external-data-sources-create flow, the per-table 'schemas' array (built from external-data-sources-db-schema) also goes in here, e.g. {\"host\": ..., \"password\": ..., \"schemas\": [{\"name\": \"orders\", \"should_sync\": true, \"sync_type\": \"incremental\", \"incremental_field\": \"updated_at\", \"incremental_field_type\": \"datetime\"}]}. Do not pass unresolved {\"secretRef\": ...} objects — resolve secrets to real values first, or use a credential_id from data-warehouse-source-connect-link.","propertyNames": {"type": "string"},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-preview-resource.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-preview-resource.jsonindex 333a02a0ee1c..cf94c9f12e74 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-preview-resource.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-preview-resource.json@@ -9,7 +9,7 @@},"payload": {"additionalProperties": {},- "description": "Connection credentials for the source. Keys depend on source_type. For database sources: host, port, database, user, password, schema. For SaaS sources: api_key or OAuth fields. For source_type \"Custom\" (a user-defined REST API): `manifest_json` (a stringified RESTAPIConfig describing client.base_url, auth, and resources) plus the credential for the auth type declared in the manifest — `auth_token` (bearer), `auth_api_key` (api_key), or `auth_password` (http_basic); keep secrets in these auth_* keys, never inline in manifest_json. Use external-data-sources-wizard to see required fields per source type.",+ "description": "Connection credentials for the source. Keys depend on source_type. For database sources: host, port, database, user, password, schema. For SaaS sources: api_key or OAuth fields. For source_type \"Custom\" (a user-defined REST API): `manifest_json` (a stringified RESTAPIConfig describing client.base_url, auth, and resources) plus the credential for the auth type declared in the manifest — `auth_token` (bearer), `auth_api_key` (api_key), or `auth_password` (http_basic); keep secrets in these auth_* keys, never inline in manifest_json. Use external-data-sources-wizard (pass source_type) to see required fields per source type. For the advanced external-data-sources-create flow, the per-table 'schemas' array (built from external-data-sources-db-schema) also goes in here, e.g. {\"host\": ..., \"password\": ..., \"schemas\": [{\"name\": \"orders\", \"should_sync\": true, \"sync_type\": \"incremental\", \"incremental_field\": \"updated_at\", \"incremental_field_type\": \"datetime\"}]}. Do not pass unresolved {\"secretRef\": ...} objects — resolve secrets to real values first, or use a credential_id from data-warehouse-source-connect-link.","propertyNames": {"type": "string"},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-wizard.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-wizard.jsonindex 7b7ea9186078..f72bd1668172 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-wizard.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-wizard.json@@ -1,5 +1,10 @@{"$schema": "https://json-schema.org/draft/2020-12/schema",- "properties": {},+ "properties": {+ "source_type": {+ "description": "Comma-separated source type(s) to return config for, e.g. 'Postgres' or 'Postgres,Stripe'. Strongly recommended: the unfiltered response describes every supported source and is very large. Omit only to enumerate the available types.",+ "type": "string"+ }+ },"type": "object"}