mcp-clickhouse

by @ClickHouse

Clickhouse MCP Server

Let AI assistants explore ClickHouse databases, paginate table schemas, and execute parameterized analytical SQL or embedded chDB queries safely. Officially maintained by ClickHouse under Apache-2.0, this Python server defaults to read-only stdio and secures Streamable HTTP with bearer tokens or OAuth/OIDC.

Databases918pythonApache-2.0

Server facts

mcp-clickhouse

GitHub stars

918

Last commit

Nov 16, 2026

Runtime

python

License

Apache-2.0

Project

License
Apache-2.0
Category
Databases

Tech

Runtime
python
Transports
stdiostreamable-httpsse
Remote access
No
Authentication
ClickHouse Credentials / X.509 TLS; Bearer Token or OAuth/OIDC on HTTP

Activity

GitHub stars
918
Last commit
Data as of

Overview

Engineers wiring clickhouse mcp into Claude Desktop, Cursor, Claude Code, or OpenCode need guardrails so analytical exploration never mutates production tables or truncates large integers in JavaScript clients. ClickHouse's official Apache-2.0 Python server (Python 3.10–3.15, with Python 3.12 recommended via `uv`) connects over ClickHouse's HTTP interface (`8123` plain or `8443` HTTPS—not native TCP ports `9000`/`9440`) and exposes `list_databases`, cursor-paginated `list_tables`, `run_query`, and optional embedded `run_chdb_select_query` via `mcp-clickhouse[chdb]`. It speaks MCP 2026-07-28 alongside legacy handshakes, serializes integers outside JavaScript's safe range as exact decimal strings, supports `{name:Type}` parameter binding, and runs `DESCRIBE` and `EXPLAIN ESTIMATE` checks before heavy MergeTree scans.

By default, `CLICKHOUSE_ALLOW_WRITE_ACCESS=false` enforces server-side `readonly=1`; enabling writes still gates `DROP`, `TRUNCATE`, `DELETE`, and `UPDATE` behind a separate `CLICKHOUSE_ALLOW_DROP=true` flag. Local desktop sessions use stdio without MCP-layer auth, requiring only `CLICKHOUSE_HOST`, `CLICKHOUSE_USER`, and `CLICKHOUSE_PASSWORD` (or X.509 client certificates in `mutual`/`proxy`/`strict` TLS modes). Switching `CLICKHOUSE_MCP_SERVER_TRANSPORT=http` exposes `/mcp` and unauthenticated `/health` while mandating `CLICKHOUSE_MCP_AUTH_TOKEN`, FastMCP OAuth/OIDC (`FASTMCP_SERVER_AUTH` for Azure Entra, Google, GitHub, WorkOS, etc.), or explicit local-dev `CLICKHOUSE_MCP_AUTH_DISABLED=true` alongside Host/Origin validation.

Install & configure

Requirements

  • Python 3.10–3.15 (Python 3.12 recommended; chDB extra supports Python 3.10–3.14) and `uv` or `pip`
  • ClickHouse HTTP/HTTPS endpoint (`8123` or `8443`) with least-privilege `CLICKHOUSE_USER` and `CLICKHOUSE_PASSWORD` (or X.509 certificate)
  • For HTTP/SSE transport: static `CLICKHOUSE_MCP_AUTH_TOKEN`, `FASTMCP_SERVER_AUTH` OAuth/OIDC config, or local-only `CLICKHOUSE_MCP_AUTH_DISABLED=true`
Documented launch / install command
python3 -m pip install mcp-clickhouse

Launch via `uv run --with mcp-clickhouse --python 3.12 mcp-clickhouse` in your MCP client config, or install globally with `python3 -m pip install mcp-clickhouse`. Always point `CLICKHOUSE_PORT` at the HTTP interface (`8123`/`8443`), not native TCP (`9000`/`9440`).

Config file · macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

Use Settings → Developer → Edit Config when available. Do not assume a Linux configuration path; check the client documentation for your platform. Remote servers use the app’s connector flow when supported, not the local stdio file shown here. Merge this example with existing settings; do not overwrite unrelated servers.

Claude Desktop configuration
{
  "mcpServers": {
    "mcp-clickhouse": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.12",
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "<clickhouse-host>",
        "CLICKHOUSE_PORT": "8443",
        "CLICKHOUSE_USER": "<clickhouse-user>",
        "CLICKHOUSE_PASSWORD": "<clickhouse-password>",
        "CLICKHOUSE_SECURE": "true",
        "CLICKHOUSE_VERIFY": "true"
      }
    }
  }
}

Read the Claude Desktop setup guide

Config file · Project: .cursor/mcp.json

User: ~/.cursor/mcp.json

The project path is relative to the workspace root. The tilde denotes your user home directory. Use Cursor’s MCP settings to confirm which configuration and scope your installed version is reading. Merge this example with existing settings; do not overwrite unrelated servers.

Cursor configuration
{
  "mcpServers": {
    "mcp-clickhouse": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.12",
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "<clickhouse-host>",
        "CLICKHOUSE_PORT": "8443",
        "CLICKHOUSE_USER": "<clickhouse-user>",
        "CLICKHOUSE_PASSWORD": "<clickhouse-password>",
        "CLICKHOUSE_SECURE": "true",
        "CLICKHOUSE_VERIFY": "true"
      }
    }
  }
}

Read the Cursor setup guide

Config file · Workspace: .vscode/mcp.json

For user scope, use the “MCP: Open User Configuration” command if available. Do not guess a user configuration path across operating systems, profiles, containers, or remote workspaces; check the client documentation. Merge this example with existing settings; do not overwrite unrelated servers.

VS Code configuration
{
  "servers": {
    "mcp-clickhouse": {
      "type": "stdio",
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.12",
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "<clickhouse-host>",
        "CLICKHOUSE_PORT": "8443",
        "CLICKHOUSE_USER": "<clickhouse-user>",
        "CLICKHOUSE_PASSWORD": "<clickhouse-password>",
        "CLICKHOUSE_SECURE": "true",
        "CLICKHOUSE_VERIFY": "true"
      }
    }
  }
}

Read the VS Code setup guide

Config file · macOS/Linux: ~/.codeium/windsurf/mcp_config.json

Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json

Open the MCP configuration through Windsurf’s settings when possible to confirm the active file. Paths can differ in managed or future releases; check the client documentation if this location is not present. Merge this example with existing settings; do not overwrite unrelated servers.

Windsurf configuration
{
  "mcpServers": {
    "mcp-clickhouse": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.12",
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "<clickhouse-host>",
        "CLICKHOUSE_PORT": "8443",
        "CLICKHOUSE_USER": "<clickhouse-user>",
        "CLICKHOUSE_PASSWORD": "<clickhouse-password>",
        "CLICKHOUSE_SECURE": "true",
        "CLICKHOUSE_VERIFY": "true"
      }
    }
  }
}

Read the Windsurf setup guide

Config file · Project scope: .mcp.json at the repository root

The project file uses mcpServers. For user scope, use claude mcp add --scope user rather than assuming .mcp.json in your home directory is the user configuration. Check the client documentation for managed settings and storage details. Merge this example with existing settings; do not overwrite unrelated servers.

Claude Code configuration
{
  "mcpServers": {
    "mcp-clickhouse": {
      "type": "stdio",
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.12",
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "<clickhouse-host>",
        "CLICKHOUSE_PORT": "8443",
        "CLICKHOUSE_USER": "<clickhouse-user>",
        "CLICKHOUSE_PASSWORD": "<clickhouse-password>",
        "CLICKHOUSE_SECURE": "true",
        "CLICKHOUSE_VERIFY": "true"
      }
    }
  }
}

Read the Claude Code setup guide

Examples are translated from the published configuration. Supply your own credentials and verify requirements in the upstream README. Remote connectors are shown only where a supported configuration format is known.

Tools

Source: repository README. Tool descriptions are a documented snapshot, not a live capability check.

ToolWhat it does
run_queryRuns SQL against ClickHouse (read-only by default) with optional `{name:Type}` parameter binding plus `DESCRIBE` and `EXPLAIN ESTIMATE` pre-checks.
list_databasesLists all databases accessible on the configured ClickHouse cluster.
list_tablesPaginates tables within a ClickHouse database using `LIKE`/`NOT LIKE` filters, single-use page tokens, and optional detailed column metadata.
run_chdb_select_queryExecutes embedded ClickHouse SQL queries over local files, URLs, or databases via chDB when `mcp-clickhouse[chdb]` and `CHDB_ENABLED=true` are active.

Use cases

  • Inspect schemas across large ClickHouse clusters using paginated `list_tables` and run `EXPLAIN ESTIMATE` before querying huge MergeTree tables.
  • Query ClickHouse Cloud or the public ClickHouse SQL Playground safely in read-only mode from Claude Desktop, Cursor, or Claude Code.
  • Run ad-hoc embedded SQL analytics on local files and remote URLs without ETL by enabling the optional chDB backend.
  • Expose a secured Streamable HTTP ClickHouse MCP endpoint with FastMCP Azure Entra/Google/GitHub OAuth, custom middleware, and `/health` probes.

Strengths

  • Enforces server-side `readonly=1` by default and adds a separate `CLICKHOUSE_ALLOW_DROP=true` guard even when writes are enabled.
  • Preserves exact UInt64 and oversized integer precision for JavaScript MCP clients by encoding out-of-range integers as decimal strings.
  • Refuses to start HTTP/SSE transport without explicit auth (`CLICKHOUSE_MCP_AUTH_TOKEN`, FastMCP OAuth/OIDC, or dev-only opt-out) and enforces Host/Origin validation.
  • Supports custom FastMCP middleware hooks, per-request client overrides, X.509 client certificates, and optional embedded chDB queries.

Limitations

  • Connects exclusively over ClickHouse's HTTP interface (`8123`/`8443`); pointing it at native TCP ports (`9000`/`9440`) fails.
  • The destructive-operation check is a server-side convenience guard rather than a security boundary—real isolation requires least-privilege ClickHouse user grants.
  • Optional `chdb` support currently caps at Python 3.14 and is skipped on Python 3.15.

mcp-clickhouse setup notes

  • Check CLICKHOUSE_HOST, CLICKHOUSE_PASSWORD, CLICKHOUSE_PORT, CLICKHOUSE_SECURE, CLICKHOUSE_USER, CLICKHOUSE_VERIFY in the mcp-clickhouse configuration if startup or authentication fails.
  • mcp-clickhouse's example uses stdio, while its catalog transports are stdio / streamable-http / sse; use the example's connection type.

Frequently asked questions

Add an `mcp-clickhouse` stdio entry running `uv` with args `["run", "--with", "mcp-clickhouse", "--python", "3.12", "mcp-clickhouse"]` and set `CLICKHOUSE_HOST`, `CLICKHOUSE_PORT`, `CLICKHOUSE_USER`, and `CLICKHOUSE_PASSWORD` in `env`. Use port `8443` with `CLICKHOUSE_SECURE=true` for ClickHouse Cloud or port `8123` with `CLICKHOUSE_SECURE=false` for local plain-HTTP Docker clusters.

Related MCP servers