: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(mcp): trim warehouse source tool payloads (#73598)
Daniel RCe57d2d7a4d18
diff --git a/products/warehouse_sources/mcp/tools.yaml b/products/warehouse_sources/mcp/tools.yamlindex 4710a9f88de2..af4e9e32a07a 100644--- a/products/warehouse_sources/mcp/tools.yaml+++ b/products/warehouse_sources/mcp/tools.yaml@@ -373,14 +373,28 @@ tools:support-ticket, or product-database question — call this first so you JOIN against an existing sourceinstead of telling the user the data isn't available. Lists every configured import source with its type(Postgres, Stripe, Hubspot, etc.), connection status, prefix, schemas, latest error, and last sync- timestamp. If nothing relevant is connected, offer to set one up with 'data-warehouse-source-setup'.- Per-schema column definitions are omitted to keep the payload small — to look up a single table's sync- status by name use external-data-schemas-list with a search, and to see a table's columns use- external-data-schemas-retrieve.+ timestamp. If nothing relevant is connected, offer to set one up with 'data-warehouse-source-setup'. Each+ schema is summarized (name, status, sync type/frequency, last sync, error, table name, row count) — column+ definitions and full sync configuration (incremental field, primary keys, row filters, column selection) are+ on external-data-schemas-retrieve. To look up a single table's sync status by name use+ external-data-schemas-list with a search.response:exclude:- schemas.*.table.columns- schemas.*.available_columns+ - schemas.*.label+ - schemas.*.description+ - schemas.*.incremental_field+ - schemas.*.incremental_field_type+ - schemas.*.incremental_field_lookback_seconds+ - schemas.*.sync_time_of_day+ - schemas.*.primary_key_columns+ - schemas.*.cdc_table_mode+ - schemas.*.enabled_columns+ - schemas.*.row_filters+ - schemas.*.source+ - schemas.*.api_version+ - schemas.*.api_version_deprecationexternal-data-sources-oauth-accounts-retrieve:operation: external_data_sources_oauth_accounts_retrieveenabled: false@@ -474,7 +488,13 @@ tools:title: Get data warehouse sourcedescription: >Get a single data warehouse source by ID. Returns full details including source type, connection status,- prefix, all table schemas with their sync statuses, latest error, and last sync timestamp.+ prefix, all table schemas with their sync statuses, latest error, and last sync timestamp. Per-schema column+ definitions are omitted to keep the payload small — use external-data-schemas-retrieve for a single table's+ columns.+ response:+ exclude:+ - schemas.*.table.columns+ - schemas.*.available_columnsexternal-data-sources-revenue-analytics-config-partial-update:operation: external_data_sources_revenue_analytics_config_partial_updateenabled: false@@ -540,7 +560,8 @@ tools:source type: the required fields (host, port, database, credentials, etc.), field types, and OAuth flows, soyou 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+ (hundreds of KB). Only omit 'source_type' if you genuinely need to enumerate every available type — and when+ enumerating, pass fields: ['*.name', '*.caption'] to skip the large per-source field definitions. Toactually connect a source, prefer 'data-warehouse-source-setup'.response:include:@@ -550,3 +571,4 @@ tools:- '*.featured'- '*.unreleasedSource'- '*.fields'+ selectable: truediff --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 1a2b94b221e8..6f0b596bde01 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@@ -133,11 +133,12 @@ to `external-data-sources-create` — you need the db-schema response to build aCall `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:+blow your context budget. Only omit `source_type` when you genuinely need to enumerate every available type, and when+you do, pass `fields: ['*.name', '*.caption']` so the response carries just the names instead of every source's config+field definitions. 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.+- `caption` — human-readable description.- `fields` — the config fields needed (host, port, database, api_key, client_id/secret, ...). Each has `name`,`type` (input, password, switch, select, file-upload), and `required`.- `featured`, `unreleasedSource` — use to gauge readiness. Skip sources marked `unreleasedSource: true` unless thediff --git a/products/warehouse_sources/skills/suggesting-data-imports/SKILL.md b/products/warehouse_sources/skills/suggesting-data-imports/SKILL.mdindex ecc47be36de1..814114067195 100644--- a/products/warehouse_sources/skills/suggesting-data-imports/SKILL.md+++ b/products/warehouse_sources/skills/suggesting-data-imports/SKILL.md@@ -42,7 +42,9 @@ Also query `system.information_schema.tables` with `posthog:execute-sql` to see### 3. Identify the right source type-If the data isn't imported yet, call `posthog:external-data-sources-wizard` to see available source types. Match the user's need to a source:+If the data isn't imported yet, call `posthog:external-data-sources-wizard` to see available source types — when+enumerating without `source_type`, pass `fields: ['*.name', '*.caption']` to skip the large per-source config field+definitions. Match the user's need to a source:**Common patterns:**@@ -98,7 +100,7 @@ Common join patterns:- `posthog:external-data-sources-list`: Check existing source connections- `posthog:external-data-schemas-list`: Check what tables are already imported- `posthog:execute-sql` over `system.information_schema.*`: See all queryable tables including views-- `posthog:external-data-sources-wizard`: Get available source types+- `posthog:external-data-sources-wizard`: Get available source types (pass `fields: ['*.name', '*.caption']` when enumerating)- `posthog:data-warehouse-source-connect-link`: Get a secure browser/OAuth link to collect credentials- `posthog:data-warehouse-source-setup`: One-step create (validate, discover tables, apply sync defaults, create)- `posthog:execute-sql`: Run queries to demonstrate what's possiblediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex e0bb32a1d373..5679a3ebc6d4 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -4394,7 +4394,7 @@}},"external-data-sources-list": {- "description": "Check what external data is already connected before answering any revenue, billing, subscription, CRM, support-ticket, or product-database question — call this first so you JOIN against an existing source instead of telling the user the data isn't available. Lists every configured import source with its type (Postgres, Stripe, Hubspot, etc.), connection status, prefix, schemas, latest error, and last sync timestamp. If nothing relevant is connected, offer to set one up with 'data-warehouse-source-setup'. Per-schema column definitions are omitted to keep the payload small — to look up a single table's sync status by name use external-data-schemas-list with a search, and to see a table's columns use external-data-schemas-retrieve.",+ "description": "Check what external data is already connected before answering any revenue, billing, subscription, CRM, support-ticket, or product-database question — call this first so you JOIN against an existing source instead of telling the user the data isn't available. Lists every configured import source with its type (Postgres, Stripe, Hubspot, etc.), connection status, prefix, schemas, latest error, and last sync timestamp. If nothing relevant is connected, offer to set one up with 'data-warehouse-source-setup'. Each schema is summarized (name, status, sync type/frequency, last sync, error, table name, row count) — column definitions and full sync configuration (incremental field, primary keys, row filters, column selection) are on external-data-schemas-retrieve. To look up a single table's sync status by name use external-data-schemas-list with a search.","category": "Warehouse sources","feature": "warehouse_sources","summary": "List data warehouse sources",@@ -4464,7 +4464,7 @@}},"external-data-sources-retrieve": {- "description": "Get a single data warehouse source by ID. Returns full details including source type, connection status, prefix, all table schemas with their sync statuses, latest error, and last sync timestamp.",+ "description": "Get a single data warehouse source by ID. Returns full details including source type, connection status, prefix, all table schemas with their sync statuses, latest error, and last sync timestamp. Per-schema column definitions are omitted to keep the payload small — use external-data-schemas-retrieve for a single table's columns.","category": "Warehouse sources","feature": "warehouse_sources","summary": "Get data warehouse source",@@ -4506,7 +4506,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. 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'.",+ "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 — and when enumerating, pass fields: ['*.name', '*.caption'] to skip the large per-source field definitions. 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 b8ab34d3560a..4db078375bad 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -4619,7 +4619,7 @@}},"external-data-sources-list": {- "description": "Check what external data is already connected before answering any revenue, billing, subscription, CRM, support-ticket, or product-database question — call this first so you JOIN against an existing source instead of telling the user the data isn't available. Lists every configured import source with its type (Postgres, Stripe, Hubspot, etc.), connection status, prefix, schemas, latest error, and last sync timestamp. If nothing relevant is connected, offer to set one up with 'data-warehouse-source-setup'. Per-schema column definitions are omitted to keep the payload small — to look up a single table's sync status by name use external-data-schemas-list with a search, and to see a table's columns use external-data-schemas-retrieve.",+ "description": "Check what external data is already connected before answering any revenue, billing, subscription, CRM, support-ticket, or product-database question — call this first so you JOIN against an existing source instead of telling the user the data isn't available. Lists every configured import source with its type (Postgres, Stripe, Hubspot, etc.), connection status, prefix, schemas, latest error, and last sync timestamp. If nothing relevant is connected, offer to set one up with 'data-warehouse-source-setup'. Each schema is summarized (name, status, sync type/frequency, last sync, error, table name, row count) — column definitions and full sync configuration (incremental field, primary keys, row filters, column selection) are on external-data-schemas-retrieve. To look up a single table's sync status by name use external-data-schemas-list with a search.","category": "Warehouse sources","feature": "warehouse_sources","summary": "List data warehouse sources",@@ -4703,7 +4703,7 @@}},"external-data-sources-retrieve": {- "description": "Get a single data warehouse source by ID. Returns full details including source type, connection status, prefix, all table schemas with their sync statuses, latest error, and last sync timestamp.",+ "description": "Get a single data warehouse source by ID. Returns full details including source type, connection status, prefix, all table schemas with their sync statuses, latest error, and last sync timestamp. Per-schema column definitions are omitted to keep the payload small — use external-data-schemas-retrieve for a single table's columns.","category": "Warehouse sources","feature": "warehouse_sources","summary": "Get data warehouse source",@@ -4745,7 +4745,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. 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'.",+ "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 — and when enumerating, pass fields: ['*.name', '*.caption'] to skip the large per-source field definitions. 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/src/tools/generated/warehouse_sources.ts b/services/mcp/src/tools/generated/warehouse_sources.tsindex b88b7251ca24..58b28189d14d 100644--- a/services/mcp/src/tools/generated/warehouse_sources.ts+++ b/services/mcp/src/tools/generated/warehouse_sources.ts@@ -645,7 +645,23 @@ const externalDataSourcesList = (): ToolBase<const filtered = {...result,results: (result.results ?? []).map((item: any) =>- omitResponseFields(item, ['schemas.*.table.columns', 'schemas.*.available_columns'])+ omitResponseFields(item, [+ 'schemas.*.table.columns',+ 'schemas.*.available_columns',+ 'schemas.*.label',+ 'schemas.*.description',+ 'schemas.*.incremental_field',+ 'schemas.*.incremental_field_type',+ 'schemas.*.incremental_field_lookback_seconds',+ 'schemas.*.sync_time_of_day',+ 'schemas.*.primary_key_columns',+ 'schemas.*.cdc_table_mode',+ 'schemas.*.enabled_columns',+ 'schemas.*.row_filters',+ 'schemas.*.source',+ 'schemas.*.api_version',+ 'schemas.*.api_version_deprecation',+ ])),} as typeof resultreturn await withPostHogUrl(context, filtered, '/data-management/sources')@@ -792,7 +808,11 @@ const externalDataSourcesRetrieve = (): ToolBase<method: 'GET',path: `/api/projects/${encodeURIComponent(String(projectId))}/external_data_sources/${encodeURIComponent(String(params.id))}/`,})- return result+ const filtered = omitResponseFields(result, [+ 'schemas.*.table.columns',+ 'schemas.*.available_columns',+ ]) as typeof result+ return filtered},})@@ -865,7 +885,15 @@ const externalDataSourcesWebhookInfoRetrieve = (): ToolBase<},})-const ExternalDataSourcesWizardSchema = ExternalDataSourcesWizardRetrieveQueryParams+const ExternalDataSourcesWizardSchema = ExternalDataSourcesWizardRetrieveQueryParams.extend({+ fields: z+ .array(z.enum(['*.name', '*.caption', '*.docsUrl', '*.featured', '*.unreleasedSource', '*.fields']))+ .min(1)+ .optional()+ .describe(+ 'Optional subset of response fields to return, each a dot-path from the allowlist. Omit to return all fields. Request only the fields your task needs to keep responses small.'+ ),+})const externalDataSourcesWizard = (): ToolBase<typeof ExternalDataSourcesWizardSchema, unknown> => ({name: 'external-data-sources-wizard',@@ -879,14 +907,12 @@ const externalDataSourcesWizard = (): ToolBase<typeof ExternalDataSourcesWizardSsource_type: params.source_type,},})- const filtered = pickResponseFields(result, [- '*.name',- '*.caption',- '*.docsUrl',- '*.featured',- '*.unreleasedSource',- '*.fields',- ]) as typeof result+ const filtered = pickResponseFields(+ result,+ params.fields?.length+ ? params.fields+ : ['*.name', '*.caption', '*.docsUrl', '*.featured', '*.unreleasedSource', '*.fields']+ ) as typeof resultreturn filtered},})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 f72bd1668172..697c9dbf11f7 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,6 +1,15 @@{"$schema": "https://json-schema.org/draft/2020-12/schema","properties": {+ "fields": {+ "description": "Optional subset of response fields to return, each a dot-path from the allowlist. Omit to return all fields. Request only the fields your task needs to keep responses small.",+ "items": {+ "enum": ["*.name", "*.caption", "*.docsUrl", "*.featured", "*.unreleasedSource", "*.fields"],+ "type": "string"+ },+ "minItems": 1,+ "type": "array"+ },"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"