ClickHouse
ClickHouse
Connect agents to ClickHouse so they can explore events and metrics with fast analytical SQL.
Analyze your data
- Count, group, and chart large tables in seconds.
- Read arrays, maps, and tuples as structured data.
- Inspect databases, tables, and columns to find what a question needs.
Make changes when you allow it
With Write access, agents can also insert data and create or alter tables. With Read access, every query runs with ClickHouse's read-only setting, so data, schema and settings cannot change. Your user's grants and settings profile always apply.
Setup instructions
Setup instructions
Connect ClickHouse
-
Create a ClickHouse user for Houston with only the grants agents need. For read-only access, for example:
CREATE USER houston IDENTIFIED BY 'choose-a-strong-password'; GRANT SELECT ON analytics.* TO houston; -
Make the HTTPS interface reachable from the internet; ClickHouse Cloud serves it on port 8443. Houston always verifies that the server certificate is issued by a public certificate authority for the host name you enter, and never connects without TLS.
-
In Houston, choose the access level, then enter the host, HTTPS port, database, username, and password, and select Add connection.
Files
Files
connector.luau
-- ClickHouse over Houston's verified HTTPS connection. Credentials stay on Houston. type Params = {[string]: string | number | boolean} type Result = {columns: {string}, rows: {{[string]: any}}, truncated: boolean} local MAX_ROWS = 10000 local help = { text = "clickhouse: SQL on one ClickHouse database. Each call is one statement on its own connection; your database grants and settings profiles still apply.", functions = {} :: {[string]: any}, } local exports: {[string]: any} = {help = help} local parameterSchema = {type = "object", additionalProperties = {type = {"string", "number", "boolean"}}} help.functions.query = { description = [[Runs one query with readonly=1. Bind values with ClickHouse placeholders such as {day:Date} in sql and pass them by name in params (strings, numbers, booleans); ClickHouse binds them on the server, so they are never quoted into the SQL. rows are objects keyed by column name, in columns order; NULL columns are absent. Numbers, booleans, arrays, tuples and maps become Lua values; integers beyond 2^53 and Decimal values become strings, and dates and times keep ClickHouse's text form, such as '2026-01-31 09:30:00'. Select hex(column) for binary strings. At most 10,000 rows or 4 MiB are returned; truncated tells when more exist, so add LIMIT, filters or aggregation. Give duplicate column names an alias.]], args = {"sql", "params"}, inputSchema = { type = "object", properties = {sql = {type = "string", minLength = 1}, params = parameterSchema}, required = {"sql"}, additionalProperties = false, examples = {{sql = "SELECT count() AS n FROM events WHERE day = {day:Date}", params = {day = "2026-01-31"}}}, }, annotations = {readOnlyHint = true, openWorldHint = true}, } function exports.query(sql: string, params: Params?): Result return await(db.query({sql = sql, params = params, maxRows = MAX_ROWS, readOnly = true})) end if houston.allows("data:write") then help.functions.execute = { description = [[Runs one statement that may change data or schema, such as INSERT, ALTER or CREATE, with the same parameters as query. ClickHouse reports no affected-row count. A failed or interrupted call may already have applied its change, so check before running it again.]], args = {"sql", "params"}, inputSchema = { type = "object", properties = {sql = {type = "string", minLength = 1}, params = parameterSchema}, required = {"sql"}, additionalProperties = false, examples = {{sql = "INSERT INTO events (day, event) VALUES ({day:Date}, {event:String})", params = {day = "2026-01-31", event = "signup"}}}, }, annotations = {readOnlyHint = false, openWorldHint = true}, } function exports.execute(sql: string, params: Params?): Result return await(db.query({sql = sql, params = params, readOnly = false})) end end return exportshouston.json
{ "schema_version": 2, "name": "ClickHouse", "files": [ "connector.luau" ], "icon": "icon.svg", "access": [ { "name": "data", "label": "Access", "levels": [ { "value": "read", "label": "Read" }, { "value": "write", "label": "Write" } ], "default": "read" } ], "config": { "host": { "label": "Host", "order": 2, "required": true, "type": "string" }, "port": { "default": 8443, "label": "HTTPS port", "maximum": 65535, "minimum": 1, "order": 3, "type": "integer" }, "database": { "default": "default", "label": "Database", "order": 4, "type": "string" }, "username": { "label": "Username", "order": 5, "required": true, "type": "string" }, "password": { "label": "Password", "order": 6, "required": true, "type": "secret" } }, "proxy": [ { "match": { "protocol": "clickhouse" }, "action": { "connection": { "host": "{{config.host}}", "port": "{{config.port}}", "database": "{{config.database}}", "user": "{{config.username}}", "password": "{{config.password}}", "tls": { "mode": "verify-full" } } } } ] }icon.svg
README.md
--- description: Give agents SQL access to ClickHouse for fast analytics, read-only unless you allow changes. --- # ClickHouse Connect agents to ClickHouse so they can explore events and metrics with fast analytical SQL. ## Analyze your data - Count, group, and chart large tables in seconds. - Read arrays, maps, and tuples as structured data. - Inspect databases, tables, and columns to find what a question needs. ## Make changes when you allow it With **Write** access, agents can also insert data and create or alter tables. With **Read** access, every query runs with ClickHouse's read-only setting, so data, schema and settings cannot change. Your user's grants and settings profile always apply.SETUP.md
# Connect ClickHouse 1. Create a ClickHouse user for Houston with only the grants agents need. For read-only access, for example: ```sql CREATE USER houston IDENTIFIED BY 'choose-a-strong-password'; GRANT SELECT ON analytics.* TO houston; ``` 2. Make the HTTPS interface reachable from the internet; ClickHouse Cloud serves it on port 8443. Houston always verifies that the server certificate is issued by a public certificate authority for the host name you enter, and never connects without TLS. 3. In Houston, choose the access level, then enter the host, HTTPS port, database, username, and password, and select **Add connection**.tests
authentication.luau
return { contract = function(m) m.authentication({ { auth = {}, config = { database = "sample", host = "database.example.com", password = "synthetic-root-secret", username = "reader", }, method = "", native = true, publisher = {}, }, }) end, }read_only.luau
-- Read access exposes query alone, and it always asks for a read-only statement. return { scenario = {publisher = {}, auth_method = "", auth_config = {}, config = {host = "db.example.com", database = "app", username = "reader", password = "fixture-password"}}, access = {data = "read"}, configure = function() requests = {} db = {query = function(request) table.insert(requests, request) return fixture.operation({columns = {"n"}, rows = {{n = 7}}, truncated = false}) end} end, run = function(exports) assert(exports.execute == nil, "read access must not expose execute") local result = fixture.example("query") assert(result.rows[1].n == 7 and result.truncated == false) local request = requests[1] assert(request.params.day == "2026-01-31") assert(request.readOnly == true and request.maxRows == 10000) end, }read_write.luau
-- Write access adds execute, which sends a statement allowed to write. return { scenario = {publisher = {}, auth_method = "", auth_config = {}, config = {host = "db.example.com", username = "writer", password = "fixture-password"}}, access = {data = "write"}, configure = function() requests = {} db = {query = function(request) table.insert(requests, request) return fixture.operation({columns = json.decode("[]"), rows = json.decode("[]"), truncated = false}) end} end, run = function(exports) local result = fixture.example("execute") assert(#result.rows == 0 and result.affectedRows == nil) assert(requests[1].readOnly == false and requests[1].params.event == "signup") end, }