The ClickHouse MCP Server enables Claude to interact with ClickHouse databases and run SQL queries. It provides tools for executing SELECT queries, listing databases and tables, and also supports chDB's embedded OLAP engine for querying data from various sources without ETL processes.
You can install the ClickHouse MCP server in two ways:
{
"mcpServers": {
"mcp-clickhouse": {
"command": "uv",
"args": [
"run",
"--with",
"mcp-clickhouse",
"--python",
"3.10",
"mcp-clickhouse"
],
"env": {
"CLICKHOUSE_HOST": "<clickhouse-host>",
"CLICKHOUSE_PORT": "<clickhouse-port>",
"CLICKHOUSE_USER": "<clickhouse-user>",
"CLICKHOUSE_PASSWORD": "<clickhouse-password>",
"CLICKHOUSE_SECURE": "true",
"CLICKHOUSE_VERIFY": "true",
"CLICKHOUSE_CONNECT_TIMEOUT": "30",
"CLICKHOUSE_SEND_RECEIVE_TIMEOUT": "30"
}
}
}
}
uv
executable (using which uv
on Mac) and replace the command
entry with this path.python3 -m pip install mcp-clickhouse
{
"mcpServers": {
"mcp-clickhouse": {
"command": "python3",
"args": [
"-m",
"mcp_clickhouse.main"
],
"env": {
"CLICKHOUSE_HOST": "<clickhouse-host>",
"CLICKHOUSE_PORT": "<clickhouse-port>",
"CLICKHOUSE_USER": "<clickhouse-user>",
"CLICKHOUSE_PASSWORD": "<clickhouse-password>",
"CLICKHOUSE_SECURE": "true",
"CLICKHOUSE_VERIFY": "true",
"CLICKHOUSE_CONNECT_TIMEOUT": "30",
"CLICKHOUSE_SEND_RECEIVE_TIMEOUT": "30"
}
}
}
}
Alternatively, you can use the installed script directly:
{
"mcpServers": {
"mcp-clickhouse": {
"command": "mcp-clickhouse",
"env": {
"CLICKHOUSE_HOST": "<clickhouse-host>",
"CLICKHOUSE_PORT": "<clickhouse-port>",
"CLICKHOUSE_USER": "<clickhouse-user>",
"CLICKHOUSE_PASSWORD": "<clickhouse-password>",
"CLICKHOUSE_SECURE": "true",
"CLICKHOUSE_VERIFY": "true",
"CLICKHOUSE_CONNECT_TIMEOUT": "30",
"CLICKHOUSE_SEND_RECEIVE_TIMEOUT": "30"
}
}
}
}
The server supports both ClickHouse and chDB, and you can enable either or both depending on your needs.
For a quick start using the ClickHouse SQL Playground:
{
"mcpServers": {
"mcp-clickhouse": {
"command": "uv",
"args": [
"run",
"--with",
"mcp-clickhouse",
"--python",
"3.10",
"mcp-clickhouse"
],
"env": {
"CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com",
"CLICKHOUSE_PORT": "8443",
"CLICKHOUSE_USER": "demo",
"CLICKHOUSE_PASSWORD": "",
"CLICKHOUSE_SECURE": "true",
"CLICKHOUSE_VERIFY": "true",
"CLICKHOUSE_CONNECT_TIMEOUT": "30",
"CLICKHOUSE_SEND_RECEIVE_TIMEOUT": "30"
}
}
}
}
To use the embedded OLAP engine:
{
"mcpServers": {
"mcp-clickhouse": {
"command": "uv",
"args": [
"run",
"--with",
"mcp-clickhouse",
"--python",
"3.10",
"mcp-clickhouse"
],
"env": {
"CHDB_ENABLED": "true",
"CLICKHOUSE_ENABLED": "false",
"CHDB_DATA_PATH": "/path/to/chdb/data"
}
}
}
}
You can enable both ClickHouse and chDB simultaneously:
{
"mcpServers": {
"mcp-clickhouse": {
"command": "uv",
"args": [
"run",
"--with",
"mcp-clickhouse",
"--python",
"3.10",
"mcp-clickhouse"
],
"env": {
"CLICKHOUSE_HOST": "<clickhouse-host>",
"CLICKHOUSE_PORT": "<clickhouse-port>",
"CLICKHOUSE_USER": "<clickhouse-user>",
"CLICKHOUSE_PASSWORD": "<clickhouse-password>",
"CLICKHOUSE_SECURE": "true",
"CLICKHOUSE_VERIFY": "true",
"CLICKHOUSE_CONNECT_TIMEOUT": "30",
"CLICKHOUSE_SEND_RECEIVE_TIMEOUT": "30",
"CHDB_ENABLED": "true",
"CHDB_DATA_PATH": "/path/to/chdb/data"
}
}
}
}
CLICKHOUSE_HOST
: The hostname of your ClickHouse serverCLICKHOUSE_USER
: The username for authenticationCLICKHOUSE_PASSWORD
: The password for authenticationCLICKHOUSE_PORT
: Default is 8443
for HTTPS, 8123
for HTTPCLICKHOUSE_SECURE
: Enable/disable HTTPS connection (default: "true"
)CLICKHOUSE_VERIFY
: Enable/disable SSL certificate verification (default: "true"
)CLICKHOUSE_CONNECT_TIMEOUT
: Connection timeout in seconds (default: "30"
)CLICKHOUSE_SEND_RECEIVE_TIMEOUT
: Send/receive timeout in seconds (default: "300"
)CLICKHOUSE_DATABASE
: Default database to useCLICKHOUSE_ENABLED
: Enable/disable ClickHouse functionality (default: "true"
)CHDB_ENABLED
: Enable/disable chDB functionality (default: "false"
)CHDB_DATA_PATH
: Path to chDB data directory (default: ":memory:"
)CLICKHOUSE_MCP_SERVER_TRANSPORT
: Sets transport method ("stdio"
, "http"
, "sse"
) (default: "stdio"
)CLICKHOUSE_MCP_BIND_HOST
: Host to bind when using HTTP/SSE transport (default: "127.0.0.1"
)CLICKHOUSE_MCP_BIND_PORT
: Port to bind when using HTTP/SSE transport (default: "8000"
)You can execute read-only SQL queries on your ClickHouse cluster:
SELECT * FROM system.databases LIMIT 10
All queries are executed with readonly = 1
for safety.
To list all databases on your ClickHouse cluster:
list_databases
To list all tables in a specific database:
list_tables database_name
Replace database_name
with the actual name of your database.
If you've enabled chDB, you can query data directly from various sources without ETL processes:
SELECT * FROM 'https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet' LIMIT 10
When running with HTTP or SSE transport, a health check endpoint is available at /health
:
curl http://localhost:8000/health
# Response: OK - Connected to ClickHouse 24.3.1
This returns 200 OK
with the ClickHouse version if the server is healthy, or 503 Service Unavailable
if it cannot connect to ClickHouse.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mcp-clickhouse" '{"command":"uv","args":["run","--with","mcp-clickhouse","--python","3.13","mcp-clickhouse"],"env":{"CLICKHOUSE_HOST":"<clickhouse-host>","CLICKHOUSE_PORT":"<clickhouse-port>","CLICKHOUSE_USER":"<clickhouse-user>","CLICKHOUSE_PASSWORD":"<clickhouse-password>","CLICKHOUSE_SECURE":"true","CLICKHOUSE_VERIFY":"true","CLICKHOUSE_CONNECT_TIMEOUT":"30","CLICKHOUSE_SEND_RECEIVE_TIMEOUT":"30"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mcp-clickhouse": {
"command": "uv",
"args": [
"run",
"--with",
"mcp-clickhouse",
"--python",
"3.13",
"mcp-clickhouse"
],
"env": {
"CLICKHOUSE_HOST": "<clickhouse-host>",
"CLICKHOUSE_PORT": "<clickhouse-port>",
"CLICKHOUSE_USER": "<clickhouse-user>",
"CLICKHOUSE_PASSWORD": "<clickhouse-password>",
"CLICKHOUSE_SECURE": "true",
"CLICKHOUSE_VERIFY": "true",
"CLICKHOUSE_CONNECT_TIMEOUT": "30",
"CLICKHOUSE_SEND_RECEIVE_TIMEOUT": "30"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mcp-clickhouse": {
"command": "uv",
"args": [
"run",
"--with",
"mcp-clickhouse",
"--python",
"3.13",
"mcp-clickhouse"
],
"env": {
"CLICKHOUSE_HOST": "<clickhouse-host>",
"CLICKHOUSE_PORT": "<clickhouse-port>",
"CLICKHOUSE_USER": "<clickhouse-user>",
"CLICKHOUSE_PASSWORD": "<clickhouse-password>",
"CLICKHOUSE_SECURE": "true",
"CLICKHOUSE_VERIFY": "true",
"CLICKHOUSE_CONNECT_TIMEOUT": "30",
"CLICKHOUSE_SEND_RECEIVE_TIMEOUT": "30"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect