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 分