ClickHouse
概览
作者提供的说明(英文原文)
Official ClickHouse MCP server for querying and exploring ClickHouse clusters and chDB.
PopNx MCP 的三大支柱
这三项永远不会合并成一个分数:意见、测量和人气是不同的东西。
- 用户评价i暂无评价评价功能将在后续阶段与账户功能一起开放
- 我们的基础检查i1 项中通过 1 项依据公开信息检查;尚未扫描代码
- 使用情况i正在增长↓ 7.9万/周 · ★ –
它能帮你做什么
我们还没有为它写通俗的介绍。下面是我们从注册中心读取到的事实。
- 连接方式: 在你的电脑上运行
- 传输方式: stdio
- 分类: 数据库与数据集
- 你需要填写:CLICKHOUSE_HOST, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD
安装
选择你使用的 AI 应用,然后复制设置。
安装之前
- 基础检查:1 项中通过 1 项
- 在你的电脑上运行,拥有你的用户账户的权限(文件、网络、应用)。
- 需要你自己填写:
CLICKHOUSE_HOST,CLICKHOUSE_USER,CLICKHOUSE_PASSWORD,CLICKHOUSE_PORT,CLICKHOUSE_SECURE,CLICKHOUSE_VERIFY,CLICKHOUSE_CA_CERT,CLICKHOUSE_CLIENT_CERT,CLICKHOUSE_CLIENT_CERT_KEY,CLICKHOUSE_TLS_MODE,CLICKHOUSE_DATABASE,CLICKHOUSE_ROLE,CLICKHOUSE_ALLOW_WRITE_ACCESS,CLICKHOUSE_ALLOW_DROP,CLICKHOUSE_MCP_QUERY_TIMEOUT,CLICKHOUSE_MCP_MAX_WORKERS
标为机密的值是你账户的钥匙。千万不要分享给别人,也不要粘贴到聊天里。
你需要
- PyPI已安装 Python 的 uv(用于 uvx 命令)
你用的是哪个应用?
在上方选择你的应用。我们会记住它,下次按钮会显示“安装到 …”。
打开 Claude Desktop → Settings → Developer → Edit Config,把下面的内容粘贴到 claude_desktop_config.json
{
"mcpServers": {
"clickhouse": {
"command": "uvx",
"args": [
"mcp-clickhouse"
],
"env": {
"CLICKHOUSE_HOST": "your-value",
"CLICKHOUSE_USER": "your-value",
"CLICKHOUSE_PASSWORD": "your-value",
"CLICKHOUSE_PORT": "your-value",
"CLICKHOUSE_SECURE": "your-value",
"CLICKHOUSE_VERIFY": "your-value",
"CLICKHOUSE_CA_CERT": "your-value",
"CLICKHOUSE_CLIENT_CERT": "your-value",
"CLICKHOUSE_CLIENT_CERT_KEY": "your-value",
"CLICKHOUSE_TLS_MODE": "your-value",
"CLICKHOUSE_DATABASE": "your-value",
"CLICKHOUSE_ROLE": "your-value",
"CLICKHOUSE_ALLOW_WRITE_ACCESS": "your-value",
"CLICKHOUSE_ALLOW_DROP": "your-value",
"CLICKHOUSE_MCP_QUERY_TIMEOUT": "your-value",
"CLICKHOUSE_MCP_MAX_WORKERS": "your-value"
}
}
}
}在终端中运行这条命令
claude mcp add clickhouse --env CLICKHOUSE_HOST=your-value --env CLICKHOUSE_USER=your-value --env CLICKHOUSE_PASSWORD=your-value --env CLICKHOUSE_PORT=your-value --env CLICKHOUSE_SECURE=your-value --env CLICKHOUSE_VERIFY=your-value --env CLICKHOUSE_CA_CERT=your-value --env CLICKHOUSE_CLIENT_CERT=your-value --env CLICKHOUSE_CLIENT_CERT_KEY=your-value --env CLICKHOUSE_TLS_MODE=your-value --env CLICKHOUSE_DATABASE=your-value --env CLICKHOUSE_ROLE=your-value --env CLICKHOUSE_ALLOW_WRITE_ACCESS=your-value --env CLICKHOUSE_ALLOW_DROP=your-value --env CLICKHOUSE_MCP_QUERY_TIMEOUT=your-value --env CLICKHOUSE_MCP_MAX_WORKERS=your-value -- uvx mcp-clickhouse运行前请先填写空着的值。
或者自己复制设置
粘贴到项目中的 .cursor/mcp.json,或 ~/.cursor/mcp.json
{
"mcpServers": {
"clickhouse": {
"command": "uvx",
"args": [
"mcp-clickhouse"
],
"env": {
"CLICKHOUSE_HOST": "your-value",
"CLICKHOUSE_USER": "your-value",
"CLICKHOUSE_PASSWORD": "your-value",
"CLICKHOUSE_PORT": "your-value",
"CLICKHOUSE_SECURE": "your-value",
"CLICKHOUSE_VERIFY": "your-value",
"CLICKHOUSE_CA_CERT": "your-value",
"CLICKHOUSE_CLIENT_CERT": "your-value",
"CLICKHOUSE_CLIENT_CERT_KEY": "your-value",
"CLICKHOUSE_TLS_MODE": "your-value",
"CLICKHOUSE_DATABASE": "your-value",
"CLICKHOUSE_ROLE": "your-value",
"CLICKHOUSE_ALLOW_WRITE_ACCESS": "your-value",
"CLICKHOUSE_ALLOW_DROP": "your-value",
"CLICKHOUSE_MCP_QUERY_TIMEOUT": "your-value",
"CLICKHOUSE_MCP_MAX_WORKERS": "your-value"
}
}
}
}浏览器会先询问是否打开应用,然后应用会显示设置并请你确认。密钥的值会留空,由你自己填写。
或者自己复制设置
粘贴到项目中的 .vscode/mcp.json
{
"servers": {
"clickhouse": {
"type": "stdio",
"command": "uvx",
"args": [
"mcp-clickhouse"
],
"env": {
"CLICKHOUSE_HOST": "your-value",
"CLICKHOUSE_USER": "your-value",
"CLICKHOUSE_PASSWORD": "your-value",
"CLICKHOUSE_PORT": "your-value",
"CLICKHOUSE_SECURE": "your-value",
"CLICKHOUSE_VERIFY": "your-value",
"CLICKHOUSE_CA_CERT": "your-value",
"CLICKHOUSE_CLIENT_CERT": "your-value",
"CLICKHOUSE_CLIENT_CERT_KEY": "your-value",
"CLICKHOUSE_TLS_MODE": "your-value",
"CLICKHOUSE_DATABASE": "your-value",
"CLICKHOUSE_ROLE": "your-value",
"CLICKHOUSE_ALLOW_WRITE_ACCESS": "your-value",
"CLICKHOUSE_ALLOW_DROP": "your-value",
"CLICKHOUSE_MCP_QUERY_TIMEOUT": "your-value",
"CLICKHOUSE_MCP_MAX_WORKERS": "your-value"
}
}
}
}浏览器会先询问是否打开应用,然后应用会显示设置并请你确认。密钥的值会留空,由你自己填写。
这个服务器在你的电脑上运行,而 ChatGPT 只能连接互联网上的服务器。请选择其他应用。
你的选择通过 Cookie 保存在这台设备上,无需账户。
需要你填写的值
- Hostname of the ClickHouse server
- Username for ClickHouse authentication
- Password for ClickHouse authentication. Required unless a client certificate uses the default or mutual TLS mode
CLICKHOUSE_PORTenvClickHouse HTTP(S) port. Defaults to 8443 when CLICKHOUSE_SECURE=true, 8123 otherwiseCLICKHOUSE_SECUREenvUse HTTPS to connect to ClickHouseCLICKHOUSE_VERIFYenvVerify SSL certificatesCLICKHOUSE_CA_CERTenvPath to a PEM CA bundle for ClickHouse server certificate verificationCLICKHOUSE_CLIENT_CERTenvPath to a PEM client certificate for the ClickHouse HTTPS connectionCLICKHOUSE_CLIENT_CERT_KEYenvPath to the PEM private key for CLICKHOUSE_CLIENT_CERTCLICKHOUSE_TLS_MODEenvClient certificate mode: mutual, proxy, or strictCLICKHOUSE_DATABASEenvDefault database to useCLICKHOUSE_ROLEenvClickHouse role to activate for the sessionCLICKHOUSE_ALLOW_WRITE_ACCESSenvAllow write operations (DDL and DML). Queries run read-only by defaultCLICKHOUSE_ALLOW_DROPenvAllow destructive operations (DROP, TRUNCATE, DELETE, UPDATE, REPLACE, CLEAR, and DETACH PERMANENTLY) when write access is also enabledCLICKHOUSE_MCP_QUERY_TIMEOUTenvQuery tool timeout in secondsCLICKHOUSE_MCP_MAX_WORKERSenvMaximum query worker thread pool size
这些设置是根据作者在注册中心的条目生成的。如果 README 的写法不同,请以 README 为准。
它能做什么
它在你的电脑上运行;安装后,工具列表会显示在你的 AI 应用中。
基础检查i
我们检查的是任何人都能看到的信息;我们没有阅读代码。不适用的检查项不计入总数。 · 检查于 2026年11月8日
- ✓ 通过
作者与仓库一致
注册名称已通过 GitHub 账户 ClickHouse 验证,该账户拥有此仓库
- … 尚未检查
仍在维护
我们还没有从 GitHub 读取这个仓库
- … 尚未检查
有许可证
我们还没有从 GitHub 读取这个仓库
- – 不适用
端点有响应
它在你的电脑上运行,没有互联网端点
- – 不适用
使用 OAuth 登录
在你的电脑上运行,改用本地设置
- … 尚未检查
工具描述中没有隐藏指令
它在你的电脑上运行;我们只能读取互联网端点的工具列表
与“数据库与数据集”中的其他服务器比较i
- 星标数多于此分类中其他 1146 个服务器的 0%
- 发布到注册中心的时间比此分类中其他 1146 个服务器的 38% 更新
- 基础检查结果等于或优于此分类中其他 1146 个服务器的 100%
与注册中心里这个分类中所有活跃的服务器比较。只有当发布者拥有该仓库时,星标数才计入。
常见问题
ClickHouse 安全吗?
它在 1 项适用的基础检查中通过了 1 项。我们没有阅读代码。在添加密钥或令牌之前,请先看看这个服务器要求哪些权限,并使用只具备所需权限的密钥。
它需要哪些密钥或代码?
你需要填写:CLICKHOUSE_HOST, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD
它在我的电脑上运行还是在云端?
它在你的电脑上运行。你的 AI 应用会在需要时启动它,数据不会经过作者的服务器(除非它自己调用在线服务)。
它还在维护吗?
GitHub 仓库最后更新于–,最新版本(0.7.0)于2个月前进入注册中心。
哪些应用可以使用它?
支持 MCP 的应用,例如 Claude Desktop、Claude Code、Cursor 和 VS Code。你的电脑上还需要有 Python (uv), Docker。
有什么可以替代它?
同一分类中有:Supabase, MongoDB MCP Server, Elasticsearch MCP Server
替代选择
同一分类中其他作者的服务器,按星标数排序。
如何看卡片:↓ 每周下载量i★ GitHub 星标i三大支柱:评价 · 检查 · 使用情况i更新 = 最新版本发布到注册中心的时间i
作者的 README
打开 README
按原文从作者的仓库复制。PopNx MCP 没有审查或背书其内容。HTML、图片和脚本已被移除。链接会离开本站。
ClickHouse MCP Server
An MCP server for ClickHouse.
The server implements MCP 2026-07-28 and supports legacy initialize handshakes from 2024-11-05 through 2025-11-25. Modern clients use sessionless requests and server/discover. Existing clients can continue to negotiate the legacy protocol.
[!NOTE]
HTTP requests without
MCP-Protocol-Versionare routed through legacy handling so
clients from before
2025-06-18can continue to connect. MCP2026-07-28permits
this behavior on servers that support those clients. Modern clients should send the
header on every POST request.
Features
ClickHouse Tools
ClickHouse tool responses are JSON-encoded strings. Integers outside [-9007199254740991, 9007199254740991] are returned as decimal strings to preserve exact values in JavaScript clients. This applies to query rows and integer table metadata. Safe-range integers and booleans keep their JSON types.
run_query- Execute SQL queries on your ClickHouse cluster.
- Input:
query(string): The SQL query to execute. - Optional input:
params(object): Named values for ClickHouse{name:Type}placeholders. See Query parameters. - Queries run in read-only mode by default (
CLICKHOUSE_ALLOW_WRITE_ACCESS=false), but writes can be enabled explicitly if needed. DESCRIBE ( )andEXPLAIN ESTIMATErun here too and are optional ways to inspect a query's result schema or its estimated reads. See Checking a query before running it.
list_databases- List all databases on your ClickHouse cluster.
list_tables- List tables in a database with pagination.
- Required input:
database(string). - Optional inputs:
like/not_like(string): ApplyLIKEorNOT LIKEfilters to table names.page_token(string): Single-use token returned by a previous call. It is retained for up to one hour.page_size(int, default50): Number of tables returned per page; must be greater than0.include_detailed_columns(bool, defaulttrue): Whenfalse, omits column metadata for lighter responses while keeping the fullcreate_table_query.- Response shape:
tables: Array of table objects for the current page.next_page_token: Pass this single-use value back before it expires to fetch the next page, ornullwhen there are no more tables.total_tables: Total count of tables that match the supplied filters.
Agents Schema discovery
The server instructions suggest reading Agents Schema's canonical AGENTS.ROOT through run_query when list_databases reveals an AGENTS database, before writing analytical SQL. This is guidance for the agent: no metadata is fetched automatically, tool results are unchanged, and existing ClickHouse permissions still apply. If AGENTS.ROOT is missing or inaccessible, normal discovery and queries remain available.
Query parameters
Pass values separately from SQL through the optional params object:
{
"query": "SELECT {id:UInt32} AS id, {name:String} AS name", "params": {"id": 13, "name": "O'Reilly"} }
Use ClickHouse's {name:Type} placeholders without quoting them. Keep the opening brace, name, and colon adjacent, as in {id:UInt32}. Spaces after the colon and within the type are supported, as in {id: UInt32} and {amount:Decimal(18, 4)}. For compatibility across supported driver versions, start names with a letter or underscore and use only letters, digits, and underscores. Python-style %s or %(name)s formatting and the driver's $name$ raw binary parameters are not supported. Calls with only query still work. Omitting params, passing null, or passing an empty object leaves the query unbound.
Parameter values can be JSON strings, numbers, booleans, null, or arrays, provided they match the declared ClickHouse type:
- Use
nullwith aNullable(...)type. - Pass exact integers outside JavaScript's safe range as decimal strings, for example
"18446744073709551615"with{id:UInt64}. Dates, timestamps, and exact decimals can also be passed as strings with the corresponding ClickHouse type. - Bind vectors as one array, for example
{vector:Array(Float32)}with"params": {"vector": [0.25, 0.5, 0.75]}. - Nulls inside arrays depend on the installed driver. They work with clickhouse-connect 1.8.0 but fail with the supported minimum 1.0.0.
- JSON lists and objects cannot bind to ClickHouse
TupleandMaptypes.
Missing values and incompatible types return query errors. With non-empty params, a query carrying many unterminated {name: placeholder starts is rejected, including placeholder-like text in comments or string literals. Parameterized queries use the same write protection, timeouts, cancellation, and JSON result encoding as other queries.
Parameter values stay out of the MCP server's normal SQL log messages, but remain in MCP tool arguments and may appear in backend errors. ClickHouse 26.3.20.7 substitutes values into the query text in system.query_log, system.processes, and system.text_log. Parameter binding is not a privacy feature and does not reduce the number of vector values sent in a tool call.
Checking a query before running it
run_query also runs DESCRIBE and EXPLAIN ESTIMATE. Both are optional checks: reach for DESCRIBE when you need a query's output columns and types, and for EXPLAIN ESTIMATE before a SELECT that could be expensive.
DESCRIBE ( ) inspects the result schema and returns the same output-column metadata as DESCRIBE TABLE:
DESCRIBE (SELECT user, sum(amt) FROM events WHERE ts > now() - INTERVAL 30 DAY GROUP BY user)
user String
sum(amt) Decimal(38, 2)
ClickHouse has to analyze the query to answer, so analysis errors surface here, with ClickHouse's own message, instead of part way through execution:
DESCRIBE (SELECT usr FROM events) -> Code: 47. Unknown expression identifier `usr` ... Maybe you meant: ['user']
DESCRIBE (SELECT * FROM nosuch) -> Code: 60. Unknown table expression identifier 'nosuch'
A query that describes cleanly can still fail when it runs, on a memory limit or a remote server error, and it says nothing about cost.
EXPLAIN ESTIMATE returns the parts, rows and marks the query would read, one row per table, which is what separates a primary key lookup from a full scan:
EXPLAIN ESTIMATE SELECT count() FROM events WHERE id = 42
database table parts rows marks
default events 1 8192 1
Those are estimated reads from MergeTree family tables, after primary key and partition pruning. They are not run time and not result size, and other table engines are not covered.
Neither statement runs the query body, but analysis is not always free: DESCRIBE (SELECT (SELECT sleep(1))) executes the scalar subquery while analyzing. Both are read-only and work under the default CLICKHOUSE_ALLOW_WRITE_ACCESS=false. See the ClickHouse documentation for EXPLAIN ESTIMATE and DESCRIBE.
chDB Tools
run_chdb_select_query- Execute SQL queries using chDB's embedded ClickHouse engine.
- Input:
query(string): The SQL query to execute. - Integers outside
[-9007199254740991, 9007199254740991]are returned as decimal strings. - Query data directly from various sources (files, URLs, databases) without ETL processes.
- Requires the optional
chdbextra:pip install 'mcp-clickhouse[chdb]'
Health Check Endpoint
When running with HTTP or SSE transport, a health check endpoint is available at /health. This endpoint:
- Returns
200 OK(body:OK) if the server is healthy and can connect to ClickHouse - Returns
503 Service Unavailablewith a generic error message if the server cannot connect to ClickHouse - Returns
503if a ClickHouse probe does not finish within two seconds. Concurrent requests share one in-flight probe - Reuses a completed probe result for one second, so probes that arrive in quick succession do not each connect to ClickHouse. A failure or a recovery can therefore be reported up to a second late
GET and HEAD requests to the endpoint are intentionally unauthenticated and exempt from Host and Origin validation so orchestrator probes (e.g. Kubernetes liveness/readiness, load balancers) can use runtime-assigned pod or target IPs without extra configuration. /health is reserved and cannot be used as the MCP transport path. The response body is deliberately minimal to avoid leaking backend version strings or error details; debug failures via the server logs.
Example:
curl http://localhost:8000/health
Response: OK
Security
Authentication for HTTP/SSE Transports
When using HTTP or SSE transport, authentication is required by default. The stdio transport (default) does not require authentication as it only communicates via standard input/output.
Three authentication modes are supported. Pick one:
| Mode | When to use | Env var |
|---|---|---|
| Static bearer token | Simple deployments, internal services | CLICKHOUSE_MCP_AUTH_TOKEN |
| OAuth / OIDC (via FastMCP) | Azure Entra, Google, GitHub, WorkOS, etc. | FASTMCP_SERVER_AUTH= (+ provider-specific FASTMCP_SERVER_AUTH_* vars) |
| Disabled | Local development only | CLICKHOUSE_MCP_AUTH_DISABLED=true |
Startup fails if none of these are configured for HTTP/SSE transports.
Setting Up Authentication
- Generate a secure token (can be any random string):
# Using uuidgen (macOS/Linux)
uuidgen
Using openssl
openssl rand -hex 32
- Configure the server with the token:
export CLICKHOUSE_MCP_AUTH_TOKEN="your-generated-token"
- Configure your MCP client to include the token in requests:
For Claude Desktop with HTTP/SSE transport:
{
"mcpServers": { "mcp-clickhouse": { "url": "http://127.0.0.1:8000", "headers": { "Authorization": "Bearer your-generated-token" } } } }
Note: the /health endpoint is intentionally unauthenticated (see Health Check Endpoint above). To verify that bearer-token auth is actually rejecting unauthenticated requests, hit the MCP endpoint itself e.g. with the MCP Inspector, or by POSTing a JSON-RPC request to /mcp with and without the Authorization header and confirming the unauthenticated call returns 401.
OAuth / OIDC via FastMCP
For production deployments with identity providers (Azure Entra, Google, GitHub, WorkOS, etc.), delegate authentication to FastMCP's built-in auth providers instead of using a static token. Set FASTMCP_SERVER_AUTH to the full class path
只显示了开头部分;其余内容请在仓库中阅读