Skip to main content
Glama
ClickHouse

mcp-clickhouse

Official
by ClickHouse

list_databases

Retrieve all available ClickHouse databases to inspect schemas and manage data connections.

Instructions

List available ClickHouse databases

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'list_databases' tool. It connects to ClickHouse, runs 'SHOW DATABASES', processes the result into a list of database names, and returns them as a JSON string.
    def list_databases():
        """List available ClickHouse databases"""
        logger.info("Listing all databases")
        client = create_clickhouse_client()
        result = client.command("SHOW DATABASES")
    
        # Convert newline-separated string to list and trim whitespace
        if isinstance(result, str):
            databases = [db.strip() for db in result.strip().split("\n")]
        else:
            databases = [result]
    
        logger.info(f"Found {len(databases)} databases")
        return json.dumps(databases)
  • Registers the 'list_databases' tool (along with others) with the FastMCP server instance if ClickHouse is enabled via environment variable.
    if os.getenv("CLICKHOUSE_ENABLED", "true").lower() == "true":
        mcp.add_tool(Tool.from_function(list_databases))
        mcp.add_tool(Tool.from_function(list_tables))
        mcp.add_tool(Tool.from_function(run_select_query))
        logger.info("ClickHouse tools registered")
  • Exposes the list_databases function in the package __init__ for easy import.
        list_databases,
        list_tables,
        run_select_query,
        create_chdb_client,
        run_chdb_select_query,
        chdb_initial_prompt,
        table_pagination_cache,
        fetch_table_names_from_system,
        get_paginated_table_data,
        create_page_token,
    )
    
    
    if os.getenv("MCP_CLICKHOUSE_TRUSTSTORE_DISABLE", None) != "1":
        try:
            import truststore
            truststore.inject_into_ssl()
        except Exception:
            pass
    
    __all__ = [
        "list_databases",
Install Server

Other Tools

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/ClickHouse/mcp-clickhouse'

If you have feedback or need assistance with the MCP directory API, please join our Discord server