list_databases
Retrieve all available ClickHouse databases to inspect schemas and manage data connections.
Instructions
List available ClickHouse databases
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_clickhouse/mcp_server.py:124-138 (handler)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)
- mcp_clickhouse/mcp_server.py:562-567 (registration)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")
- mcp_clickhouse/__init__.py:5-26 (registration)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",