Skip to main content
Glama

Run Query

run_query
Read-only

Runs read-only ClickHouse SQL queries to inspect schemas, retrieve data, and apply optional named parameters for parameterized filtering.

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, OPTIMIZE DEDUPLICATE, MODIFY/MATERIALIZE TTL, MODIFY/ALTER COLUMN with TTL, DETACH PERMANENTLY). That gate is a best-effort accident guard, not a security boundary. Integers outside [-9007199254740991, 9007199254740991] are returned as decimal strings. Do not end a query with a FORMAT clause, because this tool appends FORMAT Native. With readonly=1, the default, a SETTINGS clause fails with code 164 or is ignored. 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.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>"
    },
    "name": "run_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYes
paramsNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior1/5

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

Annotations declare readOnlyHint=true, yet the description says write access can be enabled (CLICKHOUSE_ALLOW_WRITE_ACCESS) to permit DDL/DML and CLICKHOUSE_ALLOW_DROP for DROP, TRUNCATE, DELETE, UPDATE, etc. An agent trusting the read-only annotation could execute destructive state changes, so the description directly contradicts the annotation on a safety-critical point.

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?

Content is dense but nearly every sentence carries distinct operational information (log exposure, FORMAT/SETTINGS constraints, integer bounds, DESCRIBE/EXPLAIN). Structure is a single run-on block rather than sectioned or bulleted, which hurts scanability despite the lack of filler.

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 a complex SQL executor with an output schema present, the description covers the safety profile, parameter binding pitfalls, return-value integer handling, clause restrictions, and auxiliary DESCRIBE/EXPLAIN behaviors. Nothing an agent needs to call it correctly appears 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?

Schema coverage is 0%, so the description carries the full burden, and it does so thoroughly: {name:Type} binding syntax with examples, accepted value types (JSON scalars, nulls, arrays), large-integer-as-decimal-string handling, rejected bindings for Tuple/Map, and unsupported Python percent / $name$ formatting. This is exactly the parameter meaning absent from 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?

States a specific verb+resource ("Execute SQL queries in ClickHouse") that is unmistakably distinct from the sibling list_databases/list_tables. An agent can identify what this tool does without opening the schema.

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?

Offers rich conditional guidance: use DESCRIBE(<query>) to inspect output columns/types, and EXPLAIN ESTIMATE before expensive SELECTs, plus several 'do not' constraints (no trailing FORMAT, SETTINGS fails under readonly=1). It does not explicitly route the agent to/away from sibling list tools, but for a general SQL executor that omission is minor.

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