dockndevai/mcp-clickhouse
FreeMaintainedClickHouse schema exploration, analytical queries & management — every statement classified read/write/destructive and gated by access mode, with row caps and a
About
ClickHouse schema exploration, analytical queries & management — every statement classified read/write/destructive and gated by access mode, with row caps and audit. npx -y @dockndevai/mcp-clickhouse
README
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).
Security model
| Concern | Flag | Default | Effect |
|---|---|---|---|
| What can the server do? | CLICKHOUSE_MODE |
read-only |
read-only exposes read tools only (and refuses non-SELECT in query); read-write adds execute for writes; admin allows destructive statements. |
| Which databases are in scope? | CLICKHOUSE_DATABASE_ALLOWLIST |
(all) | When set, operations on other databases are refused. |
| Which databases are read-only forever? | CLICKHOUSE_PROTECTED_DATABASES |
system,information_schema |
Readable, never mutable. |
| Can it run destructive SQL? | CLICKHOUSE_ALLOW_DELETE |
false |
DROP/TRUNCATE/DELETE/… need this and admin mode. |
| Result size cap | CLICKHOUSE_MAX_ROWS |
1000 |
Hard cap on rows returned to the model. |
| Preview without executing | CLICKHOUSE_DRY_RUN |
false |
Write/destructive statements validate + log intent, then return. |
| Audit trail | CLICKHOUSE_AUDIT_LOG |
true |
Emits a JSON line to stderr per guarded operation. |
Statement classification lives in src/sql.ts and is fail-safe: ALTER … DELETE/UPDATE counts 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-clickhouse
Claude 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 set
Develop
npm run dev
npm test # SQL classification + security policy (30 tests)
npm run typecheck
Publishing
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
Installing dockndevai/mcp-clickhouse
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/dockndevai/mcp-clickhouseFAQ
Is dockndevai/mcp-clickhouse MCP free?
Yes, dockndevai/mcp-clickhouse MCP is free — one-click install via Unyly at no cost.
Does dockndevai/mcp-clickhouse need an API key?
Yes, it requires environment variables: CLICKHOUSE_MODE, CLICKHOUSE_URL, CLICKHOUSE_USER. Unyly injects them into the config during install.
Is dockndevai/mcp-clickhouse hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install dockndevai/mcp-clickhouse in Claude Desktop, Claude Code or Cursor?
Open dockndevai/mcp-clickhouse on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
wenb1n-dev/SmartDB_MCP
A universal database MCP server supporting simultaneous connections to multiple databases. It provides tools for database operations, health analysis, SQL optim
by wenb1n-devPostgres Server
This server enables interaction with PostgreSQL databases through the Model Context Protocol, optimized for the AWS Bedrock AgentCore Runtime. It provides tools
by madhurprashPostgres
Query your database in natural language
by AnthropicPostgreSQL
Read-only database access with schema inspection.
by modelcontextprotocolRedis
Interact with Redis key-value stores.
by modelcontextprotocolSQLite
Database interaction and business intelligence capabilities.
by modelcontextprotocolmxcp
Open-source framework for building enterprise-grade MCP servers using just YAML, SQL, and Python, with built-in auth, monitoring, ETL and policy enforcement.
by raw-labstadas-github/a2asearch-mcp
MCP server to search 4,800+ MCP servers, AI agents, CLI tools and agent skills. Install: npx -y a2asearch-mcp. Ask Claude: "Find MCP servers for database access
by tadas-githubjulien040/anyquery
Query more than 40 apps with one binary using SQL. It can also connect to your PostgreSQL, MySQL, or SQLite compatible database. Local-first and private by desi
by julien040drakonkat/wizzy-mcp-tmdb
A MCP server for The Movie Database API that enables AI assistants to search and retrieve movie, TV show, and person information.
by drakonkatCompare dockndevai/mcp-clickhouse with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All data MCPs
