Mcp Clickhouse

io.github.dockndevai由 GitHub 帳號 dockndevai 發布v0.3.0更新於 Oct 24, 2026

ClickHouse query & management for AI agents — SQL-classified read/write/destructive gating.

已驗證STDIO僅桌面資料庫資料與分析

概覽

AI 產生的概覽

針對 ClickHouse 的本機 MCP 伺服器,讓助理瀏覽資料庫與資料表結構、執行唯讀查詢,並在開啟對應模式後寫入或管理資料庫,語句依讀取、寫入、破壞性分級攔阻。

可以做什麼
瀏覽資料庫、資料表、欄位、資料表統計、執行中的查詢、伺服器指標與叢集拓撲,並檢視建表語句。執行唯讀 SQL 查詢,回傳列數受可設定上限限制。在讀寫模式下執行單一 INSERT、CREATE 或 ALTER 語句。僅在管理員模式並額外開啟刪除許可時執行 DROP、TRUNCATE、DELETE 等破壞性語句。可用試執行預覽寫入與破壞性語句,並將受控操作以 JSON 稽核列記錄。
適用情境
適合讓助理檢視或查詢 ClickHouse 分析資料庫、回答資料表結構與大小等問題,或檢查執行中的查詢與伺服器指標。也適合需要分級權限與破壞性語句攔阻的受控資料庫管理情境。
執行需求
透過 npx 從 npm 套件在本機執行,需要 Node.js。需要 ClickHouse HTTP 位址、使用者與密碼,分別以 CLICKHOUSE_URL、CLICKHOUSE_USER、CLICKHOUSE_PASSWORD 設定,並設定 CLICKHOUSE_MODE(預設唯讀)。選用設定包括資料庫允許清單、受保護資料庫、刪除許可、列數上限、試執行與稽核記錄。
安裝前請注意
此伺服器可以寫入資料,並在管理員模式且開啟刪除許可時刪除或清空資料,建議從唯讀模式開始並使用唯讀的 ClickHouse 使用者。它需要保存 CLICKHOUSE_PASSWORD 中的資料庫密碼。破壞性操作僅在支援 elicitation 的用戶端要求人工確認,其他用戶端則回退到許可開關。稽核列寫入標準錯誤輸出。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Mcp Clickhouse,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

mcp-clickhouse

[CI] [License: MIT] [npm]

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 query tool that only accepts read statements, capped at CLICKHOUSE_MAX_ROWS.
  • Management — an execute tool 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

ConcernFlagDefaultEffect
What can the server do?CLICKHOUSE_MODEread-onlyread-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_DATABASESsystem,information_schemaReadable, never mutable.
Can it run destructive SQL?CLICKHOUSE_ALLOW_DELETEfalseDROP/TRUNCATE/DELETE/… need this and admin mode.
Result size capCLICKHOUSE_MAX_ROWS1000Hard cap on rows returned to the model.
Preview without executingCLICKHOUSE_DRY_RUNfalseWrite/destructive statements validate + log intent, then return.
Audit trailCLICKHOUSE_AUDIT_LOGtrueEmits a JSON line to stderr per guarded operation.
Interactive confirmation(automatic)—Destructive & high-impact actions prompt the human to approve via MCP elicitation before running; clients without elicitation fall back to the *_ALLOW_* gate.

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)

bash
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:

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:

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:

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 analytics database?"
  • "Show me the schema for events and 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:

bash
npm installnpm run buildnode dist/index.js   # with the environment variables set

Develop

bash
npm run devnpm 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

來源:README.md,提交 6940892

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

2
  1. v0.3.0最新Sep 29, 2026
  2. v0.2.2Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分