npm @dockndevai/mcp-clickhousestdioMITupdated 9d ago
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.
mcp clickhouse 能做什么?
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).
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
安装
把 mcp clickhouse 添加到你的客户端。选择你正在使用的那个。
claude mcp add mcp-clickhouse -- npx -y @dockndevai/mcp-clickhousecodex mcp add mcp-clickhouse -- npx -y @dockndevai/mcp-clickhouseamp mcp add mcp-clickhouse -- npx -y @dockndevai/mcp-clickhouse{
"mcpServers": {
"mcp-clickhouse": {
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-clickhouse"
]
}
}
}Add to `claude_desktop_config.json`, then restart Claude Desktop.
{
"mcpServers": {
"mcp-clickhouse": {
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-clickhouse"
]
}
}
}Add to `~/.cursor/mcp.json`, or `.cursor/mcp.json` for a single project.
code --add-mcp '{"name":"mcp-clickhouse","command":"npx","args":["-y","@dockndevai/mcp-clickhouse"]}'Or add the block manually to `.vscode/mcp.json` under `servers`.
{
"mcpServers": {
"mcp-clickhouse": {
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-clickhouse"
]
}
}
}Add to `~/.codeium/windsurf/mcp_config.json`.
{
"mcpServers": {
"mcp-clickhouse": {
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-clickhouse"
]
}
}
}Add to `cline_mcp_settings.json` via the MCP Servers panel.
{
"mcpServers": {
"mcp-clickhouse": {
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-clickhouse"
]
}
}
}Add to `~/.gemini/settings.json`.
{
"mcpServers": {
"mcp-clickhouse": {
"type": "local",
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-clickhouse"
],
"tools": [
"*"
]
}
}
}Add to `~/.copilot/mcp-config.json`, or run `/mcp add` inside the CLI.
{
"context_servers": {
"mcp-clickhouse": {
"command": {
"path": "npx",
"args": [
"-y",
"@dockndevai/mcp-clickhouse"
]
}
}
}
}Add to your Zed `settings.json`.
npx -y @dockndevai/mcp-clickhouseRun `goose configure`, choose **Add Extension → Command-line Extension**, and paste this command.
评分
39 / 100
不完整
- 文档25/25
- 维护25/25
- 可信度13/20
- 能力0/15
- 安装体验12/15
- Documents what it does and how to connect
- Has a resolvable package or endpoint
- Exposes at least one tool, prompt or resource
- README has substantive content
- Includes a code example
- Documents its configuration
- Mentions credentials or security posture
- Last commit 2 days ago
- Has a release history
- Repository is not archived
- Licensed MIT
- Namespace verified in the official MCP registry
- Claimed by its owner
- Published under an organisation
- 0 tool(s) documented
- Provides prompt templates
- Provides resources
- 12 documented install method(s)
- Published to a package registry
- Offers a hosted endpoint — no local install
版本历史
| 版本 | 发布于 |
|---|---|
| 0.1.2最新 | 2026年8月30日 |
| 0.1.1 | 2026年8月28日 |
| 0.1.0 | 2026年8月23日 |