Blog
guide

How to Connect ClickHouse to Claude Code Using Sequel

Musthaq Ahamad
Musthaq Ahamad
How to Connect ClickHouse to Claude Code Using Sequel

ClickHouse is designed for blazing-fast analytics over massive datasets: billions of rows, sub-second aggregations. Claude Code is Anthropic's AI CLI that lives in your terminal. With Sequel's MCP server bridging them, you can ask analytics questions about your ClickHouse data in plain English without switching tools or writing complex SQL.

What You'll Accomplish

After completing this setup, you'll be able to run Claude Code and ask:

  • "How many events were tracked yesterday, broken down by event type?"
  • "What's the p99 latency for API requests in the past 24 hours?"
  • "Which country has the most active users this week?"

Prerequisites

  • A Sequel account -- Sign up free at sequel.sh
  • A running ClickHouse instance -- ClickHouse Cloud or self-hosted
  • Claude Code installed -- run npm install -g @anthropic-ai/claude-code if needed

Step 1: Connect Your ClickHouse Database to Sequel

Sign in to sequel.sh and click Data Sources in the left sidebar.

Sequel Data Sources page

Click New Connection. On the "Choose a connector" page, select ClickHouse.

Choose a connector

Fill in the connection fields:

  • Connection Name -- a memorable label, e.g. ClickHouse Analytics
  • Host -- your ClickHouse hostname, without https:// or http:// prefix
  • Port -- 8443 for ClickHouse Cloud (HTTPS), 8123 for self-hosted HTTP
  • Username -- e.g. default
  • Password -- your ClickHouse password
  • Database -- the database name to connect to

ClickHouse connection form

ClickHouse Cloud example: If your JDBC URL is jdbc:clickhouse://abc123.us-east-1.aws.clickhouse.cloud:8443?user=default&password=mypass&ssl=true, enter:

  • Host: abc123.us-east-1.aws.clickhouse.cloud
  • Port: 8443
  • Username: default
  • Password: mypass

Click Connect to verify and save.

Step 2: Get Your Sequel API Key

Click Settings in the left sidebar, then select API Keys from the settings navigation.

Sequel API Keys page

Click New key, name it claude-code-clickhouse, and copy the key (starts with sql_).

Step 3: Configure Claude Code to Use Sequel MCP

In your terminal:

claude mcp add sequel \
  --transport http \
  https://api.sequel.sh/mcp \
  --header "Authorization: Bearer sql_your_api_key"

Replace sql_your_api_key with the key from Step 2. Verify with:

claude mcp list

Step 4: Query Your ClickHouse Database

Start a Claude Code session:

How many page views were recorded in the last 7 days?
What's the breakdown of sessions by device type this month?
Show me the top 10 error codes by frequency in the past 24 hours.

Claude Code translates these to ClickHouse-optimized SQL queries and returns results fast.

What You Can Do Now

  • Real-time monitoring -- ask "Are error rates higher than usual in the past hour?" during an incident
  • Funnel analysis -- ask "What percentage of users who started checkout completed a purchase today?"
  • Performance debugging -- ask "What are the slowest API endpoints by p95 latency over the past week?"
  • Schema navigation -- ask "What tables are in this cluster?" to orient yourself on a large ClickHouse database
  • Executive metrics -- ask "Give me key engagement metrics for this month vs. last month"

Try Sequel

Meet your always-on data analyst.

Connect your database and get instant answers in plain English. Free for up to 3 seats - no credit card required.

Get started free

Frequently asked questions

Does Sequel support ClickHouse Cloud as well as self-hosted ClickHouse?

Yes. Sequel works with both ClickHouse Cloud and self-hosted ClickHouse instances. Use port 8443 for HTTPS (ClickHouse Cloud default) or 8123 for HTTP on self-hosted instances.

What credentials do I need to connect ClickHouse to Sequel?

You need the hostname (without https:// or http://), port (typically 8443 for ClickHouse Cloud), username (often "default"), and password. Sequel adds the HTTPS prefix automatically.

Does this work with ClickHouse's MergeTree and AggregatingMergeTree tables?

Yes. Sequel queries ClickHouse using standard SQL, so it works with all ClickHouse table engines including MergeTree, ReplicatedMergeTree, AggregatingMergeTree, and others.

Is a read-only ClickHouse user recommended?

Yes. Create a user with SELECT-only permissions on the databases you want to query. In ClickHouse, this is done by assigning the readonly profile or creating a role with specific GRANT SELECT permissions.

Can Claude Code aggregate billions of rows through this integration?

Yes. ClickHouse is built for fast aggregations over large datasets, and Sequel generates aggregation queries that leverage that. Questions like "What's the sum of events by country in the past year?" return quickly.

Where do I find my ClickHouse Cloud connection details?

In your ClickHouse Cloud console, go to your service and click Connect. Choose the HTTP interface or JDBC connection string and extract the host, port, username, and password from there.

Written by

Musthaq Ahamad
Musthaq Ahamad

Co-founder and CEO of Sequel. Previously built developer tools and data infrastructure. Passionate about making data accessible for everyone.