# ClickHouse

> Query ClickHouse and ClickHouse Cloud columnar warehouses from an AI agent.

[Canonical HTML page](https://top-mcps.com/mcp/clickhouse) · [server.json](https://top-mcps.com/mcp/clickhouse.json) · [methodology](https://top-mcps.com/about/methodology)

## Install

### Claude Desktop — `claude_desktop_config.json`

Paste under mcpServers. Fully quit and reopen Claude after editing.

```json
{
  "mcpServers": {
    "clickhouse": {
      "command": "uvx",
      "args": [
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "${CLICKHOUSE_HOST}",
        "CLICKHOUSE_PORT": "${CLICKHOUSE_PORT}",
        "CLICKHOUSE_USER": "${CLICKHOUSE_USER}",
        "CLICKHOUSE_PASSWORD": "${CLICKHOUSE_PASSWORD}",
        "CLICKHOUSE_SECURE": "${CLICKHOUSE_SECURE}"
      }
    }
  }
}
```

### Claude Code — `CLI or .mcp.json`

Run from your repo. Commit .mcp.json to share with your team.

```shell
# export CLICKHOUSE_HOST=myhost.clickhouse.cloud
# export CLICKHOUSE_PORT=8443
# export CLICKHOUSE_USER=reader
# export CLICKHOUSE_PASSWORD=changeme
# export CLICKHOUSE_SECURE=true
claude mcp add clickhouse -- uvx mcp-clickhouse
```

### Cursor — `.cursor/mcp.json`

Global path: ~/.cursor/mcp.json. Reload window after editing.

```json
{
  "mcpServers": {
    "clickhouse": {
      "command": "uvx",
      "args": [
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "${CLICKHOUSE_HOST}",
        "CLICKHOUSE_PORT": "${CLICKHOUSE_PORT}",
        "CLICKHOUSE_USER": "${CLICKHOUSE_USER}",
        "CLICKHOUSE_PASSWORD": "${CLICKHOUSE_PASSWORD}",
        "CLICKHOUSE_SECURE": "${CLICKHOUSE_SECURE}"
      }
    }
  }
}
```

### VS Code — `.vscode/mcp.json`

VS Code uses the "servers" key (not "mcpServers").

```jsonc
{
  "servers": {
    "clickhouse": {
      "command": "uvx",
      "args": [
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "${CLICKHOUSE_HOST}",
        "CLICKHOUSE_PORT": "${CLICKHOUSE_PORT}",
        "CLICKHOUSE_USER": "${CLICKHOUSE_USER}",
        "CLICKHOUSE_PASSWORD": "${CLICKHOUSE_PASSWORD}",
        "CLICKHOUSE_SECURE": "${CLICKHOUSE_SECURE}"
      }
    }
  }
}
```

### Windsurf — `~/.codeium/windsurf/mcp_config.json`

Open via Cascade → hammer icon → Configure.

```json
{
  "mcpServers": {
    "clickhouse": {
      "command": "uvx",
      "args": [
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "${CLICKHOUSE_HOST}",
        "CLICKHOUSE_PORT": "${CLICKHOUSE_PORT}",
        "CLICKHOUSE_USER": "${CLICKHOUSE_USER}",
        "CLICKHOUSE_PASSWORD": "${CLICKHOUSE_PASSWORD}",
        "CLICKHOUSE_SECURE": "${CLICKHOUSE_SECURE}"
      }
    }
  }
}
```

### Cline — `cline_mcp_settings.json`

Open via the Cline sidebar → MCP Servers → Edit.

```json
{
  "mcpServers": {
    "clickhouse": {
      "command": "uvx",
      "args": [
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "${CLICKHOUSE_HOST}",
        "CLICKHOUSE_PORT": "${CLICKHOUSE_PORT}",
        "CLICKHOUSE_USER": "${CLICKHOUSE_USER}",
        "CLICKHOUSE_PASSWORD": "${CLICKHOUSE_PASSWORD}",
        "CLICKHOUSE_SECURE": "${CLICKHOUSE_SECURE}"
      }
    }
  }
}
```

### Continue — `~/.continue/config.json`

Continue uses modelContextProtocolServers with a transport block.

```json
{
  "experimental": {
    "modelContextProtocolServers": [
      {
        "transport": {
          "type": "stdio",
          "command": "uvx",
          "args": [
            "mcp-clickhouse"
          ],
          "env": {
            "CLICKHOUSE_HOST": "${CLICKHOUSE_HOST}",
            "CLICKHOUSE_PORT": "${CLICKHOUSE_PORT}",
            "CLICKHOUSE_USER": "${CLICKHOUSE_USER}",
            "CLICKHOUSE_PASSWORD": "${CLICKHOUSE_PASSWORD}",
            "CLICKHOUSE_SECURE": "${CLICKHOUSE_SECURE}"
          }
        }
      }
    ]
  }
}
```

### Codex CLI — `~/.codex/config.toml`

Codex uses TOML. Each server is a [mcp_servers.<name>] subtable.

```shell
# ~/.codex/config.toml
[mcp_servers.clickhouse]
command = "uvx"
args = [
  "mcp-clickhouse",
]
env = { CLICKHOUSE_HOST = "${CLICKHOUSE_HOST}", CLICKHOUSE_PORT = "${CLICKHOUSE_PORT}", CLICKHOUSE_USER = "${CLICKHOUSE_USER}", CLICKHOUSE_PASSWORD = "${CLICKHOUSE_PASSWORD}", CLICKHOUSE_SECURE = "${CLICKHOUSE_SECURE}" }
```

### Zed — `~/.config/zed/settings.json`

Zed calls them "context_servers". Settings live-reload on save.

```jsonc
{
  "context_servers": {
    "clickhouse": {
      "command": {
        "path": "uvx",
        "args": [
          "mcp-clickhouse"
        ]
      },
      "env": {
        "CLICKHOUSE_HOST": "${CLICKHOUSE_HOST}",
        "CLICKHOUSE_PORT": "${CLICKHOUSE_PORT}",
        "CLICKHOUSE_USER": "${CLICKHOUSE_USER}",
        "CLICKHOUSE_PASSWORD": "${CLICKHOUSE_PASSWORD}",
        "CLICKHOUSE_SECURE": "${CLICKHOUSE_SECURE}"
      }
    }
  }
}
```

### ChatGPT — `ChatGPT → Apps directory`

ClickHouse doesn't ship a hosted HTTPS endpoint today. ChatGPT supports remote MCP servers only — to use this server in ChatGPT you'll need to deploy it to a public HTTPS URL first (e.g. via Cloudflare Workers or Vercel) or wait for an official remote build.

```none

```

## At a glance

- **Maintainer:** ClickHouse
- **Transport:** stdio
- **Auth model:** API key
- **Required secrets:** CLICKHOUSE_HOST, CLICKHOUSE_PORT, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, CLICKHOUSE_SECURE
- **Supported clients:** Claude, Cursor, VS Code, Windsurf, Any MCP-compatible client, ClickHouse 22+, ClickHouse Cloud
- **License:** Apache-2.0
- **Language:** Python
- **Latest version:** latest
- **Last verified:** 2026-06-02
- **GitHub stars:** 794 (fetched 2026-06-02T13:16:41.160Z)
- **Score:** 85/100 (rubric 2026-04 — see https://top-mcps.com/about/methodology)
- **Source:** https://github.com/ClickHouse/mcp-clickhouse

## Tools & permissions

| Tool | Description | Args | Side effects |
|------|-------------|------|--------------|
| `list_databases` | List databases on the cluster. | `—` | read |
| `list_tables` | List tables in a database, including materialized views. | `database: string` | read |
| `describe_table` | Return columns, types, and partition keys for a table. | `table: string` | read |
| `list_dictionaries` | List ClickHouse dictionaries. | `—` | read |
| `query` | Run a SELECT statement and return rows. Read-only. | `sql: string` | read |

## Security & scope

- **Access scope:** read-only
- **Sandbox:** Connects to a ClickHouse cluster with a username/password (Cloud) or native auth (self-hosted). Read-only at the MCP tool layer; pair with a SELECT-only role on the cluster for defence in depth.
- **Gotchas:**
  - Read-only is MCP-side, not GRANT-side. Always create a dedicated reader role on the cluster.
  - ClickHouse Cloud bills per query — the MCP does not gate runaway aggregations. Set max_execution_time on the user profile.
  - CLICKHOUSE_SECURE=true is required for Cloud endpoints; the default port 8443 is TLS-only.

## Quick answer

**What it does.** Connects to a ClickHouse cluster and exposes database/table enumeration, schema inspection, and analytical SELECT execution to AI models. Read-only by default.

**Best for:**
- Product analytics queries
- Observability log search
- Time-series rollups
- Schema audits across wide tables
- Funnel and retention SQL

**Not for:**
- OLTP workflows
- Sub-gigabyte local files (use DuckDB)
- Write-heavy ingestion from an LLM

## Description

The official ClickHouse MCP connects an AI agent to a ClickHouse cluster — self-hosted or ClickHouse Cloud — and exposes schema inspection, dictionary listing, and SELECT execution. Designed for analytical workloads where Postgres is the wrong shape and DuckDB is too local. The server ships read-only by default and honours role-level grants on the connecting user.

## Why it matters

ClickHouse is the default columnar warehouse for product analytics, observability, and time-series workloads. An MCP turns "open the tabix console" into a conversational query against the same cluster engineers already use.

## Key features

- Official ClickHouse maintainership
- Read-only by default
- ClickHouse Cloud + self-hosted
- Dictionary and materialized-view introspection
- Query log inspection for cost auditing

## FAQ

### ClickHouse Cloud or self-hosted?

Both. The MCP uses the standard ClickHouse client libraries — point CLICKHOUSE_HOST at a Cloud endpoint with CLICKHOUSE_SECURE=true, or at an internal hostname for self-hosted clusters.

### Does it expose writes?

No write tools are exposed by default. Treat the read-only flag as advisory and grant the connecting ClickHouse user GRANT SELECT only as defence in depth.

### How does it handle large result sets?

Rows are capped at a configurable LIMIT — 1000 rows by default. For aggregation queries this is rarely a constraint; for raw exploration, narrow the WHERE before raising the cap.

### Does it support materialized views?

Yes — they appear in the table list with their MATERIALIZED flag, and the agent can query them like any other table. Dictionaries are exposed via a dedicated list_dictionaries tool.

## Changelog

- **2026-06-02** — Refreshed install snippets and fact sheet; verified for 2026.
- **2025-02-20** — Initial directory listing.
