clickhouse-mcp
Provides read-only access to a ClickHouse instance, enabling schema exploration, data sampling, and execution of guarded SELECT/SHOW/DESCRIBE/EXPLAIN queries to investigate observability data like logs, metrics, and traces.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@clickhouse-mcpWhy did p99 latency spike at 02:14?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
clickhouse-mcp
A read-only Model Context Protocol server for ClickHouse. It gives an AI agent a small set of tools to explore a ClickHouse instance and investigate observability data (logs, metrics, traces) without being able to write or mutate anything.
Built as a reference for wiring agents onto a petabyte-scale analytics platform: the agent discovers the schema, samples data, and runs guarded read-only SQL to answer questions like "why did p99 latency spike at 02:14?".
Tools
Tool | What it does |
|
|
|
|
|
|
|
|
|
|
| Arbitrary read-only SQL (SELECT/WITH/SHOW/DESCRIBE/EXPLAIN) |
Related MCP server: db-connect-mcp
Safety
Verb guard: only
SELECT / WITH / SHOW / DESCRIBE / EXPLAIN / EXISTSare allowed; write/DDL verbs (INSERT,CREATE,DROP,ALTER,TRUNCATE, …) are rejected.Limits: every query sets
max_result_rowsandmax_execution_time, and the rows returned to the model are capped (with a truncation note) to protect its context window.Defence in depth: still point this at a read-only ClickHouse user. The app-level guard is a first line, not the only one.
Prerequisites
Node.js 20+
Any ClickHouse instance. Easiest is local docker (no setup, includes
system.*observability tables to play with):docker run -d --name ch -p 8123:8123 -p 9000:9000 clickhouse/clickhouse-server
Install
git clone <your-fork-url> clickhouse-mcp && cd clickhouse-mcp
npm install
cp .env.example .env # then edit if your ClickHouse needs authVerify it talks to ClickHouse
npm run self-test
# Connecting to http://localhost:8123
# databases: [ 'default', 'system', 'INFORMATION_SCHEMA', ... ]
# version: [ { v: '25.x.x.x' } ]
# OKRun as an MCP server (stdio)
npm startUse it from a client
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"clickhouse": {
"command": "npx",
"args": ["tsx", "/absolute/path/to/clickhouse-mcp/src/index.ts"],
"env": {
"CLICKHOUSE_URL": "http://localhost:8123",
"CLICKHOUSE_USERNAME": "default",
"CLICKHOUSE_PASSWORD": ""
}
}
}
}Claude Code:
claude mcp add clickhouse -e CLICKHOUSE_URL=http://localhost:8123 -- npx tsx /absolute/path/to/clickhouse-mcp/src/index.tsMCP Inspector (great for debugging the tools directly):
npx @modelcontextprotocol/inspector npx tsx src/index.tsThen ask an agent: "What tables are in the system database? Show recent slow queries from system.query_log grouped by minute."
License
MIT
Available Tools
6 toolsdescribe_tableA
Describe the columns and types of a table.
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | ||
| database | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full burden for behavioral disclosure. It states the purpose but does not mention read-only nature, potential errors (e.g., table not found), or any side effects. Lacks context about what happens if inputs are invalid.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that is front-loaded with the primary action. Every word earns its place; no filler or repetition.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is simple, and the description adequately indicates the expected return (columns and types). However, since there is no output schema, more detail could be given about the response format (e.g., data types, ordered list), but it remains sufficient for basic usage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It implicitly covers 'table' but provides no information about the 'database' parameter, which is required. The meaning of each parameter is not elaborated beyond the schema's property names.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'describe' and the resource 'columns and types of a table', distinguishing it from siblings like list_tables (which lists table names) and sample_rows (which retrieves data). It is specific and unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies when to use the tool (when you need column structure), but does not explicitly mention alternatives or exclusions. No guidance is given on when not to use it, such as when you need row data or table creation DDL.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_databasesA
List all databases in ClickHouse.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations exist, so the description must carry the full behavioral burden. It only states 'List all databases in ClickHouse' and provides no additional context about read-only nature, performance, pagination, or error behavior. Minimal disclosure beyond the obvious.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One short sentence with no filler. Every word adds meaning: 'List', 'all', 'databases', 'ClickHouse'. Perfectly concise and front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple listing tool with no parameters, no output schema, and simple siblings, the description is nearly complete. It covers the core purpose. It could optionally mention whether system/internal databases are included or specify output format, but these are minor gaps. Adequate for an agent to invoke correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so schema coverage is trivially 100%. By rule, baseline for 0 params is 4. The description adds no parameter-specific meaning, but none is needed. It correctly implies the operation takes no arguments.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description uses specific verb 'List' and resource 'databases' scoped to ClickHouse. It clearly distinguishes from sibling tools like list_tables by naming the resource type. No ambiguity.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Usage is implied by the description and tool name: use this when you need all databases in ClickHouse. However, it does not explicitly state when not to use it or mention alternatives such as list_tables for tables. No exclusions are given.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_tablesA
List tables in a database.
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | Database name. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description implies a read-only operation by using 'list', but with no annotations, it carries full burden. It does not detail output format, error behavior, or any other behavioral aspects. This is adequate for a simple listing tool but lacks additional context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single concise sentence with no unnecessary words, making it easy to parse and front-loaded with the core purpose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (1 parameter, no output schema), the description is mostly complete. It clearly indicates that the tool lists tables for a given database, which is sufficient for correct invocation, though it could be slightly more explicit about the return value.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema already documents the 'database' parameter as 'Database name.' with 100% coverage. The description only restates that tables are listed 'in a database,' adding minimal additional meaning beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description 'List tables in a database' clearly states the tool's function with a specific verb (list) and resource (tables), and it naturally distinguishes from siblings like list_databases (which lists databases) and describe_table (which describes a single table).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives. The description does not mention prerequisites, exclusions, or scenarios where sibling tools might be more appropriate.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
queryA
Run a read-only SQL query against ClickHouse (SELECT/WITH/SHOW/DESCRIBE/EXPLAIN only). Results are capped to keep the agent's context small. Use it to investigate telemetry: group by time, aggregate, find anomalies, join logs/metrics/traces. Add LIMIT on big tables.
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | Read-only SQL. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of disclosing behaviors. It states the tool is read-only, enumerates allowed statement types, and notes that results are capped to keep context small. This gives the agent essential safety and performance expectations, though it omits details like error handling for non-read-only queries.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is composed of three concise sentences, immediately stating the purpose then adding safety and usage guidance. Every sentence provides value without redundancy or filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a single-parameter query tool with no output schema, the description adequately covers purpose, read-only scope, result size behavior, and intended use cases. It does not specify the return format or behavior on invalid SQL, but these are less critical given the tool's simplicity and strong safety framing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema parameter description is minimal ('Read-only SQL'), but the tool description expands on this by specifying allowed statement types and advising LIMIT usage on large tables. This adds meaningful context beyond the schema, making it easier to construct correct queries.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states that the tool runs read-only SQL queries against ClickHouse, enumerating allowed statement types (SELECT/WITH/SHOW/DESCRIBE/EXPLAIN). This distinguishes it from sibling tools like list_databases and sample_rows, which cover more specific discovery operations.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit use cases for telemetry investigation: grouping by time, aggregating, finding anomalies, and joining logs/metrics/traces. It also gives practical advice to add LIMIT on big tables. It does not explicitly mention when to avoid this tool in favor of siblings, but the context is sufficient for most scenarios.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
sample_rowsA
Read a small sample of rows from a table to understand its shape. Defaults to 10 rows.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| table | Yes | ||
| database | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full responsibility for behavioral disclosure. It does state 'Read' (implying non-mutating) and mentions the default limit of 10 rows, which is useful. However, it does not explain whether the sample is random or sequential, how it handles large tables, or what the return format looks like – leaving gaps in transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single clear sentence that front-loads the action and purpose, then adds the default limit. Every word earns its place; there is no fluff or repetition.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity and absence of an output schema, the description covers the essential purpose and default behavior. It does not explain return structure or sampling strategy, but the name and description together provide sufficient context for an agent to understand what the tool does. Sibling tools are contextually related, but the description doesn't explicitly guide selection among them, slightly reducing completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It adds meaning to 'limit' by stating a default of 10 rows, but it doesn't mention min/max bounds or that it's optional. For 'database' and 'table,' the parameter names are self-explanatory, so this partial compensation is adequate but not comprehensive.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's function: 'Read a small sample of rows from a table to understand its shape.' This uses a specific verb (read) and resource (sample of rows from a table), and it distinguishes from sibling tools like 'describe_table' (schema) and 'query' (full query) by emphasizing a small sample for shape understanding.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'to understand its shape' implies the tool is for quick, exploratory data checks, but it does not explicitly name alternatives or state when not to use it. There's no mention of 'use describe_table for schema' or 'use query for full results,' so guidance is merely implied rather than explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
show_create_tableA
Return the CREATE TABLE statement for a table (schema, engine, settings).
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | ||
| database | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses the output type (a CREATE TABLE statement) and scope (schema, engine, settings), which is useful. However, it does not explicitly state that the tool is read-only or mention any permissions or error behavior. The verb 'Return' implies a safe read, but additional context like 'does not modify the table' would improve clarity.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that delivers the essential information with no filler. The parenthetical adds relevant detail without bloating. It is front-loaded and every word earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is simple with only two parameters and no output schema. The description tells what it returns but does not specify the exact return format (e.g., a raw SQL string) or any error cases. Given the lack of annotations and output schema, a bit more detail about the return value would improve completeness. Currently, it is adequate but leaves some gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has 0% description coverage, and the description does not compensate. It mentions 'for a table' but does not explain the 'database' or 'table' parameters beyond their names. No syntax, formats, or relationship between parameters is added. Since the description fails to add meaning beyond the schema property names, a low score is warranted.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Return the CREATE TABLE statement for a table.' It specifies the exact resource (table) and the output (the statement), and the parenthetical '(schema, engine, settings)' adds specificity. This distinguishes it from siblings like describe_table, which might return metadata, and query or sample_rows, which return data.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage: when you need the DDL for a table. However, it does not explicitly state when to prefer this over describe_table or provide any exclusions. No explicit alternatives or 'when not to use' guidance is given, so it stops at implied usage.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
6 tool updates
v0.1.0- First observed
describe_table - First observed
list_databases - First observed
list_tables - First observed
query - First observed
sample_rows - First observed
show_create_table
TDQS
Scored across 6 tools
Each tool targets a distinct operation: listing databases, listing tables, sampling rows, describing columns, showing the CREATE statement, and running arbitrary queries. While describe_table and show_create_table both expose schema information, their purposes are clearly separated by level of detail and use case. No two tools are likely to be confused.
The tool names mostly follow a consistent verb_noun pattern (list_databases, list_tables, describe_table, show_create_table, sample_rows). The exception is 'query', which is a single verb, but it is a reasonable outlier given its generic nature. Overall, the naming is predictable and easy to navigate.
Six tools is an ideal size for a ClickHouse exploration server, covering all essential read-only operations without unnecessary bloat. Each tool has a clear purpose and none feel redundant. The count is well-scoped for the server's stated goal of investigating telemetry data.
The tool set provides full coverage for the core workflows: discovering databases and tables, understanding table schemas via describe and CREATE statements, sampling data, and running arbitrary queries for deeper analysis. There are no obvious gaps for a read-only data exploration server; any additional needs can be fulfilled through the query tool.
Maintenance
Related MCP Connectors
Governed access to production AI-agent traces in an existing ClickHouse store.
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Related MCP Servers
FlicenseNot gradedqualityAmaintenanceProduction-ready MCP server designed to empower AI agents and LLMs to interact seamlessly with ClickHouse. It exposes your ClickHouse database as a set of standardized tools and resources that adhere to the MCP protocol, making it easy for agents built on OpenAI, Claude, or other platforms to query, explore, and analyse your data.37-- AlicenseAqualityAmaintenanceA read-only MCP server for exploratory data analysis across PostgreSQL, MySQL, and ClickHouse databases, providing safe, read-only access with comprehensive analysis capabilities.1070 PyPI6MIT
- FlicenseNot gradedqualityFmaintenanceA read-only MCP server that enables AI agents to explore database schemas and execute safe queries on PostgreSQL and MySQL.-
- FlicenseAqualityCmaintenanceRead-only MCP server for ClickHouse that allows listing databases and tables, describing schemas, and running SELECT queries.4-