You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rely on clickhouse client for readonly and limit for typescript-mcp template (#2968)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Switches MCP template to rely on ClickHouse readonly mode and
client-enforced limits, updates query tool schema, and removes custom
SQL validation/limit utilities.
>
> - **MCP Server (`templates/typescript-mcp/app/apis/mcp.ts`)**:
> - Add `clickhouseReadonlyQuery` to execute JSONEachRow queries with
ClickHouse `readonly=2` and enforced `limit`.
> - Update `query_clickhouse` tool: read-only description, increase
`limit` max to `1000`, remove whitelist/blocklist validation and manual
LIMIT handling; rely on DB-level readonly.
> - Use direct SQL strings and apply high limit (`10000`) for catalog
metadata queries; route result parsing through the new helper.
> - Reorganize catalog type interfaces (`DataCatalogParams`,
`ColumnInfo`, `TableInfo`, `DataCatalogResponse`).
> - **Removal**:
> - Delete `templates/typescript-mcp/app/apis/utils/sql.ts` and drop
related imports (`validateQuery`, `applyLimitToQuery`, `Sql`, `sql`).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
83cc45e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
* - Row limit enforcement: Results automatically limited to maximum of 100 rows
270
+
* Allows AI assistants to execute SQL queries against ClickHouse.
271
+
* Results are limited to max 1000 rows to prevent excessive data transfer.
272
+
* Security is enforced at the database level using ClickHouse readonly mode.
261
273
*/
262
274
server.registerTool(
263
275
"query_clickhouse",
276
+
/**
277
+
* Type assertion needed here due to MCP SDK type limitations.
278
+
* The SDK expects Record<string, ZodTypeAny> but our schema structure
279
+
* doesn't match that exact type. Runtime validation still works correctly.
280
+
*/
264
281
{
265
282
title: "Query ClickHouse Database",
266
283
description:
267
-
"Execute a SQL query against the ClickHouse OLAP database and return results as JSON",
284
+
"Execute a read-only query against the ClickHouse OLAP database and return results as JSON. Use SELECT, SHOW, DESCRIBE, or EXPLAIN queries only. Data modification queries (INSERT, UPDATE, DELETE, ALTER, CREATE, etc.) are prohibited.",
268
285
inputSchema: {
269
286
query: z.string().describe("SQL query to execute against ClickHouse"),
270
287
limit: z
271
288
.number()
272
289
.min(1)
273
-
.max(100)
290
+
.max(1000)
274
291
.default(100)
275
292
.optional()
276
293
.describe(
277
-
"Maximum number of rows to return (default: 100, max: 100)",
294
+
"Maximum number of rows to return (default: 100, max: 1000)",
0 commit comments