mcp-clickhouse
mcp-clickhouse is an MCP server for exploring, querying, and monitoring ClickHouse with statement-aware access controls.
List databases and tables, describe columns, show CREATE statements, and get table part/row/size stats.
Run read-only SELECT/SHOW/DESCRIBE queries, capped by
CLICKHOUSE_MAX_ROWS.Monitor running queries, server metrics, and cluster topology.
The provided schema exposes read-only tools; the README also documents an
executetool for write/admin operations such as INSERT/CREATE/ALTER and gated destructive statements.Enforce security controls: access modes, database allowlists, protected databases, destructive gating, dry-run, audit logging, and human approval.
Provides tools for exploring ClickHouse schemas, running analytical read queries, and managing the database with configurable access modes and security restrictions.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-clickhouse What are the biggest tables in the analytics database?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-clickhouse
A Model Context Protocol server for ClickHouse. It lets an MCP-capable client (Claude Desktop, Claude Code, etc.) explore schemas, run analytical queries, and manage the database — with behaviour controlled entirely by flags.
The security model is statement-aware: every SQL statement is classified as read, write, or destructive, and gated against the current access mode. Read-only mode additionally runs queries under ClickHouse's own readonly=1 setting.
Features
Exploration & monitoring — databases, tables, columns,
SHOW CREATE, table stats (parts/rows/bytes), running queries, server metrics, cluster topology.Read queries — a
querytool that only accepts read statements, capped atCLICKHOUSE_MAX_ROWS.Management — an
executetool for INSERT/CREATE/ALTER (read-write) and DROP/TRUNCATE/DELETE (admin), each gated by classification.Access modes —
read-only→read-write→admin, layered so a mode never exposes statements above its level.Security flags — database allowlist, protected databases, destructive gating, row cap, dry-run, and JSON audit logging (see below).
Related MCP server: clickhouse-mcp-server
Security model
Concern | Flag | Default | Effect |
What can the server do? |
|
|
|
Which databases are in scope? |
| (all) | When set, a statement that touches any other database is refused: the databases are read off the SQL itself (qualified names, |
Which databases are read-only forever? |
|
| Readable, never mutable. |
Can it run destructive SQL? |
|
| DROP/TRUNCATE/DELETE/ |
Result size cap |
|
| Hard cap on rows returned to the model. |
Preview without executing |
|
| Write/destructive statements validate + log intent, then return. |
Audit trail |
|
| Emits a JSON line to stderr per guarded operation. |
Interactive confirmation | (automatic) | — | Destructive statements prompt the human to approve via MCP elicitation before running. The prompt shows the tool, the exact arguments (the full SQL) and a fingerprint; for |
Require a human |
|
| When |
Statement classification lives in src/sql.ts and is fail-safe: ALTER … DELETE/UPDATE and the data-losing ALTER commands, CREATE OR REPLACE and OPTIMIZE … DEDUPLICATE|CLEANUP count as destructive, and anything unparseable is treated as destructive.
Tools
Read (read-only+): list_databases, list_tables, describe_table, show_create_table, table_stats, running_queries, server_metrics, cluster_info, query
Write/Admin (read-write+): execute — runs a single statement after classifying it; writes need read-write mode, destructive statements need admin mode + CLICKHOUSE_ALLOW_DELETE.
Quickstart — add to your agent
Published on npm as @dockndevai/mcp-clickhouse. No clone or build needed — your MCP client runs it on demand with npx. Start in read-only mode; see .env.example for every variable and docs/CLIENTS.md for the full per-client guide.
Claude Code (CLI)
claude mcp add clickhouse -e CLICKHOUSE_URL="http://localhost:8123" -e CLICKHOUSE_USER="default" -e CLICKHOUSE_MODE="read-only" -- npx -y @dockndevai/mcp-clickhouseClaude Desktop · Cursor · Windsurf — same block in claude_desktop_config.json, .cursor/mcp.json, or ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"clickhouse": {
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-clickhouse"
],
"env": {
"CLICKHOUSE_URL": "http://localhost:8123",
"CLICKHOUSE_USER": "default",
"CLICKHOUSE_MODE": "read-only"
}
}
}
}OpenAI Codex CLI — in ~/.codex/config.toml:
[mcp_servers.clickhouse]
command = "npx"
args = ["-y", "@dockndevai/mcp-clickhouse"]
env = { CLICKHOUSE_URL = "http://localhost:8123", CLICKHOUSE_USER = "default", CLICKHOUSE_MODE = "read-only" }VS Code (GitHub Copilot, Agent mode) — in .vscode/mcp.json:
{
"servers": {
"clickhouse": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-clickhouse"
],
"env": {
"CLICKHOUSE_URL": "http://localhost:8123",
"CLICKHOUSE_USER": "default",
"CLICKHOUSE_MODE": "read-only"
}
}
}
}Example prompts
"What are the biggest tables in the
analyticsdatabase?""Show me the schema for
eventsand run a query for daily counts this week.""Which queries are currently running and using the most memory?"
Run from source (development)
Prefer the published package above. To run from a clone:
npm install
npm run build
node dist/index.js # with the environment variables setDevelop
npm run dev
npm test # SQL classification + security policy (30 tests)
npm run typecheckPublishing
This server ships a server.json for the official MCP registry and an mcpName for npm ownership validation. See PUBLISHING.md for publishing to npm and listing on the MCP registry, Smithery, Glama, Cursor, and PulseMCP.
License
MIT
Available Tools
9 toolscluster_infoCluster infoARead-onlyIdempotent
Cluster topology from system.clusters (shards, replicas, hosts).
Inputs: no named parameters.
describe_tableDescribe tableARead-onlyIdempotent
Column names, types, defaults, and comments for a table.
Inputs: table (required), database (required).
list_databasesList databasesARead-onlyIdempotent
List databases and their engines.
Inputs: no named parameters.
list_tablesList tablesBRead-onlyIdempotent
List tables in a database with engine, row count, and size.
Inputs: database (required).
queryRun a read-only queryARead-onlyIdempotent
Run a SELECT/SHOW/DESCRIBE query and return rows. Non-read statements are refused here — use execute (read-write mode) for those. Results are capped at CLICKHOUSE_MAX_ROWS.
Inputs: sql (required).
running_queriesRunning queriesARead-onlyIdempotent
Currently executing queries from system.processes (id, user, elapsed, memory).
Inputs: no named parameters.
server_metricsServer metricsARead-onlyIdempotent
Non-zero metrics from system.metrics (connections, merges, memory, etc.).
Inputs: no named parameters.
show_create_tableShow CREATE TABLEBRead-onlyIdempotent
Return the full CREATE TABLE statement (schema, engine, settings) for a table.
Inputs: table (required), database (required).
table_statsTable statsBRead-onlyIdempotent
Part count, row count, on-disk size, and time range from system.parts.
Inputs: table (required), database (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool targets a fairly distinct area: table listing, column metadata, DDL, stats, and system introspection. The main overlap is that `query` can also run SHOW/DESCRIBE and thus partially duplicates `describe_table`, `show_create_table`, `list_databases`, and `list_tables`, though dedicated tools provide clearer structured output.
All names are snake_case, but the conventions are mixed: verb_noun forms (`list_tables`, `describe_table`, `show_create_table`), noun phrases (`table_stats`, `cluster_info`, `running_queries`, `server_metrics`), and a lone verb (`query`). Readable but not a predictable pattern.
Nine tools is well-scoped for a ClickHouse introspection and query server. Each tool has a clear place, and there is no obvious bloat or missing category within the read-oriented surface.
Read-side coverage is solid (databases, tables, schema, stats, queries, cluster, metrics). However, the `query` description explicitly says non-read statements must use an `execute` tool, which is absent, leaving writes/DDL as a dead end and creating an inconsistent tool surface.
Maintenance
Related MCP Connectors
Governed access to production AI-agent traces in an existing ClickHouse store.
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Hosted BigQuery MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server implementation that enables Claude AI to interact with Clickhouse databases. Features include secure database connections, query execution, read-only mode support, and multi-query capabilities.223 PyPI2MIT
- AlicenseNot gradedqualityDmaintenanceEnables interaction with ClickHouse databases via MCP, providing tools to list databases and tables and execute safe SELECT, SHOW, and DESCRIBE queries.78 npmMIT
- FlicenseAqualityDmaintenanceRead-only MCP server for ClickHouse that allows listing databases and tables, describing schemas, and running SELECT queries.4-
- FlicenseNot gradedqualityDmaintenanceMCP server for executing SQL queries on PostgreSQL and ClickHouse with per-connection allow/deny policies by statement group.-