mcp-clickhouse
Official
by ClickHouse
ClickHouse MCP Server
An MCP server for ClickHouse.
<a href="https://glama.ai/mcp/servers/yvjy4csvo1"><img width="380" height="200" src="https://glama.ai/mcp/servers/yvjy4csvo1/badge" alt="mcp-clickhouse MCP server" /></a>
Features
Tools
run_select_query
- Execute SQL queries on your ClickHouse cluster.
- Input:
sql
(string): The SQL query to execute. - All ClickHouse queries are run with
readonly = 1
to ensure they are safe.
list_databases
- List all databases on your ClickHouse cluster.
list_tables
- List all tables in a database.
- Input:
database
(string): The name of the database.
Configuration
Note: This is a temporary configuration process that will be significantly improved once the package is published.
- Run
uv sync
to install the dependencies. To installuv
follow the instructions here. Then dosource .venv/bin/activate
. - Setup the
.env.production
file with the ClickHouse credentials.
Copy
CLICKHOUSE_HOST=<CLICKHOUSE_HOST>
CLICKHOUSE_PORT=<CLICKHOUSE_PORT>
CLICKHOUSE_USER=<CLICKHOUSE_USER>
CLICKHOUSE_PASSWORD=<CLICKHOUSE_PASSWORD>
- Run
fastmcp install mcp_clickhouse/mcp_server.py -f .env.production
to install the server. - Open the configuration file located at:
- On macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- On Windows:
%APPDATA%/Claude/claude_desktop_config.json
Locate the command entry for
uv
and replace it with the absolute path to theuv
executable. This ensures that the correct version ofuv
is used when starting the server. - On macOS:
- Restart Claude Desktop to apply the changes.
Development
- In
test-services
directory rundocker compose up -d
to start the ClickHouse cluster. - Add the following variables to a
.env
file in the root of the repository.
Copy
CLICKHOUSE_HOST=localhost
CLICKHOUSE_PORT=8123
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=clickhouse
- Run
uv sync
to install the dependencies. To installuv
follow the instructions here. Then dosource .venv/bin/activate
. - For easy testing, you can run
fastmcp dev mcp_clickhouse/mcp_server.py
to start the MCP server.
ClickHouse database integration with schema inspection and query capabilities