Skip to main content
Glama
aliyun

Hologres MCP Server

Official
by aliyun

gather_hg_table_statistics

Collect table statistics in Hologres databases to improve query optimization and generate better query execution plans.

Instructions

Execute the ANALYZE TABLE command to have Hologres collect table statistics, enabling QO to generate better query plans

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaYesSchema name in Hologres database
tableYesTable name in Hologres database

Implementation Reference

  • Dispatches the tool call by validating schema and table arguments, then constructs the ANALYZE query for gathering table statistics.
    elif name == "gather_hg_table_statistics":
        schema = arguments.get("schema")
        table = arguments.get("table")
        if not all([schema, table]):
            raise ValueError("Schema and table are required")
        query = f"ANALYZE {schema}.{table}"
    elif name == "get_hg_query_plan":
  • Defines the input schema requiring 'schema' and 'table' strings.
    inputSchema={
        "type": "object",
        "properties": {
            "schema": {
                "type": "string",
                "description": "Schema name in Hologres database"
            },
            "table": {
                "type": "string",
                "description": "Table name in Hologres database"
            }
        },
        "required": ["schema", "table"]
    }
  • Registers the tool in the list_tools() function with name, description, and schema.
    Tool(
        name="gather_hg_table_statistics",
        description="Execute the ANALYZE TABLE command to have Hologres collect table statistics, enabling QO to generate better query plans",
        inputSchema={
            "type": "object",
            "properties": {
                "schema": {
                    "type": "string",
                    "description": "Schema name in Hologres database"
                },
                "table": {
                    "type": "string",
                    "description": "Table name in Hologres database"
                }
            },
            "required": ["schema", "table"]
        }
    ),
  • Executes the constructed query on the database connection. For this tool, specially returns a success message after execution since ANALYZE does not return query results.
    def handle_call_tool(tool_name, query, serverless = False):
        """Handle callTool method."""
        config = get_db_config()
        try:
            with connect_with_retry() as conn:
                with conn.cursor() as cursor:
    
                    # 特殊处理 serverless computing 查询
                    if serverless:
                        cursor.execute("set hg_computing_resource='serverless'")
                    
                    # Execute the query
                    cursor.execute(query)
                    
                    # 特殊处理 ANALYZE 命令
                    if tool_name == "gather_hg_table_statistics":
                        return f"Successfully {query}"
                    
                    # 处理其他有返回结果的查询
                    if cursor.description:  # SELECT query
                        columns = [desc[0] for desc in cursor.description]
                        rows = cursor.fetchall()
                        result = [",".join(map(str, row)) for row in rows]
                        return "\n".join([",".join(columns)] + result)
                    elif tool_name == "execute_dml_sql":  # Non-SELECT query
                        row_count = cursor.rowcount
                        return f"Query executed successfully. {row_count} rows affected."
                    else:
                        return "Query executed successfully"
        except Exception as e:
            return f"Error executing query: {str(e)}"
  • Special handling for ANALYZE command: returns success message without fetching results.
    # 特殊处理 ANALYZE 命令
    if tool_name == "gather_hg_table_statistics":
        return f"Successfully {query}"
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 mentions the command execution and purpose but lacks critical details: it doesn't specify if this is a read-only or destructive operation (ANALYZE TABLE can be resource-intensive), required permissions, execution time, or impact on database performance. This leaves significant gaps for safe and effective use.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the key action and purpose without unnecessary details. Every word contributes to understanding the tool's function, making it appropriately sized and well-structured for quick comprehension.

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?

Given the complexity of a database statistics tool with no annotations and no output schema, the description is incomplete. It explains what the tool does but omits behavioral aspects (e.g., execution characteristics, side effects) and output details. For a tool that likely affects query performance, more context on usage and results is needed for effective agent operation.

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 100%, with both parameters (schema and table) well-documented in the input schema. The description adds no additional parameter semantics beyond implying these are used for the ANALYZE TABLE command. This meets the baseline score of 3 when schema coverage is high, as the schema adequately explains the parameters.

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 action ('Execute the ANALYZE TABLE command') and the resource ('Hologres collect table statistics'), with a specific purpose ('enabling QO to generate better query plans'). It distinguishes from siblings like list_hg_tables_in_a_schema or show_hg_table_ddl by focusing on statistics collection rather than listing or showing DDL. However, it doesn't explicitly differentiate from execute_hg_ddl_sql, which could potentially run similar commands.

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. It doesn't mention prerequisites (e.g., after data changes), exclusions (e.g., not for real-time tables), or compare to siblings like execute_hg_ddl_sql for similar SQL execution. Usage is implied through the purpose but lacks explicit context for selection.

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

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/aliyun/alibabacloud-hologres-mcp-server'

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