By viderstar
Query ClickHouse from an agent without inflated numbers or full-history scans.
npx claudepluginhub viderstar/clickhouse-kitClickHouse for agents: an MCP connection driven entirely by environment variables, a query-hygiene skill (deduplication, partition pruning, column pruning, join order), a pre-flight guard hook against inflated counts and full-history scans, and a personal-data warning on results.
ClickHouse for coding agents: a connection you configure once, a skill that keeps the numbers honest, and two hooks that catch the expensive mistakes before they run.
A Claude Code plugin.
Two failure modes show up again and again when an agent queries ClickHouse:
ReplacingMergeTree;
old row versions sit next to new ones until a merge happens, so a plain count()
over-reports. Nothing errors. The figure just ends up in a report.SELECT * on a columnar store, and you are reading hundreds of gigabytes on a
production node.Prose in a prompt catches these sometimes. A hook catches them every time.
ch-query skill — deduplication, partition pruning with PREWHERE, column pruning,
join order, EXPLAIN ESTIMATE, and how to explore an unfamiliar schema before writing
anything.ch-guard hook (PreToolUse) — stops to ask when a query aggregates without FINAL
or argMax, hits a table you marked as heavy with no date filter, does SELECT *
without a LIMIT, or reads a backup-shaped table name. Always ask, never deny; a
deliberate query skips it with a -- ch-guard: ok <why> first line, and the bypass is
logged.pii_guard hook (PostToolUse) — notes when a result looks like personal data, so
the rows do not get copy-pasted into a ticket or a wiki page.claude plugin marketplace add ViderStar/clickhouse-kit
claude plugin install clickhouse-kit@clickhouse-kit
Connection. Put the values in the env block of ~/.claude/settings.json (or export
them in your shell). Nothing ClickHouse-specific is hard-coded in the plugin:
{
"env": {
"CLICKHOUSE_HOST": "clickhouse.example.com",
"CLICKHOUSE_PORT": "8443",
"CLICKHOUSE_USER": "readonly",
"CLICKHOUSE_PASSWORD": "...",
"CLICKHOUSE_SECURE": "true"
}
}
Use a read-only user with row and memory limits. The plugin does not need more, and an
agent that cannot DROP is one less thing to think about.
For several servers, copy the block in .mcp.json under a different key with a different
set of variable names.
The heavy-table list is what makes ch-guard genuinely useful — it cannot know which
of your tables is a monster. Find them:
SELECT database || '.' || name AS t, engine,
formatReadableSize(total_bytes) AS size,
formatReadableQuantity(total_rows) AS rows
FROM system.tables
WHERE database NOT IN ('system', 'information_schema', 'INFORMATION_SCHEMA')
ORDER BY total_bytes DESC LIMIT 20
and write them into ~/.config/clickhouse-kit/heavy_tables.json (template:
hooks/heavy_tables.json):
{
"tables": { "shop.prices_by_day": "26 billion rows, 159 GiB" },
"date_columns": ["date", "event_date", "date_time"],
"checks": ["dedup", "heavy", "select_star", "backup"]
}
Any check you disagree with can be dropped from checks.
Personal data (optional): ~/.config/clickhouse-kit/pii.json takes
internal_domains (staff e-mail domains, so they stop being flagged), column_names and
extra_patterns (regexes for national ID formats).
python3 hooks/ch_guard.py --selftest
printf '%s' '{"tool_input":{"query":"select count() from shop.orders"}}' | python3 hooks/ch_guard.py
The hooks are plain stdin-JSON → stdout-JSON filters with no dependencies, so they work
outside Claude Code too — for instance in a pre-commit check over .sql files.
The hooks match any MCP tool whose name ends in run_query, run_select_query or
query, so they apply whatever you called your ClickHouse MCP server — including a
self-hosted HTTP one instead of the bundled stdio config.
MIT.
7-day visitors to each marketplace page
UI/UX design intelligence skill with 80 styles, 194 palettes, 74 font pairings, 25 charts, and 22 stack guidelines
RuFlo Marketplace: Claude Code native agents, swarms, workers, and MCP tools for continuous software engineering
Editorial diagrams in your brand, as self-contained HTML and SVG. Architecture, flowcharts, sequence, state machines, ER and database schemas, timelines, swimlanes, org charts, Gantt, Wardley maps, user journeys, service blueprints, UML class, lifecycle phase maps, and charts from bar, line and scatter to Sankey, treemap and heatmap, plus many more. Redraws draw.io, Mermaid, Excalidraw and PlantUML files. Exports SVG and PNG.