ClickHouse MCP: how to connect ClickHouse to Claude, Cursor or Codex

There are three ways to give an AI assistant access to ClickHouse over MCP: run ClickHouse's own open-source server on your machine, use the hosted endpoint that comes with ClickHouse Cloud, or connect through Contextflo when a whole team needs it. Here is how each one is set up.
The options at a glance
| Option | Runs where | Auth | Best for |
|---|---|---|---|
mcp-clickhouse (open source, by ClickHouse) | Your machine | ClickHouse user and password in the config | One person, any ClickHouse |
| ClickHouse Cloud remote MCP | Hosted by ClickHouse | OAuth sign-in, or a Cloud API key | ClickHouse Cloud users |
| Contextflo | Hosted, connects once | OAuth sign-in per person | A team asking questions about the same data |
Option 1: the open-source server, mcp-clickhouse
ClickHouse maintains mcp-clickhouse on GitHub. It exposes run_query, list_databases and list_tables, and it's read-only unless you set CLICKHOUSE_ALLOW_WRITE_ACCESS=true.
For Claude Desktop, add it to claude_desktop_config.json:
{
"mcpServers": {
"mcp-clickhouse": {
"command": "uv",
"args": ["run", "--with", "mcp-clickhouse", "--python", "3.12", "mcp-clickhouse"],
"env": {
"CLICKHOUSE_HOST": "<host>",
"CLICKHOUSE_PORT": "8443",
"CLICKHOUSE_USER": "<read-only user>",
"CLICKHOUSE_PASSWORD": "<password>",
"CLICKHOUSE_SECURE": "true",
"CLICKHOUSE_VERIFY": "true"
}
}
}
}
Cursor reads the same mcpServers shape from ~/.cursor/mcp.json. Codex uses TOML in ~/.codex/config.toml:
[mcp_servers.clickhouse]
command = "uv"
args = ["run", "--with", "mcp-clickhouse", "--python", "3.12", "mcp-clickhouse"]
[mcp_servers.clickhouse.env]
CLICKHOUSE_HOST = "<host>"
CLICKHOUSE_PORT = "8443"
CLICKHOUSE_USER = "<read-only user>"
CLICKHOUSE_PASSWORD = "<password>"
CLICKHOUSE_SECURE = "true"
To try it before pointing it at your own data, use ClickHouse's public playground: host sql-clickhouse.clickhouse.com, port 8443, user demo, empty password.
Option 2: ClickHouse Cloud's hosted MCP endpoint
If you're on ClickHouse Cloud, there's nothing to install. Enable MCP on your service (Connect, then MCP), then add the remote URL to your assistant:
https://mcp.clickhouse.cloud/mcp
You sign in with OAuth in the browser. ClickHouse documents the tools as read-only: running SELECT queries and listing databases and tables, plus tools for your organization, services, backups, ClickPipes and billing.
In Cursor that's a url entry in mcp.json:
{
"mcpServers": {
"clickhouse-cloud": { "url": "https://mcp.clickhouse.cloud/mcp" }
}
}
In Codex, a url under [mcp_servers.clickhouse-cloud], then codex mcp login clickhouse-cloud to sign in. In Claude, add it as a custom connector under Settings, Connectors.
Where both stop for a team
Both options connect one person to ClickHouse. Once a few people are asking questions, the gaps show up:
- Nobody shares context. ClickHouse event tables are wide and full of codes. Each person's assistant guesses what
event_type = 7orstsmeans on its own. - Access is all or nothing. Everyone gets whatever the ClickHouse user can read.
- You can't see what was asked.
system.query_logshows the SQL, not who asked the question or what the assistant told them.
Option 3: ClickHouse with Contextflo
Contextflo connects to ClickHouse once with a read-only user. It generates table and column descriptions, lets you save the definitions your team agrees on, controls which tables each person can query, and keeps an audit trail of prompts and the SQL that ran. Your team connects their own assistant, Claude, Cursor, Codex, ChatGPT or Grok, to one URL:
https://mcp.contextflo.com/mcp
Everyone signs in with their own account, so access and the audit trail are per person. More on the setup in connecting Claude to ClickHouse.
You do the modeling, we do the rest. Connect ClickHouse free.
FAQ
Is there an official ClickHouse MCP server? Yes, two. ClickHouse maintains the open-source mcp-clickhouse server, which you run locally with uv or pip, and ClickHouse Cloud offers a hosted remote MCP endpoint at https://mcp.clickhouse.cloud/mcp that you sign in to with OAuth.
Is the ClickHouse MCP server read-only? By default, yes. mcp-clickhouse runs queries read-only unless you set CLICKHOUSE_ALLOW_WRITE_ACCESS to true, and dropping tables needs a separate CLICKHOUSE_ALLOW_DROP flag. ClickHouse documents the Cloud remote MCP tools as read-only. Connect with a read-only ClickHouse user anyway.
Can I try the ClickHouse MCP server without my own database? Yes. The mcp-clickhouse README points at ClickHouse's public SQL playground: host sql-clickhouse.clickhouse.com, port 8443, user demo, empty password, secure connection on.
How do I connect ClickHouse to Claude for a whole team? The local server runs on one person's machine with that person's credentials. For a team, Contextflo connects to ClickHouse once with a read-only user, adds table descriptions and shared definitions, controls which tables each person can query, and keeps an audit trail of prompts and the SQL that ran.
See it on your own data.
Connect your warehouse and your team can ask Claude about it the same day, without waiting on a data team. Want a walkthrough first? Grab 20 minutes.
Book a 20-minute callSee how teams use Contextflo
Related posts
Keep reading

Conversational analytics: 5 ways to set it up, compared
7 min read

How to connect Claude to BigQuery? What works and what doesn't in 2026
8 min read

How to connect Claude to Postgres without giving it write access
9 min read

How to build a BI dashboard with Claude that your team can actually trust
8 min read

How to give Claude read-only access to your database (it isn't always the default)
7 min read

You connected your warehouse to Claude, now what?
5 min read

Query BigQuery from the Codex CLI with MCP
5 min read

Run ClickHouse queries from Codex with MCP
6 min read

Databricks in Codex: Genie One MCP or Contextflo
5 min read




