Back to Browse

Clickhouse MCP Server

Data & AnalyticsModerate5.2MCP RegistryLocal
Free

Server data from the Official MCP Registry

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

About

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

Security Report

5.2
Moderate5.2Moderate Risk

This is a well-designed MCP server with a sophisticated statement-aware security model. SQL classification is fail-safe (defaulting to the most restrictive category when unsure), access modes are layered correctly, and all database operations are gated by policy. Code quality is high with proper input validation, comprehensive audit logging, and defense-in-depth (server-side readonly enforcement + client-side policy checks). Minor observations: the regex-based SQL parsing could be brittle for complex queries, and the best-effort protected database detection via regex may miss some edge cases, but these are unlikely to be exploitable in practice. Supply chain analysis found 3 known vulnerabilities in dependencies (0 critical, 3 high severity). Package verification found 1 issue.

7 files analyzed · 7 issues found

Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.

Permissions Required

This plugin requests these system permissions. Most are normal for its category.

HTTP Network Access

Connects to external APIs or services over the internet.

env_vars

Check that this permission is expected for this type of plugin.

What You'll Need

Set these up before or after installing:

ClickHouse HTTP endpoint.Optional

Environment variable: CLICKHOUSE_URL

ClickHouse user (prefer a read-only user).Optional

Environment variable: CLICKHOUSE_USER

ClickHouse password.Required

Environment variable: CLICKHOUSE_PASSWORD

Access mode: read-only | read-write | admin.Optional

Environment variable: CLICKHOUSE_MODE

How to Install

Add this to your MCP configuration file:

{
  "mcpServers": {
    "io-github-dockndevai-mcp-clickhouse": {
      "env": {
        "CLICKHOUSE_URL": "your-clickhouse-url-here",
        "CLICKHOUSE_MODE": "your-clickhouse-mode-here",
        "CLICKHOUSE_USER": "your-clickhouse-user-here",
        "CLICKHOUSE_PASSWORD": "your-clickhouse-password-here"
      },
      "args": [
        "-y",
        "@dockndevai/mcp-clickhouse"
      ],
      "command": "npx"
    }
  }
}

Documentation

View on GitHub

From the project's GitHub 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 modesread-onlyread-writeadmin, 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.

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

Reviews

No reviews yet

Be the first to review this server!