The ClickHouse MCP Server enables Claude to interact with ClickHouse databases through SQL queries, providing a bridge between the AI assistant and your data. It supports both remote ClickHouse instances and the embedded chDB engine.
To set up the ClickHouse MCP Server for Claude Desktop:
Locate the Claude Desktop configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%/Claude/claude_desktop_config.jsonAdd the following configuration for a ClickHouse connection:
{
  "mcpServers": {
    "mcp-clickhouse": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.10",
        "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"
      }
    }
  }
}
To try it out with a public demo instance:
{
  "mcpServers": {
    "mcp-clickhouse": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.10",
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com",
        "CLICKHOUSE_PORT": "8443",
        "CLICKHOUSE_USER": "demo",
        "CLICKHOUSE_PASSWORD": "",
        "CLICKHOUSE_SECURE": "true",
        "CLICKHOUSE_VERIFY": "true",
        "CLICKHOUSE_CONNECT_TIMEOUT": "30",
        "CLICKHOUSE_SEND_RECEIVE_TIMEOUT": "30"
      }
    }
  }
}
To use the embedded chDB engine:
{
  "mcpServers": {
    "mcp-clickhouse": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.10",
        "mcp-clickhouse"
      ],
      "env": {
        "CHDB_ENABLED": "true",
        "CLICKHOUSE_ENABLED": "false",
        "CHDB_DATA_PATH": "/path/to/chdb/data"
      }
    }
  }
}
You can enable both simultaneously:
{
  "mcpServers": {
    "mcp-clickhouse": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.10",
        "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",
        "CHDB_ENABLED": "true",
        "CHDB_DATA_PATH": "/path/to/chdb/data"
      }
    }
  }
}
If you prefer not to use uv:
python3 -m pip install mcp-clickhouse
{
  "mcpServers": {
    "mcp-clickhouse": {
      "command": "python3",
      "args": [
        "-m",
        "mcp_clickhouse.main"
      ],
      "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"
      }
    }
  }
}
Alternatively, use the installed script directly:
{
  "mcpServers": {
    "mcp-clickhouse": {
      "command": "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"
      }
    }
  }
}
run_select_query: Execute SQL queries on your ClickHouse cluster (read-only).
sql (string) - The SQL query to execute.list_databases: List all databases on your ClickHouse cluster.
list_tables: List all tables in a specific database.
database (string) - The name of the database.sql (string) - The SQL query to execute.CLICKHOUSE_HOST: ClickHouse server hostnameCLICKHOUSE_USER: Username for authenticationCLICKHOUSE_PASSWORD: Password for authenticationCLICKHOUSE_PORT: Default is 8443 for HTTPS, 8123 for HTTPCLICKHOUSE_SECURE: Enable/disable HTTPS ("true" by default)CLICKHOUSE_VERIFY: Enable/disable SSL verification ("true" by default)CLICKHOUSE_CONNECT_TIMEOUT: Connection timeout in seconds ("30" by default)CLICKHOUSE_SEND_RECEIVE_TIMEOUT: Query timeout in seconds ("300" by default)CLICKHOUSE_DATABASE: Default database to useCLICKHOUSE_MCP_SERVER_TRANSPORT: Transport method ("stdio", "http", or "sse")CLICKHOUSE_MCP_BIND_HOST: Host to bind for HTTP/SSE ("127.0.0.1" by default)CLICKHOUSE_MCP_BIND_PORT: Port for HTTP/SSE ("8000" by default)CLICKHOUSE_MCP_QUERY_TIMEOUT: Timeout for SELECT tools ("30" by default)CLICKHOUSE_ENABLED: Enable/disable ClickHouse functionality ("true" by default)CHDB_ENABLED: Enable/disable chDB functionality ("false" by default)CHDB_DATA_PATH: Path to chDB data directory (":memory:" by default)When running with HTTP or SSE transport, a health check endpoint is available at /health, which:
200 OK with the ClickHouse version if healthy503 Service Unavailable if unable to connectExample:
curl http://localhost:8000/health
# Response: OK - Connected to ClickHouse 24.3.1
                    
                    To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "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"}}'
                        See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:
{
    "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"
            }
        }
    }
}
                        To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. Add this to your configuration file:
{
    "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"
            }
        }
    }
}
                        3. Restart Claude Desktop for the changes to take effect