list_databases
Retrieve a list of all available databases in the ClickHouse MCP Server for streamlined database management and access.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_databases"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_clickhouse/mcp_server.py:28-34 (handler)The handler function for the 'list_databases' tool. It uses a ClickHouse client to execute the 'SHOW DATABASES' command and returns the list of databases.
@mcp.tool() def list_databases(): logger.info("Listing all databases") client = create_clickhouse_client() result = client.command("SHOW DATABASES") logger.info(f"Found {len(result) if isinstance(result, list) else 1} databases") return result - mcp_clickhouse/mcp_server.py:104-115 (helper)Helper function to create and return a ClickHouse client instance using environment variables, used by the list_databases handler.
def create_clickhouse_client(): host = os.getenv("CLICKHOUSE_HOST") port = os.getenv("CLICKHOUSE_PORT") username = os.getenv("CLICKHOUSE_USER") logger.info(f"Creating ClickHouse client connection to {host}:{port} as {username}") return clickhouse_connect.get_client( host=host, port=port, username=username, password=os.getenv("CLICKHOUSE_PASSWORD"), )