Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(mcp): hint agents to write human-readable formatted SQL (#61105)

Andrew Maguire804e16eeb8d9
diff --git a/products/data_warehouse/backend/api/saved_query.py b/products/data_warehouse/backend/api/saved_query.py
index e97f2fa484ed..c7b4f9531982 100644
--- a/products/data_warehouse/backend/api/saved_query.py
+++ b/products/data_warehouse/backend/api/saved_query.py
@@ -203,7 +203,7 @@ class DataWarehouseSavedQuerySerializer(
created_by = UserBasicSerializer(read_only=True)
columns = serializers.SerializerMethodField(read_only=True)
query = QueryDefinitionField(
- help_text='HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}',
+ help_text='HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100"}',
)
sync_frequency = serializers.SerializerMethodField()
latest_history_id = serializers.SerializerMethodField(read_only=True)
diff --git a/products/data_warehouse/frontend/generated/api.schemas.ts b/products/data_warehouse/frontend/generated/api.schemas.ts
index e82671f36e69..c7e3c727924f 100644
--- a/products/data_warehouse/frontend/generated/api.schemas.ts
+++ b/products/data_warehouse/frontend/generated/api.schemas.ts
@@ -1554,7 +1554,7 @@ export const DataWarehouseSavedQueryApiQueryKind = {
} as const
/**
- * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}
+ * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\n event,\n count() AS cnt\nFROM events\nGROUP BY event\nLIMIT 100"}
*/
export type DataWarehouseSavedQueryApiQuery = {
kind?: DataWarehouseSavedQueryApiQueryKind
@@ -1577,7 +1577,7 @@ export interface DataWarehouseSavedQueryApi {
* @maxLength 128
*/
name: string
- /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"} */
+ /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\n event,\n count() AS cnt\nFROM events\nGROUP BY event\nLIMIT 100"} */
query: DataWarehouseSavedQueryApiQuery
readonly created_by: UserBasicApi
readonly created_at: string
@@ -1655,7 +1655,7 @@ export const PatchedDataWarehouseSavedQueryApiQueryKind = {
} as const
/**
- * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}
+ * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\n event,\n count() AS cnt\nFROM events\nGROUP BY event\nLIMIT 100"}
*/
export type PatchedDataWarehouseSavedQueryApiQuery = {
kind?: PatchedDataWarehouseSavedQueryApiQueryKind
@@ -1678,7 +1678,7 @@ export interface PatchedDataWarehouseSavedQueryApi {
* @maxLength 128
*/
name?: string
- /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"} */
+ /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\n event,\n count() AS cnt\nFROM events\nGROUP BY event\nLIMIT 100"} */
query?: PatchedDataWarehouseSavedQueryApiQuery
readonly created_by?: UserBasicApi
readonly created_at?: string
diff --git a/products/data_warehouse/frontend/generated/api.zod.ts b/products/data_warehouse/frontend/generated/api.zod.ts
index 5e7062f579a3..d9fd51322333 100644
--- a/products/data_warehouse/frontend/generated/api.zod.ts
+++ b/products/data_warehouse/frontend/generated/api.zod.ts
@@ -1434,7 +1434,7 @@ export const WarehouseSavedQueriesCreateBody = /* @__PURE__ */ zod
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'
+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}'
),
folder_id: zod
.uuid()
@@ -1477,7 +1477,7 @@ export const WarehouseSavedQueriesUpdateBody = /* @__PURE__ */ zod
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'
+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}'
),
folder_id: zod
.uuid()
@@ -1522,7 +1522,7 @@ export const WarehouseSavedQueriesPartialUpdateBody = /* @__PURE__ */ zod
})
.optional()
.describe(
- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'
+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}'
),
folder_id: zod
.uuid()
@@ -1569,7 +1569,7 @@ export const WarehouseSavedQueriesAncestorsCreateBody = /* @__PURE__ */ zod
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'
+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}'
),
folder_id: zod
.uuid()
@@ -1612,7 +1612,7 @@ export const WarehouseSavedQueriesCancelCreateBody = /* @__PURE__ */ zod
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'
+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}'
),
folder_id: zod
.uuid()
@@ -1659,7 +1659,7 @@ export const WarehouseSavedQueriesDescendantsCreateBody = /* @__PURE__ */ zod
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'
+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}'
),
folder_id: zod
.uuid()
@@ -1702,7 +1702,7 @@ export const WarehouseSavedQueriesMaterializeCreateBody = /* @__PURE__ */ zod
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'
+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}'
),
folder_id: zod
.uuid()
@@ -1748,7 +1748,7 @@ export const WarehouseSavedQueriesRevertMaterializationCreateBody = /* @__PURE__
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'
+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}'
),
folder_id: zod
.uuid()
@@ -1791,7 +1791,7 @@ export const WarehouseSavedQueriesRunCreateBody = /* @__PURE__ */ zod
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'
+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}'
),
folder_id: zod
.uuid()
@@ -1837,7 +1837,7 @@ export const WarehouseSavedQueriesResumeSchedulesCreateBody = /* @__PURE__ */ zo
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT \* FROM events LIMIT 100\"}'
+ 'HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}'
),
folder_id: zod
.uuid()
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 52aeaa401ae7..de546a0e6dbb 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -12148,7 +12148,7 @@ export namespace Schemas {
} as const;
/**
- * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}
+ * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\n event,\n count() AS cnt\nFROM events\nGROUP BY event\nLIMIT 100"}
*/
export type DataWarehouseSavedQueryQuery = {
kind?: DataWarehouseSavedQueryQueryKind;
@@ -12203,7 +12203,7 @@ export namespace Schemas {
* @maxLength 128
*/
name: string;
- /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"} */
+ /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\n event,\n count() AS cnt\nFROM events\nGROUP BY event\nLIMIT 100"} */
query: DataWarehouseSavedQueryQuery;
readonly created_by: UserBasic;
readonly created_at: string;
@@ -27766,7 +27766,7 @@ export namespace Schemas {
} as const;
/**
- * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}
+ * HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\n event,\n count() AS cnt\nFROM events\nGROUP BY event\nLIMIT 100"}
*/
export type PatchedDataWarehouseSavedQueryQuery = {
kind?: PatchedDataWarehouseSavedQueryQueryKind;
@@ -27789,7 +27789,7 @@ export namespace Schemas {
* @maxLength 128
*/
name?: string;
- /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"} */
+ /** HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\n event,\n count() AS cnt\nFROM events\nGROUP BY event\nLIMIT 100"} */
query?: PatchedDataWarehouseSavedQueryQuery;
readonly created_by?: UserBasic;
readonly created_at?: string;
diff --git a/services/mcp/src/generated/data_warehouse/api.ts b/services/mcp/src/generated/data_warehouse/api.ts
index bc370181bbba..1c38cc89f39e 100644
--- a/services/mcp/src/generated/data_warehouse/api.ts
+++ b/services/mcp/src/generated/data_warehouse/api.ts
@@ -1055,7 +1055,7 @@ export const WarehouseSavedQueriesCreateBody = /* @__PURE__ */ zod
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'
+ 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100"}'
),
folder_id: zod
.uuid()
@@ -1112,7 +1112,7 @@ export const WarehouseSavedQueriesPartialUpdateBody = /* @__PURE__ */ zod
})
.optional()
.describe(
- 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'
+ 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100"}'
),
folder_id: zod
.uuid()
@@ -1172,7 +1172,7 @@ export const WarehouseSavedQueriesMaterializeCreateBody = /* @__PURE__ */ zod
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'
+ 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100"}'
),
folder_id: zod
.uuid()
@@ -1227,7 +1227,7 @@ export const WarehouseSavedQueriesRevertMaterializationCreateBody = /* @__PURE__
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'
+ 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100"}'
),
folder_id: zod
.uuid()
@@ -1279,7 +1279,7 @@ export const WarehouseSavedQueriesRunCreateBody = /* @__PURE__ */ zod
query: zod.string(),
})
.describe(
- 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Example: {"kind": "HogQLQuery", "query": "SELECT * FROM events LIMIT 100"}'
+ 'HogQL query definition as a JSON object with a "query" key containing the SQL string and a "kind" key (always "HogQLQuery"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {"kind": "HogQLQuery", "query": "SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100"}'
),
folder_id: zod
.uuid()
diff --git a/services/mcp/src/templates/execute-sql-prompt.md b/services/mcp/src/templates/execute-sql-prompt.md
index 1f8105f0fd5c..1f9c484bf1a3 100644
--- a/services/mcp/src/templates/execute-sql-prompt.md
+++ b/services/mcp/src/templates/execute-sql-prompt.md
@@ -31,6 +31,10 @@ Before writing any SQL, read the PostHog `querying-posthog-data` skill. It is th
If the required events, properties, or tables do not exist, say so — do not run queries that will return empty results.
+### Format SQL for readability
+
+Write SQL a human can scan: multi-line with indentation, one column/CTE per line, and inline `--` comments for non-obvious logic. This matters most for queries you save via `view-create` / `view-update` — the SQL editor stores and renders the string verbatim, so a minified one-liner stays unreadable for whoever opens the view later.
+
### Handling large results
Large JSON values in results (notably full `properties` objects) are truncated by default. If you anticipate a large result set, or you are selecting the full `properties` object (e.g., `SELECT properties FROM events`), dump the results to a file and process them with bash rather than returning them inline. Alternatively, cherry-pick specific keys (`properties.$browser`) instead of the whole object.
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/view-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/view-create.json
index 351f211ac801..e00e6dfd6e97 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/view-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/view-create.json
@@ -37,7 +37,7 @@
"type": "string"
},
"query": {
- "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT * FROM events LIMIT 100\"}",
+ "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}",
"properties": {
"kind": {
"default": "HogQLQuery",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/view-materialize.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/view-materialize.json
index 948717df2fe9..ab90f674a65c 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/view-materialize.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/view-materialize.json
@@ -62,7 +62,7 @@
"type": "string"
},
"query": {
- "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT * FROM events LIMIT 100\"}",
+ "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}",
"properties": {
"kind": {
"default": "HogQLQuery",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/view-run.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/view-run.json
index 948717df2fe9..ab90f674a65c 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/view-run.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/view-run.json
@@ -62,7 +62,7 @@
"type": "string"
},
"query": {
- "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT * FROM events LIMIT 100\"}",
+ "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}",
"properties": {
"kind": {
"default": "HogQLQuery",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/view-unmaterialize.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/view-unmaterialize.json
index 948717df2fe9..ab90f674a65c 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/view-unmaterialize.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/view-unmaterialize.json
@@ -62,7 +62,7 @@
"type": "string"
},
"query": {
- "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT * FROM events LIMIT 100\"}",
+ "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}",
"properties": {
"kind": {
"default": "HogQLQuery",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/view-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/view-update.json
index 2152f8bee8f2..7f695a1e901c 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/view-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/view-update.json
@@ -52,7 +52,7 @@
"type": "string"
},
"query": {
- "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT * FROM events LIMIT 100\"}",
+ "description": "HogQL query definition as a JSON object with a \"query\" key containing the SQL string and a \"kind\" key (always \"HogQLQuery\"). Format the SQL string multi-line with indentation and inline `--` comments for non-obvious logic — the SQL editor renders it verbatim, so avoid minified single-line SQL. Example: {\"kind\": \"HogQLQuery\", \"query\": \"SELECT\\n event,\\n count() AS cnt\\nFROM events\\nGROUP BY event\\nLIMIT 100\"}",
"properties": {
"kind": {
"default": "HogQLQuery",