Base for any clickhouse analysis by any of altinity-expert-clickhouse skills. Use it before running any other diagnostics.
Run this before any other altinity-expert-clickhouse-* skill. It produces the facts every later skill reuses: connection mode, cluster name (or single node), ClickHouse version, Keeper presence, time window.
Check your available tools in this order and stop at the first match:
clickhouse and one of query, execute, sql (for example clickhouse_execute_query, mcp__clickhouse__execute_query). Send exactly one SQL statement per call. If several ClickHouse MCP servers exist, ask the user which one to use.clickhouse-client (or clickhouse client). Use only the connection flags the user provided (--host, --port, --user, --password, --secure); do not guess credentials from environment variables. Run one statement per invocation with --query "<statement>". Never use --queries-file or --multiquery.Run this one statement. It works on a standalone server (no macro, no Keeper) and on a cluster:
SELECT
hostName() AS hostname,
version() AS version,
(SELECT substitution FROM system.macros WHERE macro = 'cluster') AS cluster_macro,
(SELECT groupUniqArray(cluster) FROM system.clusters WHERE NOT is_local) AS candidate_clusters,
(SELECT count() FROM system.tables WHERE database = 'system' AND name = 'zookeeper_connection') AS has_keeper,
formatReadableTimeDelta(uptime()) AS uptime,
formatReadableSize((SELECT value FROM system.asynchronous_metrics WHERE metric = 'OSMemoryTotal')) AS os_memory_total
If it fails with an authentication or network error, stop and ask for the connection details. Do not retry with guessed credentials.
cluster_macro is not empty โ cluster mode. Leave '{cluster}' in every query pack exactly as written; the server expands the macro.cluster_macro is empty and candidate_clusters is not empty โ ask the user which cluster to use, then replace '{cluster}' with that name in each statement before running it.clusterAllReplicas('{cluster}', system.<table>) with system.<table> in each statement before running it.has_keeper = 0 means no Keeper/ZooKeeper: skip every statement marked -- @requires keeper and report replication and ON CLUSTER checks as not applicable.
event_time >= now() - INTERVAL 24 HOUR). Packs already use relative windows; do not widen them without asking.; and start with a -- @check <id> <title> header; keep the id with its result.-- @requires: skip the statement when the named table is missing, when keeper is required and has_keeper = 0, or when the version condition is not met. List skipped ids with the reason.{cluster} as decided in Step 3. Any other {placeholder} is a template variable: substitute a real value first or skip the statement.UNKNOWN_IDENTIFIER, run DESCRIBE TABLE system.<table> and drop the missing column.severity column is the verdict for that row. Copy it; do not re-grade.Start every report with this table, filled from Step 2:
| Connection mode | Cluster | ClickHouse version | Keeper | Time window |
|---|---|---|---|---|
| MCP or clickhouse-client | macro value, chosen cluster, or "single node" | version | yes/no | window used |
altinity-expert-clickhouse-overview