By ClickHouseCreated 23 days ago
starstarstarstarstar

Query your ClickHouse database server.

Visit Project
Share this MCP:
X (Formerly Twitter)RedditblueskyThreads by Instagram

Category

Official MCP Server

Tags

ClickhouseSqlDatabaseMcp ServerOlap

What is ClickHouse MCP Server?

ClickHouse MCP Server is an integration tool that allows you to query your ClickHouse database server directly through MCP (Model Communications Protocol) clients like Claude. It supports both ClickHouse (a high-performance OLAP database) and chDB (ClickHouse's embedded OLAP engine) for direct data querying from various sources without ETL processes.

How to use ClickHouse MCP Server?

  1. Configure the MCP Server:
    • Locate and modify the Claude Desktop configuration file:
      • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
      • Windows: %APPDATA%/Claude/claude_desktop_config.json
  2. Add the server configuration:
    • Add the mcp-clickhouse server section with required environment variables for ClickHouse or chDB.
    • Example for ClickHouse SQL playground:
      {
        "mcpServers": {
          "mcp-clickhouse": {
            "env": {
              "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com",
              "CLICKHOUSE_PORT": "8443",
              "CLICKHOUSE_USER": "demo"
            }
          }
        }
      }
      
  3. Restart Claude Desktop to apply the changes.

Key Features of ClickHouse MCP Server

  • ClickHouse Tools
    • run_select_query: Execute SQL queries with readonly=1 for safety
    • list_databases: List all databases on the ClickHouse cluster
    • list_tables: List tables in a specified database
  • chDB Tools
    • run_chdb_select_query: Execute SQL queries using chDB's embedded engine
    • Supports direct querying from files, URLs, and databases without ETL
  • Configuration Flexibility
    • Supports both ClickHouse and chDB simultaneously
    • Comprehensive environment variable controls for security and performance
  • Security
    • Recommends using non-administrative users with minimum privileges
    • Default secure connections via HTTPS

Use Cases of ClickHouse MCP Server

  1. Direct Data Analysis: Execute SQL queries on large datasets with high performance
  2. Database Exploration: List databases and tables programmatically
  3. Embedded Analytics: Use chDB to query data directly from sources without loading into ClickHouse
  4. Local Development: Test queries in a Dockerized ClickHouse environment
  5. Cloud Integration: Connect to ClickHouse Cloud instances
  6. Mixed Workloads: Combine traditional ClickHouse with chDB's embedded capabilities
  7. Secure Access: SafeREAD_ONLY queries with MFA and SSL verification

FAQ from ClickHouse MCP Server

  • How do I connect to a secure ClickHouse instance?

    Set CLICKHOUSE_SECURE=true and provide valid certificates for CLICKHOUSE_VERIFY. Use standard HTTPS ports (8443).

  • Can I use chDB without ClickHouse?

    Yes, set CHDB_ENABLED=true and CLICKHOUSE_ENABLED=false. You can configure CHDB_DATA_PATH for persistent storage.

  • What's the default timeout for queries?

    Connection timeout is 30 seconds, send/receive timeout is 300 seconds for long-running queries.

  • How do I test the server locally?

    Use fastmcp dev or run the development ClickHouse cluster with docker compose up -d in the test-services directory.

  • Is my password stored securely?

    Passwords are handled via environment variables. For production, use secure credential stores and never hardcode passwords.

  • What's the difference between ClickHouse and chDB?

    ClickHouse is a standalone OLAP database, while chDB is an embedded version that can query data directly from various sources.

  • How do I add a new database?

    Use standard ClickHouse client tools or SQL commands. The MCP server provides read-only access by default.