Skip to main content
Glama
cgrdavies

mcp-clickhouse-long-running

by cgrdavies

list_tables

Retrieve detailed information on ClickHouse tables in a specified database, including schema, comment, row count, and column count. Filter results using 'like' and 'not like' patterns for precise table listing.

Instructions

List available ClickHouse tables in a database, including schema, comment, row count, and column count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYes
likeNo
not_likeNo

Implementation Reference

  • The @mcp.tool()-decorated handler function that implements the list_tables tool. It queries system.tables for table metadata in the given database (optionally filtered by like/not_like), then for each table queries system.columns to fetch column details, constructs Table and Column dataclasses, and returns serialized dicts.
    @mcp.tool()
    def list_tables(
        database: str, like: Optional[str] = None, not_like: Optional[str] = None
    ):
        """List available ClickHouse tables in a database, including schema, comment,
        row count, and column count."""
        logger.info(f"Listing tables in database '{database}'")
        client = create_clickhouse_client()
        query = f"SELECT database, name, engine, create_table_query, dependencies_database, dependencies_table, engine_full, sorting_key, primary_key, total_rows, total_bytes, total_bytes_uncompressed, parts, active_parts, total_marks, comment FROM system.tables WHERE database = {format_query_value(database)}"
        if like:
            query += f" AND name LIKE {format_query_value(like)}"
    
        if not_like:
            query += f" AND name NOT LIKE {format_query_value(not_like)}"
    
        result = client.query(query)
    
        # Deserialize result as Table dataclass instances
        tables = result_to_table(result.column_names, result.result_rows)
    
        for table in tables:
            column_data_query = f"SELECT database, table, name, type AS column_type, default_kind, default_expression, comment FROM system.columns WHERE database = {format_query_value(database)} AND table = {format_query_value(table.name)}"
            column_data_query_result = client.query(column_data_query)
            table.columns = [
                c
                for c in result_to_column(
                    column_data_query_result.column_names,
                    column_data_query_result.result_rows,
                )
            ]
    
        logger.info(f"Found {len(tables)} tables")
        return [asdict(table) for table in tables]
  • Table dataclass defining the output schema for tables returned by list_tables.
    @dataclass
    class Table:
        database: str
        name: str
        engine: str
        create_table_query: str
        dependencies_database: str
        dependencies_table: str
        engine_full: str
        sorting_key: str
        primary_key: str
        total_rows: int
        total_bytes: int
        total_bytes_uncompressed: int
        parts: int
        active_parts: int
        total_marks: int
        comment: Optional[str] = None
        columns: List[Column] = field(default_factory=list)
  • Column dataclass defining the schema for table columns.
    @dataclass
    class Column:
        database: str
        table: str
        name: str
        column_type: str
        default_kind: Optional[str]
        default_expression: Optional[str]
        comment: Optional[str]
  • Helper function to convert query results to List[Table].
    def result_to_table(query_columns, result) -> List[Table]:
        return [Table(**dict(zip(query_columns, row))) for row in result]
  • Helper function to convert query results to List[Column].
    def result_to_column(query_columns, result) -> List[Column]:
        return [Column(**dict(zip(query_columns, row))) for row in result]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It describes what information is returned but doesn't mention performance characteristics, rate limits, authentication requirements, pagination behavior, or whether this is a read-only operation (though 'list' implies read-only). The description is functional but lacks important operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently conveys the core functionality. It's appropriately sized for a listing tool and front-loads the essential information without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 3 parameters (0% schema coverage), no annotations, and no output schema, the description is insufficient. It explains what information is returned but doesn't address how to use the parameters, what format the output takes, or important behavioral considerations. The description leaves too many gaps given the tool's complexity and lack of structured documentation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the schema provides no parameter documentation. The description doesn't mention any parameters at all, failing to explain what 'database', 'like', or 'not_like' parameters do or how they affect the listing. This leaves significant gaps in understanding how to use the tool effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'list' and resource 'ClickHouse tables in a database', specifying what information is included (schema, comment, row count, column count). It distinguishes from 'list_databases' by focusing on tables within a database, but doesn't explicitly differentiate from 'run_select_query' which could also retrieve table information.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'run_select_query' for table information or 'list_databases' for database listing. It mentions what the tool does but offers no context about appropriate use cases or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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