The ClickHouse MCP Server is a Model Context Protocol (MCP) server implementation developed by ClickHouse officially. It is specifically designed to provide AI assistants (such as Claude) with secure connectivity and interaction capabilities with ClickHouse databases. This project, through the standardized MCP protocol, enables AI assistants to execute SQL queries, manage database structures, and perform real-time data analysis.
MCP (Model Context Protocol) is an open standard aimed at providing AI applications with a secure and standardized way to integrate with external services. Through this server, users can allow AI assistants to directly access their ClickHouse databases, enabling intelligent data querying and analysis.
run_select_query
)readonly = 1
mode to ensure data security.sql
(string): The SQL query statement to execute.list_databases
)list_tables
)database
(string): The database name.~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
{
"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"
}
}
}
}
CLICKHOUSE_HOST
: ClickHouse server hostname.CLICKHOUSE_USER
: Authentication username.CLICKHOUSE_PASSWORD
: Authentication password.CLICKHOUSE_PORT
: Port number.CLICKHOUSE_SECURE
: Enable/disable HTTPS connection.CLICKHOUSE_VERIFY
: Enable/disable SSL certificate verification.CLICKHOUSE_CONNECT_TIMEOUT
: Connection timeout (seconds).CLICKHOUSE_SEND_RECEIVE_TIMEOUT
: Send/receive timeout (seconds).CLICKHOUSE_DATABASE
: Default database to connect to.{
"env": {
"CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com",
"CLICKHOUSE_PORT": "8443",
"CLICKHOUSE_USER": "demo",
"CLICKHOUSE_PASSWORD": "",
"CLICKHOUSE_SECURE": "true",
"CLICKHOUSE_VERIFY": "true"
}
}
# .env file configuration
CLICKHOUSE_HOST=localhost
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=clickhouse
CLICKHOUSE_SECURE=false
CLICKHOUSE_VERIFY=false
CLICKHOUSE_HOST=your-instance.clickhouse.cloud
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=your-password
# Use secure default settings
# Install dependencies
uv sync
# Activate virtual environment
source .venv/bin/activate
# Start development server
mcp dev mcp_clickhouse/mcp_server.py
# Install development dependencies
uv sync --all-extras --dev
# Code check
uv run ruff check .
# Start test services
docker compose up -d test_services
# Run tests
uv run pytest tests
The ClickHouse MCP Server project builds a secure and efficient bridge between AI assistants and ClickHouse databases. Through the standardized MCP protocol, it enables AI assistants to understand and operate complex database structures, execute sophisticated SQL queries, and provide real-time data insights.
This project represents a new direction in AI and database integration, providing developers with a powerful and secure tool that allows AI assistants to truly understand and operate enterprise-grade data resources.