GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dockndevai/mcp-clickhouse: MCP server for ClickHouse — explore, query, and manage with SQL-classification-based security modes and access-control flags.

BranchesTags
Open more actions menu

Latest commit

 

History

33 Commits
33 Commits

Folders and files

NameName
Last commit message
Last commit date
.claude/skills/mcp-suite-maintenance
.claude/skills/mcp-suite-maintenance
 
 
.github
.github
 
 
docs
docs
 
 
src
src
 
 
test
test
 
 
.dockerignore
.dockerignore
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
PUBLISHING.md
PUBLISHING.md
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
glama.json
glama.json
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
server.json
server.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

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

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, a statement that touches any other database is refused: the databases are read off the SQL itself (qualified names, USE, joins, subqueries, INSERT … SELECT, RENAME, …) and unqualified names count as the connection's default database (CLICKHOUSE_DATABASE). A statement the server cannot analyse is refused. Best-effort — back it with ClickHouse grants.
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/RENAME/EXCHANGE/data-losing ALTER (DROP PARTITION/COLUMN/INDEX, DETACH/CLEAR/REPLACE PARTITION, RENAME COLUMN, MOVE … TO TABLE, MODIFY TTL, type-changing MODIFY COLUMN, mutations), CREATE OR REPLACE, `OPTIMIZE … DEDUPLICATE
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.
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 DROP / TRUNCATE / DELETE / RENAME / EXCHANGE / ALTER / CREATE OR REPLACE / OPTIMIZE on a table, view, dictionary or database named in the statement, that object's version is pinned across the prompt and the statement is refused if it changed; DROP TABLE / DROP DATABASE also ask the human to type the name; a prompt nobody answers is a refusal.
Require a human CLICKHOUSE_REQUIRE_HUMAN_APPROVAL false When true, destructive statements are refused if the client cannot elicit (instead of falling back to the CLICKHOUSE_ALLOW_DELETE gate alone).

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

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

About

MCP server for ClickHouse — explore, query, and manage with SQL-classification-based security modes and access-control flags.

dockndevai.github.io/

Topics

clickhousellmmcpmodel-context-protocololapsql

Resources

Readme
MIT license

Code of conduct

Code of conduct

Security policy

Security policy
Activity

Stars

3 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.