Skip to main content
Glama
ClickHouse

mcp-clickhouse

Official
by ClickHouse

Run Query

run_query

Run SQL queries against ClickHouse with optional bound parameters, read-only by default; inspect result schemas with DESCRIBE and estimate costs with EXPLAIN ESTIMATE.

Instructions

Execute SQL queries in ClickHouse. Queries run in read-only mode by default. Bind optional params by name with {name:Type} placeholders, such as {name:String} or {vector:Array(Float32)}. Values may be JSON scalars, nulls, or arrays. Pass exact large integers as decimal strings. JSON lists and objects cannot bind to Tuple and Map types. Python percent formatting and $name$ raw binary parameters are not supported. Parameter values stay out of the MCP server's normal SQL log lines, but may appear in errors and backend logs. Set CLICKHOUSE_ALLOW_WRITE_ACCESS=true to allow DDL and DML operations. Set CLICKHOUSE_ALLOW_DROP=true to additionally allow destructive operations (DROP, TRUNCATE, DELETE, UPDATE, REPLACE TABLE/PARTITION, CREATE OR REPLACE, CLEAR COLUMN/INDEX/PROJECTION, DETACH PERMANENTLY). That gate is a best-effort accident guard, not a security boundary. Integers outside [-9007199254740991, 9007199254740991] are returned as decimal strings. Two optional checks also run through this tool. Use DESCRIBE () when you need a query's output columns and types; it inspects the result schema and surfaces analysis errors such as an unknown column, but a query that describes cleanly can still fail at runtime. Consider EXPLAIN ESTIMATE before a SELECT that could be expensive; it returns the estimated parts, rows and marks read from MergeTree family tables, which is not run time and not result size. Neither runs the query body, though analysis can execute scalar subqueries.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
paramsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.7.0
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / params
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": true,
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
    • removedOutput schema / description
      Removed value: -"Generic wrapper for non-object return types."
  2. Addedv0.2.0

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description fully discloses behavioral traits: read-only by default, write/drop gated by environment variables, parameter binding constraints, integer handling as decimal strings, and the best-effort nature of the accident guard (not a security boundary). It even warns about parameter visibility in logs. This is exceptionally transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but every sentence delivers necessary behavioral or usage information. It's logically structured: main purpose, read-only default, parameter details, write-access gates, integer handling, and optional checks. While it could be trimmed slightly, the density of information justifies the length for a complex tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity and the presence of an output schema, the description covers all essential aspects: query execution, parameter binding, access control, integer representation, and optional DESCRIBE/EXPLAIN usage. It does not need to detail the return format since an output schema exists. Nothing an agent needs to correctly invoke this tool is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema only defines 'query' and 'params' with no descriptions, so the description carries the entire burden. It thoroughly explains parameter binding syntax ({name:Type}), acceptable value types (scalars, nulls, arrays), limitations (no Tuple/Map binding, no Python formatting), and how to pass large integers as decimal strings. This adds critical meaning far beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it executes SQL queries in ClickHouse with a specific verb and resource. It differentiates itself from sibling tools (list_databases, list_tables) by being the general-purpose query executor, and even mentions read-only default and optional write access, making its role unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit guidance on when to use the tool for general queries, and details when to use DESCRIBE and EXPLAIN ESTIMATE for schema inspection and cost estimation. It does not explicitly say 'use list_databases for listing databases', but that's implied by sibling names and the description's scope. The read-only default and access flags also clarify permissible usage contexts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools