Execute ad-hoc SQL
execute_queryRun ad-hoc SQL queries on BigQuery, Postgres, or ClickHouse. Choose the dialect that matches your data source and execute instantly.
Instructions
Run an ad-hoc SQL query. Provide exactly one dialect: BigQuery, Postgres, or ClickHouse. Prefer query_endpoint when a saved endpoint exists.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bq_sql | No | BigQuery SQL. | |
| pg_sql | No | Postgres SQL. | |
| ch_sql | No | ClickHouse SQL. |
Implementation Reference
- src/logflare.ts:107-117 (handler)The executeQuery method in LogflareClient that makes the actual API call to /api/query with the SQL parameters.
executeQuery(args: { bqSql?: string pgSql?: string chSql?: string }) { const query: Record<string, string> = {} if (args.bqSql) query.bq_sql = args.bqSql if (args.pgSql) query.pg_sql = args.pgSql if (args.chSql) query.ch_sql = args.chSql return this.request<unknown>('/api/query', { query }) } - src/index.ts:156-184 (registration)The server.registerTool call for 'execute_query' that defines the input schema (bq_sql, pg_sql, ch_sql) and handler that validates exactly one SQL dialect is provided, then delegates to client.executeQuery.
server.registerTool( 'execute_query', { title: 'Execute ad-hoc SQL', description: 'Run an ad-hoc SQL query. Provide exactly one dialect: BigQuery, Postgres, or ClickHouse. ' + 'Prefer query_endpoint when a saved endpoint exists.', inputSchema: { bq_sql: z.string().optional().describe('BigQuery SQL.'), pg_sql: z.string().optional().describe('Postgres SQL.'), ch_sql: z.string().optional().describe('ClickHouse SQL.'), }, }, async ({ bq_sql, pg_sql, ch_sql }) => { const provided = [bq_sql, pg_sql, ch_sql].filter(Boolean).length if (provided !== 1) { return errorText( 'Provide exactly one of bq_sql, pg_sql, or ch_sql.', ) } try { return text( await client.executeQuery({ bqSql: bq_sql, pgSql: pg_sql, chSql: ch_sql }), ) } catch (err) { return errorText(err) } }, ) - src/index.ts:163-167 (schema)Zod input schema for execute_query defining three optional string parameters: bq_sql, pg_sql, ch_sql.
inputSchema: { bq_sql: z.string().optional().describe('BigQuery SQL.'), pg_sql: z.string().optional().describe('Postgres SQL.'), ch_sql: z.string().optional().describe('ClickHouse SQL.'), },