ClickHouse MCP Server

Query and explore ClickHouse databases, or the embedded chDB engine, with SQL from an MCP client

Official · ClickHouse Python Local · stdio DatabasesData and analytics

82 popularity score ★ 903 ↓ 241k/mo

Connect your client

Local (PyPI)

Add in one click

Opens the app, which asks before it adds the server. Then replace each <NAME> in its settings with your value.

Or add it by command or config

It needs CLICKHOUSE_HOST, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD. Replace each <NAME> with your value.

Claude CodeTerminal
claude mcp add clickhouse -e CLICKHOUSE_HOST=<CLICKHOUSE_HOST> -e CLICKHOUSE_USER=<CLICKHOUSE_USER> -e CLICKHOUSE_PASSWORD=<CLICKHOUSE_PASSWORD> -- uv run --with mcp-clickhouse --python 3.12 mcp-clickhouse
Claude Desktopclaude_desktop_config.json
{
  "mcpServers": {
    "clickhouse": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.12",
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "<CLICKHOUSE_HOST>",
        "CLICKHOUSE_USER": "<CLICKHOUSE_USER>",
        "CLICKHOUSE_PASSWORD": "<CLICKHOUSE_PASSWORD>"
      }
    }
  }
}
Cursor~/.cursor/mcp.json
{
  "mcpServers": {
    "clickhouse": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.12",
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "<CLICKHOUSE_HOST>",
        "CLICKHOUSE_USER": "<CLICKHOUSE_USER>",
        "CLICKHOUSE_PASSWORD": "<CLICKHOUSE_PASSWORD>"
      }
    }
  }
}
VS Code.vscode/mcp.json
{
  "servers": {
    "clickhouse": {
      "type": "stdio",
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.12",
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "<CLICKHOUSE_HOST>",
        "CLICKHOUSE_USER": "<CLICKHOUSE_USER>",
        "CLICKHOUSE_PASSWORD": "<CLICKHOUSE_PASSWORD>"
      }
    }
  }
}
Codex~/.codex/config.toml
[mcp_servers.clickhouse]
command = "uv"
args = ["run", "--with", "mcp-clickhouse", "--python", "3.12", "mcp-clickhouse"]

[mcp_servers.clickhouse.env]
CLICKHOUSE_HOST = "<CLICKHOUSE_HOST>"
CLICKHOUSE_USER = "<CLICKHOUSE_USER>"
CLICKHOUSE_PASSWORD = "<CLICKHOUSE_PASSWORD>"
Gemini CLITerminal
gemini mcp add --scope user -e CLICKHOUSE_HOST=<CLICKHOUSE_HOST> -e CLICKHOUSE_USER=<CLICKHOUSE_USER> -e CLICKHOUSE_PASSWORD=<CLICKHOUSE_PASSWORD> clickhouse uv -- run --with mcp-clickhouse --python 3.12 mcp-clickhouse

Settings 12

CLICKHOUSE_HOST Required: Hostname of the ClickHouse server.
CLICKHOUSE_USER Required: ClickHouse user to connect as; use a least-privilege user.
CLICKHOUSE_PASSWORD Required: Password for that user; not needed when a client certificate is used in mutual TLS mode.
CLICKHOUSE_PORT Optional: HTTP interface port; 8443 when secure, 8123 otherwise.
CLICKHOUSE_SECURE Optional: Use HTTPS to reach ClickHouse; default true.
CLICKHOUSE_DATABASE Optional: Default database for queries.
CLICKHOUSE_ROLE Optional: ClickHouse role to use, if the user needs one.
CLICKHOUSE_ALLOW_WRITE_ACCESS Optional: Set true to allow inserts and DDL; default false (read-only).
CLICKHOUSE_ALLOW_DROP Optional: Set true, with write access, to allow DROP, TRUNCATE, DELETE and UPDATE.
CLICKHOUSE_MCP_QUERY_TIMEOUT Optional: Query timeout in seconds; default 30.
CHDB_ENABLED Optional: Set true to add the chDB tool; needs the mcp-clickhouse[chdb] extra.
CLICKHOUSE_MCP_SERVER_TRANSPORT Optional: stdio (default), http or sse; http/sse need CLICKHOUSE_MCP_AUTH_TOKEN or another auth setting.

What it does

ClickHouse's own MCP server connects an assistant to a ClickHouse cluster over the database's HTTP interface. Out of the box it gives three tools: one lists databases, one pages through the tables in a database with their columns and CREATE statements, and one runs SQL. The SQL tool also accepts DESCRIBE and EXPLAIN ESTIMATE, so a query's output columns or its estimated reads can be checked before it runs. Values can be bound to ClickHouse {name:Type} placeholders through a separate params object instead of being pasted into the SQL.

By default every query runs with ClickHouse's readonly=1 setting. CLICKHOUSE_ALLOW_WRITE_ACCESS=true allows inserts and non-destructive DDL. DROP, TRUNCATE, DELETE, UPDATE and similar statements also need CLICKHOUSE_ALLOW_DROP=true. Queries time out after 30 seconds by default, and the server then tries to cancel them with KILL QUERY.

With the chdb extra installed and CHDB_ENABLED=true, it adds a fourth tool, run_chdb_select_query, and a chdb_initial_prompt prompt. These run SQL in chDB, an in-process ClickHouse engine that can read files and URLs without a server. If chDB is switched on but the extra is missing, the v0.7.0 code (mcp_clickhouse/mcp_server.py) only logs a warning and leaves the tool out, so the tool may be missing without any startup error. Setting CLICKHOUSE_ENABLED=false removes the three ClickHouse tools for a chDB-only setup.

It speaks stdio by default. It can also serve Streamable HTTP or the deprecated SSE transport, with a bearer token or a FastMCP OAuth/OIDC provider in front.

What it needs

RuntimePython 3.10+

Python 3.10 to 3.14, with 3.12 recommended. The documented launch command uses uv. You need a ClickHouse server reachable over its HTTP interface (8123/8443, not the native 9000/9440 ports) and a ClickHouse user and password. ClickHouse's public SQL Playground works with the demo user. chDB needs the mcp-clickhouse[chdb] extra and no server.

Limits

Only ClickHouse's HTTP interface is supported; native-protocol ports fail. Writes are off unless CLICKHOUSE_ALLOW_WRITE_ACCESS=true. The extra CLICKHOUSE_ALLOW_DROP check is described as a best-effort guard in the server, not a security boundary. Queries time out after 30 s by default (CLICKHOUSE_MCP_QUERY_TIMEOUT). list_tables returns 50 tables per page by default. ClickHouse Cloud does not accept X.509 client certificates. Over HTTP/SSE, startup fails unless a token, an OAuth provider or explicitly disabled auth is configured. The SSE transport is deprecated.

Who it suits

It suits developers and analysts who run ClickHouse, whether self-hosted or ClickHouse Cloud, and want an assistant to explore schemas and run analytical SQL. Because the default is read-only, it is a reasonable first connection to a production cluster when paired with a least-privilege ClickHouse user. chDB mode suits ad-hoc SQL over local files without a database server. Teams that need writes must turn them on and should restrict grants in ClickHouse itself. For other databases, pick a server built for them.

Tools 4

list_databases
Lists the databases on the connected ClickHouse server.
list_tables
Pages through a database's tables with column details, filtered by LIKE/NOT LIKE patterns.
run_query
Runs SQL, with optional named parameters; read-only unless write access is turned on.
run_chdb_select_query
Runs SQL in the embedded chDB engine; present only when chDB is enabled and installed.

Similar servers