clickhouse-mcp-server
Provides tools to interact with ClickHouse databases, including listing databases, listing tables, and executing SELECT, SHOW, and DESCRIBE queries.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@clickhouse-mcp-serverlist tables in the default database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ClickHouse MCP Server
A Model Context Protocol (MCP) server that provides tools for interacting with ClickHouse databases. Built with xmcp and supports both HTTP and stdio transport methods.
Features
List Databases: Retrieve all databases from your ClickHouse server
List Tables: Get tables from a specific database
Run Select Queries: Execute SELECT, SHOW, and DESCRIBE queries safely
Multiple Transport Modes: Supports stdio, HTTP, and SSE (Server-Sent Events)
TLS/SSL Support: Configurable certificate handling for secure connections
Installation
From npm (when published)
npm install -g clickhouse-mcp-serverFrom source
git clone https://github.com/ahmedrowaihi/clickhouse-mcp-server.git
cd clickhouse-mcp-server
bun install
bun run buildUsage
As a CLI tool (after global install)
# Start in stdio mode (for local/subprocess communication)
clickhouse-mcp stdio
# Start in HTTP mode (for remote/network access)
clickhouse-mcp http
# Start in SSE mode (Server-Sent Events over HTTP)
clickhouse-mcp sseDevelopment mode
# Start development server
bun run dev
# Build for production
bun run build
# Run specific modes
bun run start:stdio
bun run start:httpDirect execution (after building)
# Using the compiled launcher
node dist/launcher.js stdio
node dist/launcher.js http
node dist/launcher.js sse
# Or run server files directly
node dist/stdio.js
node dist/http.jsConfiguration
Environment Variables
Set these environment variables before running the server:
export CLICKHOUSE_HOST_URL=https://your-clickhouse-server.com:8443
export CLICKHOUSE_USER=your-username
export CLICKHOUSE_PASSWORD=your-password
export CLICKHOUSE_DATABASE=your-database
# Optional settings with defaults
export CLICKHOUSE_SECURE=true
export CLICKHOUSE_VERIFY=true
export CLICKHOUSE_CONNECT_TIMEOUT_SEC=10
export CLICKHOUSE_SEND_RECEIVE_TIMEOUT_SEC=60
# Optional TLS certificate path
export CLICKHOUSE_CERT_PATH=/path/to/certificate.pemOr create a .env file in your project root:
# ClickHouse connection settings
CLICKHOUSE_HOST_URL=https://your-clickhouse-server.com:8443
CLICKHOUSE_USER=your-username
CLICKHOUSE_PASSWORD=your-password
CLICKHOUSE_DATABASE=your-database
# Optional settings with defaults
CLICKHOUSE_SECURE=true
CLICKHOUSE_VERIFY=true
CLICKHOUSE_CONNECT_TIMEOUT_SEC=10
CLICKHOUSE_SEND_RECEIVE_TIMEOUT_SEC=60
# Optional TLS certificate path
CLICKHOUSE_CERT_PATH=/path/to/certificate.pemMCP Client Configuration
Claude Desktop
Add this to your Claude Desktop configuration file:
On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"clickhouse": {
"command": "clickhouse-mcp",
"args": ["stdio"],
"env": {
"CLICKHOUSE_HOST_URL": "https://your-clickhouse-server.com:8443",
"CLICKHOUSE_USER": "your-username",
"CLICKHOUSE_PASSWORD": "your-password",
"CLICKHOUSE_DATABASE": "your-database",
"CLICKHOUSE_SECURE": "true",
"CLICKHOUSE_VERIFY": "true",
"CLICKHOUSE_CONNECT_TIMEOUT_SEC": "10",
"CLICKHOUSE_SEND_RECEIVE_TIMEOUT_SEC": "60"
}
}
}
}Using with npx (if not globally installed)
{
"mcpServers": {
"clickhouse": {
"command": "npx",
"args": ["clickhouse-mcp-server", "stdio"],
"env": {
"CLICKHOUSE_HOST_URL": "https://your-clickhouse-server.com:8443",
"CLICKHOUSE_USER": "your-username",
"CLICKHOUSE_PASSWORD": "your-password",
"CLICKHOUSE_DATABASE": "your-database"
}
}
}
}HTTP/SSE Mode Setup
For HTTP-based MCP clients, you need to run the server in HTTP or SSE mode and configure your client to connect via URL.
Step 1: Create .env file
Create a .env file in your project directory:
CLICKHOUSE_HOST_URL=https://sql-clickhouse.clickhouse.com:8443
CLICKHOUSE_USER=demo
CLICKHOUSE_PASSWORD=
CLICKHOUSE_DATABASE=default
CLICKHOUSE_SECURE=trueStep 2: Start the server
# Start in HTTP mode
clickhouse-mcp http
# Or start in SSE mode
clickhouse-mcp sseThe server will start on http://localhost:3001 by default and accepts mcp requests on the /mcp path.
Step 3: Configure MCP Client
For MCP clients that support HTTP connections, add this to your configuration:
{
"mcpServers": {
"clickhouse-playground": {
"url": "http://127.0.0.1:3001/mcp"
}
}
}Complete Example for Playground Testing:
Create
.envfile:CLICKHOUSE_HOST_URL=https://sql-clickhouse.clickhouse.com:8443 CLICKHOUSE_USER=demo CLICKHOUSE_PASSWORD= CLICKHOUSE_DATABASE=default CLICKHOUSE_SECURE=trueStart server:
clickhouse-mcp sseConfigure your MCP client:
{ "mcpServers": { "clickhouse-playground": { "url": "http://127.0.0.1:3001/mcp" } } }
Note: HTTP/SSE mode is ideal for web-based MCP clients, remote access, or when you need multiple clients to connect to the same server instance.
Quick Start with ClickHouse Playground
To quickly test the MCP server, you can use the public ClickHouse SQL Playground:
Environment Variables for Playground
export CLICKHOUSE_HOST_URL=https://sql-clickhouse.clickhouse.com:8443
export CLICKHOUSE_USER=demo
export CLICKHOUSE_PASSWORD=""
export CLICKHOUSE_DATABASE=default
export CLICKHOUSE_SECURE=trueClaude Desktop Configuration for Playground
{
"mcpServers": {
"clickhouse-playground": {
"command": "clickhouse-mcp",
"args": ["stdio"],
"env": {
"CLICKHOUSE_HOST_URL": "https://sql-clickhouse.clickhouse.com:8443",
"CLICKHOUSE_USER": "demo",
"CLICKHOUSE_PASSWORD": "",
"CLICKHOUSE_DATABASE": "default",
"CLICKHOUSE_SECURE": "true"
}
}
}
}Test Commands
Once configured, you can test these queries in Claude Desktop:
List databases: "Show me all available databases"
List tables: "What tables are in the default database?"
Sample query: "Show me the first 10 rows from any table"
Note: The ClickHouse Playground is a public demo environment. Don't use it for production data or sensitive information.
Environment Variables
Variable | Description | Required | Default |
| Full URL to ClickHouse server | Yes | - |
| Username for authentication | Yes | - |
| Password for authentication | Yes | - |
| Default database to connect to | Yes | - |
| Use HTTPS/TLS connection | No |
|
| Verify SSL certificates | No |
|
| Connection timeout in seconds | No |
|
| Request timeout in seconds | No |
|
| Path to custom SSL certificate | No | - |
Available Tools
1. List Databases
Lists all databases available on the ClickHouse server.
Usage in MCP client:
{
"method": "tools/call",
"params": {
"name": "list_databases"
}
}2. List Tables
Lists all tables in a specified database.
Parameters:
database(string): Name of the database
Usage in MCP client:
{
"method": "tools/call",
"params": {
"name": "list_tables",
"arguments": {
"database": "my_database"
}
}
}3. Run Select Query
Executes SELECT, SHOW, or DESCRIBE queries on the ClickHouse database.
Parameters:
query(string): The SQL query to execute (must start with SELECT, SHOW, or DESCRIBE)
Usage in MCP client:
{
"method": "tools/call",
"params": {
"name": "run_select_query",
"arguments": {
"query": "SELECT * FROM my_table LIMIT 10"
}
}
}Transport Modes
STDIO Mode
Best for local development and subprocess communication:
clickhouse-mcp stdioHTTP Mode
Ideal for remote access and web-based clients:
clickhouse-mcp httpSSE Mode
Server-Sent Events over HTTP for real-time applications:
clickhouse-mcp sseBuilding
# Build everything (xmcp + launcher)
bun run build
# Build only xmcp components
bun run build:xmcpSecurity
All queries are executed with
readonly: "1"setting for safetyOnly SELECT, SHOW, and DESCRIBE queries are allowed
TLS/SSL support for secure connections
Requirements
Node.js >= 20.0.0
ClickHouse server with network access
Valid ClickHouse credentials
License
MIT
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Submit a pull request
Links
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ahmedrowaihi/clickhouse-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server