> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/clickhouse.md).

# ClickHouse

Connect to ClickHouse to run SQL queries and explore tables and schemas in your ClickHouse database from your AI workflows.

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector        | Authentication   |
| ---------------- | ---------------- |
| ClickHouse       | Credentials      |
| ClickHouse (JWT) | JWT Access Token |

#### ClickHouse

Connect to a ClickHouse database using username and password. Works with ClickHouse Cloud and self-hosted deployments over HTTP or HTTPS.

**Set up in ClickHouse**

1. Prepare the ClickHouse account or service that the workflow will access. Grant access to the required resources and operations.
2. **Host:** ClickHouse server hostname. For ClickHouse Cloud, use the hostname from your service.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **ClickHouse**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field             | Required                 | What to enter                                                                                                                                                     |
| ------------------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Host                      | Yes                      | ClickHouse server hostname. For ClickHouse Cloud, use the hostname from your service.                                                                             |
| Port                      | Optional / as applicable | 8443 for HTTPS (ClickHouse Cloud), 8123 for HTTP.                                                                                                                 |
| Username                  | Optional / as applicable | The ClickHouse user to authenticate as.                                                                                                                           |
| Password                  | Yes                      | The password for the ClickHouse user.                                                                                                                             |
| Database                  | Optional / as applicable | The default database to connect to.                                                                                                                               |
| Use HTTPS                 | Optional / as applicable | Use HTTPS (TLS) for the connection. Keep enabled for ClickHouse Cloud.                                                                                            |
| Verify TLS Certificate    | Optional / as applicable | Verify the server's TLS certificate. Disable only for self-signed certs in trusted environments. For private CAs, prefer providing `ca_cert` and leaving this on. |
| CA Certificate (optional) | Optional / as applicable | PEM-encoded CA certificate bundle to verify the server. Use this for self-hosted ClickHouse behind a private CA. Leave blank to use the system trust store.       |

**Provider documentation:** [Setup reference](https://clickhouse.com/docs/en/integrations/sql-clients).

#### ClickHouse (JWT)

Connect to ClickHouse Cloud using a JWT bearer token issued by your identity provider (Okta, Auth0, Azure AD, etc.). The IdP must be configured as a trusted JWT validator in your ClickHouse Cloud organization.

**Set up in ClickHouse**

1. Obtain a JWT bearer token issued by that identity provider for the ClickHouse Cloud user.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **ClickHouse (JWT)**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field             | Required                 | What to enter                                                                                                                                                                                                                                                           |
| ------------------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Host                      | Yes                      | ClickHouse Cloud hostname. JWT auth is not supported on self-hosted ClickHouse.                                                                                                                                                                                         |
| Port                      | Optional / as applicable | HTTPS port (default 8443 for ClickHouse Cloud).                                                                                                                                                                                                                         |
| JWT Access Token          | Yes                      | A JWT issued by your IdP (Okta, Auth0, Azure AD, etc.) that is trusted by your ClickHouse Cloud organization. The token must be valid at connection time; token refresh is handled externally. [Provider instructions](https://clickhouse.com/docs/cloud/security/jwt). |
| Database                  | Optional / as applicable | The default database to connect to.                                                                                                                                                                                                                                     |
| CA Certificate (optional) | Optional / as applicable | PEM-encoded CA certificate bundle to verify the server. ClickHouse Cloud uses publicly trusted certs, so this is rarely needed -- only set it if your IdP routes through a private CA.                                                                                  |

**Provider documentation:** [Setup reference](https://clickhouse.com/docs/en/cloud/security/cloud-authentication).

#### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

### Use an action

1. Add the required **ClickHouse** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Query ClickHouse

Run a read-only SQL query against a ClickHouse database.

**Inputs**

| Field               | Type            | Required | Description                                                                                                                                          |
| ------------------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| Query               | string          | Yes      | SQL query to execute. SELECT/WITH only; writes and DDL are rejected. Default: .                                                                      |
| Database (optional) | select (string) | No       | Optional database override; pick from the dropdown or type a name. Defaults to the connection's database. Options load from the selected connection. |

**Outputs**

| Field     | Type        | Description                                                                              |
| --------- | ----------- | ---------------------------------------------------------------------------------------- |
| SQL Query | string      | The SQL query that was executed.                                                         |
| Results   | dict\_array | Result rows as JSON objects keyed by column name.                                        |
| Truncated | boolean     | True if the result set was capped by the row guard; add a tighter LIMIT to see the rest. |

#### Describe Table

Describe a ClickHouse table -- engine, keys, columns, and types.

**Inputs**

| Field               | Type            | Required | Description                                                                                                                                          |
| ------------------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| Table               | select (string) | Yes      | Table to describe. Pick from the dropdown or type a name; accepts `table` or `database.table`. Options load from the selected connection. Default: . |
| Database (optional) | select (string) | No       | Optional database override; pick from the dropdown or type a name. Ignored if `table` is qualified. Options load from the selected connection.       |

**Outputs**

| Field                 | Type   | Description                                        |
| --------------------- | ------ | -------------------------------------------------- |
| Schema summary (text) | string | Schema as a prompt-ready string for LLM grounding. |
| Schema (data)         | dict   | Schema as structured data for code paths.          |

#### List Tables

List ClickHouse tables with engine, row count, and comment.

**Inputs**

| Field                           | Type            | Required | Description                                                                                                                                               |
| ------------------------------- | --------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Database (optional)             | select (string) | No       | Optional database scope; pick from the dropdown or type a name. Leave blank to list across all user databases. Options load from the selected connection. |
| Filter by table name (optional) | string          | No       | Glob on table name. `*` = any sequence, `?` = one character. Example: `orders_*` matches `orders_2024`, `orders_archive`.                                 |
| Include system databases        | boolean         | No       | If true, include ClickHouse internal databases. Off by default. Default: false.                                                                           |

**Outputs**

| Field                 | Type        | Description                                                                       |
| --------------------- | ----------- | --------------------------------------------------------------------------------- |
| Tables summary (text) | string      | Inventory as a prompt-ready string for LLM grounding.                             |
| Tables (data)         | dict\_array | Inventory as structured data: database, name, engine, total\_rows, comment.       |
| Truncated             | boolean     | True if more tables matched than were returned; narrow `name_filter` to see more. |

### Important behavior

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/clickhouse.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
