Skip to main content
Glama
dockndevai

mcp-clickhouse

by dockndevai

mcp-clickhouse

CI License: MIT

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

Related MCP server: clickhouse-mcp-server

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.

Use with your MCP client

Works with Claude Code, Claude Desktop, Cursor, OpenAI Codex CLI, Windsurf, VS Code (Copilot), and any other MCP client — see docs/CLIENTS.md for per-client setup.

Install

npm install
npm run build

Run with Claude Desktop / Claude Code

{
  "mcpServers": {
    "clickhouse": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-clickhouse/dist/index.js"],
      "env": {
        "CLICKHOUSE_URL": "http://clickhouse:8123",
        "CLICKHOUSE_USER": "readonly",
        "CLICKHOUSE_PASSWORD": "…",
        "CLICKHOUSE_MODE": "read-only",
        "CLICKHOUSE_DATABASE_ALLOWLIST": "analytics"
      }
    }
  }
}

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

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

Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    B
    quality
    F
    maintenance
    An MCP server implementation that enables Claude AI to interact with Clickhouse databases. Features include secure database connections, query execution, read-only mode support, and multi-query capabilities.
    2
    2
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables interaction with ClickHouse databases via MCP, providing tools to list databases and tables and execute safe SELECT, SHOW, and DESCRIBE queries.
    32
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    MCP server for executing SQL queries on PostgreSQL and ClickHouse with per-connection allow/deny policies by statement group.

View all related MCP servers

Related MCP Connectors

  • Read-only MCP access to sessions, funnels, campaigns, errors, live visitors, and anomalies.

  • MCP server for managing Prisma Postgres.

  • Read-only Yandex Metrika MCP. Query visits, sources, geo, devices and more in plain language.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dockndevai/mcp-clickhouse'

If you have feedback or need assistance with the MCP directory API, please join our Discord server