home / mcp / clickhouse mcp server
Provides an MCP server to securely explore ClickHouse databases by listing tables, reading data, and running SQL queries through a controlled interface.
Configuration
View docs{
"mcpServers": {
"dubin555-clickhouse_mcp_server": {
"command": "uv",
"args": [
"--directory",
"/path/to/clickhouse_mcp_server",
"run",
"-m",
"clickhouse_mcp_server.server"
],
"env": {
"CLICKHOUSE_HOST": "localhost",
"CLICKHOUSE_PORT": "8123",
"CLICKHOUSE_USER": "default",
"CLICKHOUSE_DATABASE": "default",
"CLICKHOUSE_PASSWORD": "CHANGE_TO_YOUR_PASSWORD"
}
}
}
}You can use this MCP server to securely explore and analyze ClickHouse databases through a structured, controlled interface. It lets AI assistants list tables, read data, and execute SQL queries against ClickHouse with clearly defined environment settings and run configurations.
Connect to your ClickHouse MCP server from an MCP client (such as CLINE or another compatible tool). You configure the server to talk to ClickHouse and then issue natural language questions or SQL-like prompts to retrieve data, run queries, or inspect table structures. Examples of questions you might ask include things like: What is the sales volume in each region? Which product is the best-selling?
Prerequisites you need before running the server:
Install and run steps you can follow to start the MCP server for ClickHouse:
# Set up environment variables for ClickHouse connection
export CLICKHOUSE_HOST=localhost
export CLICKHOUSE_PORT=8123
export CLICKHOUSE_USER=default
export CLICKHOUSE_PASSWORD=CHANGE_TO_YOUR_PASSWORD
export CLICKHOUSE_DATABASE=default
# Run the MCP server via the CLI (example command shown in configuration)
# The command assumes you have the MCP server code at the specified directory
uv --directory /path/to/clickhouse_mcp_server run -m clickhouse_mcp_server.serverConfiguration, security considerations, and practical usage notes help you get the most out of the ClickHouse MCP Server.
Environment variables required to connect to ClickHouse are provided in the server configuration. You can set them in your shell or in your MCP client’s environment configuration.
Example MCP client configuration snippet demonstrates how to start the local MCP server with the necessary environment settings.
{
"mcpServers": {
"clickhouse": {
"command": "uv",
"args": [
"--directory",
"/path/to/clickhouse_mcp_server",
"run",
"-m",
"clickhouse_mcp_server.server"
],
"env": {
"CLICKHOUSE_HOST": "localhost",
"CLICKHOUSE_PORT": "8123",
"CLICKHOUSE_USER": "default",
"CLICKHOUSE_PASSWORD": "CHANGE_TO_YOUR_PASSWORD",
"CLICKHOUSE_DATABASE": "default"
}
}
}
}Lists all tables available in the connected ClickHouse database.
Reads data from a specified table or query result set.
Executes a given SQL query against ClickHouse and returns results.