: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
chore(hogql): connectionId and connections-list MCP betterment (#60671)
Jovan Sakovice2b5a976db42
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 73e6477172f2..286e8fe5123f 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -21914,7 +21914,7 @@"additionalProperties": false,"properties": {"connectionId": {- "description": "Optional direct external data source id for running against a specific source",+ "description": "Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here.","type": "string"},"endPosition": {@@ -22021,7 +22021,7 @@"additionalProperties": false,"properties": {"connectionId": {- "description": "Optional direct external data source id for running against a specific source",+ "description": "Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here.","type": "string"},"debug": {@@ -22166,7 +22166,7 @@"additionalProperties": false,"properties": {"connectionId": {- "description": "Optional direct external data source id for running against a specific source",+ "description": "Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here.","type": "string"},"explain": {diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex c74a3140a1df..31d58536367b 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -528,7 +528,7 @@ export interface HogQLVariable {export interface HogQLQuery extends DataNode<HogQLQueryResponse> {kind: NodeKind.HogQLQueryquery: string- /** Optional direct external data source id for running against a specific source */+ /** Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here. */connectionId?: string/** Run the selected connection query directly without translating it through HogQL first */sendRawQuery?: boolean@@ -741,7 +741,7 @@ export interface HogQLMetadata extends DataNode<HogQLMetadataResponse> {language: HogLanguage/** Query to validate */query: string- /** Optional direct external data source id for running against a specific source */+ /** Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here. */connectionId?: string/** Query within which "expr" and "template" are validated. Defaults to "select * from events" */sourceQuery?: AnyDataNode@@ -761,7 +761,7 @@ export interface HogQLAutocomplete extends DataNode<HogQLAutocompleteResponse> {language: HogLanguage/** Query to validate */query: string- /** Optional direct external data source id for running against a specific source */+ /** Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here. */connectionId?: string/** Query in whose context to validate. */sourceQuery?: AnyDataNodediff --git a/posthog/api/test/test_query_service.py b/posthog/api/test/test_query_service.pyindex 324af5b0253d..6f8284d10d48 100644--- a/posthog/api/test/test_query_service.py+++ b/posthog/api/test/test_query_service.py@@ -26,6 +26,7 @@ from posthog.schema import (from posthog.hogql.database.database import Databasefrom posthog.hogql.database.models import TableNodefrom posthog.hogql.database.postgres_table import PostgresTable+from posthog.hogql.direct_connection import INVALID_CONNECTION_ID_ERRORfrom posthog.hogql.errors import ResolutionErrorfrom posthog.api.services.query import process_query_model@@ -627,7 +628,7 @@ class TestQueryService(APIBaseTest):with self.assertRaises(ValidationError) as error:process_query_model(self.team, query)- self.assertEqual(cast(list[str], error.exception.detail)[0], "Invalid connectionId for this team")+ self.assertEqual(cast(list[str], error.exception.detail)[0], INVALID_CONNECTION_ID_ERROR)@parameterized.expand([@@ -662,7 +663,7 @@ class TestQueryService(APIBaseTest):with self.assertRaises(ValidationError) as error:process_query_model(self.team, query)- self.assertEqual(cast(list[str], error.exception.detail)[0], "Invalid connectionId for this team")+ self.assertEqual(cast(list[str], error.exception.detail)[0], INVALID_CONNECTION_ID_ERROR)@patch("posthog.api.services.query.DataWarehouseJoin.objects.filter")@patch("posthog.api.services.query.resolve_database_for_connection")diff --git a/posthog/hogql/direct_connection.py b/posthog/hogql/direct_connection.pyindex 28a2d4e4e1d3..e9847079400a 100644--- a/posthog/hogql/direct_connection.py+++ b/posthog/hogql/direct_connection.py@@ -16,7 +16,10 @@ if TYPE_CHECKING:from posthog.temporal.data_imports.sources.postgres.source import PostgresSource-INVALID_CONNECTION_ID_ERROR = "Invalid connectionId for this team"+INVALID_CONNECTION_ID_ERROR = (+ "Invalid connectionId: not a direct external data source (access_method='direct') in this team. "+ "Warehouse import sources are not valid here."+)def get_direct_connection_source(team: "Team", connection_id: str | None) -> ExternalDataSource | None:diff --git a/posthog/hogql/metadata.py b/posthog/hogql/metadata.pyindex f81d5afa6451..a6a669a1ef39 100644--- a/posthog/hogql/metadata.py+++ b/posthog/hogql/metadata.py@@ -11,7 +11,7 @@ from posthog.hogql.base import ASTfrom posthog.hogql.compiler.bytecode import create_bytecodefrom posthog.hogql.context import HogQLContextfrom posthog.hogql.database.database import Database-from posthog.hogql.direct_connection import get_direct_connection_source+from posthog.hogql.direct_connection import INVALID_CONNECTION_ID_ERROR, get_direct_connection_sourcefrom posthog.hogql.errors import ExposedHogQLErrorfrom posthog.hogql.filters import replace_filtersfrom posthog.hogql.metadata_heuristics import run_metadata_heuristics@@ -48,7 +48,7 @@ def get_hogql_metadata(source = get_direct_connection_source(team, query.connectionId)if query.connectionId and source is None:response.isValid = False- response.errors = [HogQLNotice(message="Invalid connectionId for this team")]+ response.errors = [HogQLNotice(message=INVALID_CONNECTION_ID_ERROR)]return responsedatabase = Nonediff --git a/posthog/hogql/test/test_metadata.py b/posthog/hogql/test/test_metadata.pyindex 7ebe5adb78b2..ad1f2a2acfbb 100644--- a/posthog/hogql/test/test_metadata.py+++ b/posthog/hogql/test/test_metadata.py@@ -14,6 +14,7 @@ from posthog.schema import (SessionTableVersion,)+from posthog.hogql.direct_connection import INVALID_CONNECTION_ID_ERRORfrom posthog.hogql.metadata import get_hogql_metadatafrom posthog.models import Cohort, PropertyDefinition@@ -242,7 +243,7 @@ class TestMetadata(ClickhouseTestMixin, APIBaseTest):)self.assertFalse(metadata.isValid)- self.assertEqual([error.message for error in metadata.errors], ["Invalid connectionId for this team"])+ self.assertEqual([error.message for error in metadata.errors], [INVALID_CONNECTION_ID_ERROR])def test_metadata_with_direct_connection_does_not_allow_posthog_tables(self):source = ExternalDataSource.objects.create(@@ -424,7 +425,7 @@ class TestMetadata(ClickhouseTestMixin, APIBaseTest):)self.assertFalse(metadata.isValid)- self.assertEqual([error.message for error in metadata.errors], ["Invalid connectionId for this team"])+ self.assertEqual([error.message for error in metadata.errors], [INVALID_CONNECTION_ID_ERROR])@override_settings(PERSON_ON_EVENTS_OVERRIDE=True, PERSON_ON_EVENTS_V2_OVERRIDE=False)def test_metadata_in_cohort(self):diff --git a/posthog/hogql/test/test_query.py b/posthog/hogql/test/test_query.pyindex 5a3f8fd383d9..2966b18716e2 100644--- a/posthog/hogql/test/test_query.py+++ b/posthog/hogql/test/test_query.py@@ -24,6 +24,7 @@ from posthog.schema import ()from posthog.hogql import ast+from posthog.hogql.direct_connection import INVALID_CONNECTION_ID_ERRORfrom posthog.hogql.errors import ExposedHogQLError, QueryErrorfrom posthog.hogql.property import property_to_exprfrom posthog.hogql.query import execute_hogql_query@@ -313,7 +314,7 @@ class TestQuery(ClickhouseTestMixin, APIBaseTest):connection_id=str(selected_source.id),)- self.assertEqual(str(error.exception), "Invalid connectionId for this team")+ self.assertEqual(str(error.exception), INVALID_CONNECTION_ID_ERROR)@patch("posthog.hogql.query.sync_execute")def test_execute_hogql_query_rejects_non_direct_connection_before_clickhouse(self, mock_sync_execute):@@ -334,7 +335,7 @@ class TestQuery(ClickhouseTestMixin, APIBaseTest):connection_id=str(selected_source.id),)- self.assertEqual(str(error.exception), "Invalid connectionId for this team")+ self.assertEqual(str(error.exception), INVALID_CONNECTION_ID_ERROR)mock_sync_execute.assert_not_called()@pytest.mark.usefixtures("unittest_snapshot")diff --git a/posthog/hogql_queries/hogql_query_runner.py b/posthog/hogql_queries/hogql_query_runner.pyindex cdb4a30a2899..60a11cb03a23 100644--- a/posthog/hogql_queries/hogql_query_runner.py+++ b/posthog/hogql_queries/hogql_query_runner.py@@ -13,6 +13,7 @@ from posthog.schema import (from posthog.hogql import astfrom posthog.hogql.constants import HogQLGlobalSettings+from posthog.hogql.direct_connection import INVALID_CONNECTION_ID_ERRORfrom posthog.hogql.errors import ExposedHogQLErrorfrom posthog.hogql.filters import replace_filtersfrom posthog.hogql.parser import CacheOrigin, parse_select@@ -108,7 +109,7 @@ class HogQLQueryRunner(AnalyticsQueryRunner[HogQLQueryResponse]):team_id=self.team.pk, connection_id=self.query.connectionId)if source is None:- raise ExposedHogQLError("Invalid connectionId for this team")+ raise ExposedHogQLError(INVALID_CONNECTION_ID_ERROR)if self.query.sendRawQuery and self.query.connectionId:return execute_hogql_query(diff --git a/posthog/schema.py b/posthog/schema.pyindex a4400dda2846..d03e494c24e0 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -22684,7 +22684,11 @@ class HogQLQuery(BaseModel):)connectionId: str | None = Field(default=None,- description=("Optional direct external data source id for running against a specific source"),+ description=(+ "Optional id of a direct external data source (access_method='direct') to"+ " run against instead of ClickHouse. Warehouse import sources are not valid"+ " here."+ ),)explain: bool | None = Nonefilters: HogQLFilters | None = None@@ -26389,7 +26393,11 @@ class HogQLAutocomplete(BaseModel):)connectionId: str | None = Field(default=None,- description=("Optional direct external data source id for running against a specific source"),+ description=(+ "Optional id of a direct external data source (access_method='direct') to"+ " run against instead of ClickHouse. Warehouse import sources are not valid"+ " here."+ ),)endPosition: int = Field(..., description="End position of the editor word")filters: HogQLFilters | None = Field(default=None, description="Table to validate the expression against")@@ -26471,7 +26479,11 @@ class HogQLMetadata(BaseModel):)connectionId: str | None = Field(default=None,- description=("Optional direct external data source id for running against a specific source"),+ description=(+ "Optional id of a direct external data source (access_method='direct') to"+ " run against instead of ClickHouse. Warehouse import sources are not valid"+ " here."+ ),)debug: bool | None = Field(default=None,diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 2c5fd17e5229..9f0adcf98dde 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -5172,7 +5172,7 @@ export type HogQLQueryApiValues = { [key: string]: unknown } | nullexport type HogQLQueryApiVariables = { [key: string]: HogQLVariableApi } | nullexport interface HogQLQueryApi {- /** Optional direct external data source id for running against a specific source */+ /** Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here. */connectionId?: string | nullexplain?: boolean | nullfilters?: HogQLFiltersApi | nulldiff --git a/products/data_warehouse/mcp/tools.yaml b/products/data_warehouse/mcp/tools.yamlindex 9b6bfc896d7b..ab83c230a467 100644--- a/products/data_warehouse/mcp/tools.yaml+++ b/products/data_warehouse/mcp/tools.yaml@@ -213,7 +213,20 @@ tools:input_schema: ExternalDataSourceTypeSchemaexternal-data-sources-connections-list:operation: external_data_sources_connections_list- enabled: false+ enabled: true+ scopes:+ - external_data_source:read+ annotations:+ readOnly: true+ destructive: false+ idempotent: true+ list: true+ title: List direct-query connections+ description: >+ List external data sources that can be used as a connectionId when running execute-sql against an external+ source (direct-query Postgres connections). Returns a lightweight id, prefix, and engine for each — unlike+ external-data-sources-list, it does not include warehouse import sources or table schemas. Use this to+ discover valid connectionId values.external-data-sources-create:operation: external_data_sources_createenabled: truediff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 01de5da1d932..6bbcad3cbe86 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -4879,7 +4879,7 @@ export type HogQLQueryApiValues = { [key: string]: unknown } | nullexport type HogQLQueryApiVariables = { [key: string]: HogQLVariableApi } | nullexport interface HogQLQueryApi {- /** Optional direct external data source id for running against a specific source */+ /** Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here. */connectionId?: string | nullexplain?: boolean | nullfilters?: HogQLFiltersApi | nulldiff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 364954af9722..0ed3ab356f7a 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -2084,6 +2084,21 @@"readOnlyHint": true}},+ "external-data-sources-connections-list": {+ "description": "List external data sources that can be used as a connectionId when running execute-sql against an external source (direct-query Postgres connections). Returns a lightweight id, prefix, and engine for each — unlike external-data-sources-list, it does not include warehouse import sources or table schemas. Use this to discover valid connectionId values.",+ "category": "Data warehouse",+ "feature": "data_warehouse",+ "summary": "List direct-query connections",+ "title": "List direct-query connections",+ "required_scopes": ["external_data_source:read"],+ "new_mcp": true,+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ }+ },"external-data-sources-create": {"description": "Create a new external data source connection. Before calling this, use 'external-data-sources-wizard' to discover source types and 'external-data-sources-db-schema' to validate credentials and discover available tables. Present the db-schema results to the user showing each table's available sync methods, incremental fields, detected primary keys, and columns so they can configure before creation. 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 from the db-schema response.","category": "Data warehouse",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex aa238d33fdc2..05a85f2ba8b5 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -2309,6 +2309,21 @@"readOnlyHint": true}},+ "external-data-sources-connections-list": {+ "description": "List external data sources that can be used as a connectionId when running execute-sql against an external source (direct-query Postgres connections). Returns a lightweight id, prefix, and engine for each — unlike external-data-sources-list, it does not include warehouse import sources or table schemas. Use this to discover valid connectionId values.",+ "category": "Data warehouse",+ "feature": "data_warehouse",+ "summary": "List direct-query connections",+ "title": "List direct-query connections",+ "required_scopes": ["external_data_source:read"],+ "new_mcp": true,+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ }+ },"external-data-sources-create": {"description": "Create a new external data source connection. Before calling this, use 'external-data-sources-wizard' to discover source types and 'external-data-sources-db-schema' to validate credentials and discover available tables. Present the db-schema results to the user showing each table's available sync methods, incremental fields, detected primary keys, and columns so they can configure before creation. 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 from the db-schema response.","category": "Data warehouse",diff --git a/services/mcp/schema/tool-inputs.json b/services/mcp/schema/tool-inputs.jsonindex e20d3ccd14f2..504d9e86a068 100644--- a/services/mcp/schema/tool-inputs.json+++ b/services/mcp/schema/tool-inputs.json@@ -904,7 +904,7 @@"type": "object","properties": {"connectionId": {- "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, returns the schema of that source instead of the ClickHouse catalog. Use external-data-sources-list to discover available connection ids.",+ "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, returns the schema of that source instead of the ClickHouse catalog. Use external-data-sources-connections-list to discover available connection ids.","type": "string"}}@@ -2596,7 +2596,7 @@}},"connectionId": {- "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, the query runs against that source instead of ClickHouse. Use external-data-sources-list to discover available connection ids.",+ "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, the query runs against that source instead of ClickHouse. Use external-data-sources-connections-list to discover available connection ids.","type": "string"}},@@ -2974,7 +2974,7 @@}},"connectionId": {- "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, the query runs against that source instead of ClickHouse. Use external-data-sources-list to discover available connection ids.",+ "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, the query runs against that source instead of ClickHouse. Use external-data-sources-connections-list to discover available connection ids.","type": "string"}},@@ -3000,7 +3000,7 @@"enum": ["hogQL", "hogQLExpr", "hog", "hogTemplate"]},"connectionId": {- "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, validates against that source instead of the ClickHouse catalog. Use external-data-sources-list to discover available connection ids.",+ "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, validates against that source instead of the ClickHouse catalog. Use external-data-sources-connections-list to discover available connection ids.","type": "string"}},diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 3b994a4c5ef1..7ec56f1d1660 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -3714,7 +3714,7 @@ export namespace Schemas {export type HogQLQueryVariables = {[key: string]: HogQLVariable} | null;export interface HogQLQuery {- /** Optional direct external data source id for running against a specific source */+ /** Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here. */connectionId?: string | null;explain?: boolean | null;filters?: HogQLFilters | null;@@ -19916,7 +19916,7 @@ export namespace Schemas {export type HogQLMetadataVariables = {[key: string]: HogQLVariable} | null;export interface HogQLMetadata {- /** Optional direct external data source id for running against a specific source */+ /** Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here. */connectionId?: string | null;/** Enable more verbose output, usually run from the /debug page */debug?: boolean | null;@@ -19942,7 +19942,7 @@ export namespace Schemas {}export interface HogQLAutocomplete {- /** Optional direct external data source id for running against a specific source */+ /** Optional id of a direct external data source (access_method='direct') to run against instead of ClickHouse. Warehouse import sources are not valid here. */connectionId?: string | null;/** End position of the editor word */endPosition: number;diff --git a/services/mcp/src/generated/data_warehouse/api.ts b/services/mcp/src/generated/data_warehouse/api.tsindex 2c4ab616ca74..84a1a930da48 100644--- a/services/mcp/src/generated/data_warehouse/api.ts+++ b/services/mcp/src/generated/data_warehouse/api.ts@@ -3,7 +3,7 @@* MCP service uses these Zod schemas for generated tool handlers.* To regenerate: hogli build:openapi*- * PostHog API - MCP 34 enabled ops+ * PostHog API - MCP 35 enabled ops* OpenAPI spec version: 1.0.0*/import * as zod from 'zod'@@ -921,6 +921,23 @@ export const ExternalDataSourcesCheckCdcPrerequisitesCreateParams = /* @__PURE__),})+/**+ * Create, Read, Update and Delete External data Sources.+ */+export const ExternalDataSourcesConnectionsListParams = /* @__PURE__ */ zod.object({+ project_id: zod+ .string()+ .describe(+ "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 ExternalDataSourcesConnectionsListQueryParams = /* @__PURE__ */ zod.object({+ 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.'),+ search: zod.string().optional().describe('A search term.'),+})+/*** Create, Read, Update and Delete External data Sources.*/diff --git a/services/mcp/src/schema/query.ts b/services/mcp/src/schema/query.tsindex ed403c3e0caa..15595045e28c 100644--- a/services/mcp/src/schema/query.ts+++ b/services/mcp/src/schema/query.ts@@ -216,7 +216,7 @@ const HogQLQuerySchema = z.object({.string().optional().describe(- 'Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, the query runs against that source instead of ClickHouse. Use external-data-sources-list to discover available connection ids.'+ 'Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, the query runs against that source instead of ClickHouse. Use external-data-sources-connections-list to discover available connection ids.'),})diff --git a/services/mcp/src/schema/tool-inputs.ts b/services/mcp/src/schema/tool-inputs.tsindex 0c5fac992bdc..51ab89b0aa9d 100644--- a/services/mcp/src/schema/tool-inputs.ts+++ b/services/mcp/src/schema/tool-inputs.ts@@ -544,7 +544,7 @@ export const HogQLSchemaInputSchema = z.object({.string().optional().describe(- 'Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, returns the schema of that source instead of the ClickHouse catalog. Use external-data-sources-list to discover available connection ids.'+ 'Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, returns the schema of that source instead of the ClickHouse catalog. Use external-data-sources-connections-list to discover available connection ids.'),})@@ -565,7 +565,7 @@ export const QueryValidateInputSchema = z.object({.string().optional().describe(- 'Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, validates against that source instead of the ClickHouse catalog. Use external-data-sources-list to discover available connection ids.'+ 'Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, validates against that source instead of the ClickHouse catalog. Use external-data-sources-connections-list to discover available connection ids.'),})diff --git a/services/mcp/src/tools/generated/data_warehouse.ts b/services/mcp/src/tools/generated/data_warehouse.tsindex 9090a88271e9..f165ec56ff18 100644--- a/services/mcp/src/tools/generated/data_warehouse.ts+++ b/services/mcp/src/tools/generated/data_warehouse.ts@@ -16,6 +16,7 @@ import {ExternalDataSchemasResyncCreateBody,ExternalDataSchemasResyncCreateParams,ExternalDataSchemasRetrieveParams,+ ExternalDataSourcesConnectionsListQueryParams,ExternalDataSourcesCreateBody,ExternalDataSourcesCreateWebhookCreateBody,ExternalDataSourcesCreateWebhookCreateParams,@@ -391,6 +392,29 @@ const externalDataSourcesCheckCdcPrerequisitesCreate = (): ToolBase<},})+const ExternalDataSourcesConnectionsListSchema = ExternalDataSourcesConnectionsListQueryParams++const externalDataSourcesConnectionsList = (): ToolBase<+ typeof ExternalDataSourcesConnectionsListSchema,+ WithPostHogUrl<Schemas.PaginatedExternalDataSourceConnectionOptionList>+> => ({+ name: 'external-data-sources-connections-list',+ schema: ExternalDataSourcesConnectionsListSchema,+ handler: async (context: Context, params: z.infer<typeof ExternalDataSourcesConnectionsListSchema>) => {+ const projectId = await context.stateManager.getProjectId()+ const result = await context.api.request<Schemas.PaginatedExternalDataSourceConnectionOptionList>({+ method: 'GET',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/external_data_sources/connections/`,+ query: {+ limit: params.limit,+ offset: params.offset,+ search: params.search,+ },+ })+ return await withPostHogUrl(context, result, '/sql')+ },+})+const ExternalDataSourcesCreateSchema = ExternalDataSourcesCreateBody.extend({source_type: ExternalDataSourceTypeSchema,payload: ExternalDataSourcePayloadSchema,@@ -1112,6 +1136,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'external-data-schemas-resync': externalDataSchemasResync,'external-data-schemas-retrieve': externalDataSchemasRetrieve,'external-data-sources-check-cdc-prerequisites-create': externalDataSourcesCheckCdcPrerequisitesCreate,+ 'external-data-sources-connections-list': externalDataSourcesConnectionsList,'external-data-sources-create': externalDataSourcesCreate,'external-data-sources-create-webhook-create': externalDataSourcesCreateWebhookCreate,'external-data-sources-delete-webhook-create': externalDataSourcesDeleteWebhookCreate,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/external-data-sources-connections-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/external-data-sources-connections-list.jsonnew file mode 100644index 000000000000..bc560e594d69--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/external-data-sources-connections-list.json@@ -0,0 +1,18 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "properties": {+ "limit": {+ "description": "Number of results to return per page.",+ "type": "number"+ },+ "offset": {+ "description": "The initial index from which to return the results.",+ "type": "number"+ },+ "search": {+ "description": "A search term.",+ "type": "string"+ }+ },+ "type": "object"+}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/hogql-schema.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/hogql-schema.jsonindex 44c4a705fe6c..2459a2deffbb 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/hogql-schema.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/hogql-schema.json@@ -2,7 +2,7 @@"$schema": "https://json-schema.org/draft/2020-12/schema","properties": {"connectionId": {- "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, returns the schema of that source instead of the ClickHouse catalog. Use external-data-sources-list to discover available connection ids.",+ "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, returns the schema of that source instead of the ClickHouse catalog. Use external-data-sources-connections-list to discover available connection ids.","type": "string"}},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/query-run.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/query-run.jsonindex 04f4b6b86e21..de6178220b25 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/query-run.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/query-run.json@@ -1529,7 +1529,7 @@"source": {"properties": {"connectionId": {- "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, the query runs against that source instead of ClickHouse. Use external-data-sources-list to discover available connection ids.",+ "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, the query runs against that source instead of ClickHouse. Use external-data-sources-connections-list to discover available connection ids.","type": "string"},"filters": {@@ -1762,7 +1762,7 @@{"properties": {"connectionId": {- "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, the query runs against that source instead of ClickHouse. Use external-data-sources-list to discover available connection ids.",+ "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, the query runs against that source instead of ClickHouse. Use external-data-sources-connections-list to discover available connection ids.","type": "string"},"filters": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/query-validate.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/query-validate.jsonindex 221f9defc2a0..494b4f67c356 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/query-validate.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/v1/query-validate.json@@ -2,7 +2,7 @@"$schema": "https://json-schema.org/draft/2020-12/schema","properties": {"connectionId": {- "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, validates against that source instead of the ClickHouse catalog. Use external-data-sources-list to discover available connection ids.",+ "description": "Optional id of an external data source (e.g. a Postgres or DuckDB direct-query connection). When set, validates against that source instead of the ClickHouse catalog. Use external-data-sources-connections-list to discover available connection ids.","type": "string"},"language": {