home / mcp / clickhouse mcp server

ClickHouse MCP Server

Provides MCP endpoints to run SQL queries, list databases, and enumerate tables on a ClickHouse cluster.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "iskakaushik-mcp-clickhouse": {
      "command": "fastmcp",
      "args": [
        "install",
        "mcp_clickhouse/mcp_server.py",
        "-f",
        ".env.production"
      ],
      "env": {
        "CLICKHOUSE_HOST": "localhost",
        "CLICKHOUSE_PORT": "8123",
        "CLICKHOUSE_USER": "default",
        "CLICKHOUSE_PASSWORD": "clickhouse"
      }
    }
  }
}

This MCP Server lets you run and manage ClickHouse queries from a unified API. You can execute read-only SQL, list databases, and enumerate tables across your ClickHouse cluster, making it easy to build tools and dashboards that rely on live data.

How to use

Connect with your MCP client and call the available tools to interact with ClickHouse. You can execute read-only SQL queries with run_select_query, list all databases with list_databases, and list tables within a database with list_tables. These endpoints are designed to be safe for operational use by ensuring all SQL queries run in readonly mode.

How to install

{
  "mcpServers": {
    "clickhouse_mcp": {
      "command": "fastmcp",
      "args": ["install", "mcp_clickhouse/mcp_server.py", "-f", ".env.production"]
    }
  }
}

Additional notes

Prerequisites include a Python-compatible environment and the MCP tooling used to manage server plugins. You will set up a production environment file with your ClickHouse credentials, install the MCP server, and then start using it with your MCP client or development workflow.

Development tips

For local development, you can start a ClickHouse cluster using the provided container setup, then define the required environment variables in a root or per-project file. Use the development command to run the MCP server during testing.

Available tools

run_select_query

Execute a read-only SQL query on your ClickHouse cluster. You provide the SQL string and the server runs it with readonly mode to ensure safety.

list_databases

Return a list of all databases present on your ClickHouse cluster.

list_tables

Return a list of tables within a specified database.