Skip to main content
Glama
aliyun

Hologres MCP Server

Official
by aliyun

execute_hg_select_sql_with_serverless

Execute SELECT SQL queries on Hologres databases using serverless computing resources to handle memory-intensive operations and avoid query memory limitations.

Instructions

Use Serverless Computing resources to execute SELECT SQL to query data in Hologres database. When the error like "Total memory used by all existing queries exceeded memory limitation" occurs during execute_hg_select_sql execution, you can re-execute the SQL with the tool execute_hg_select_sql_with_serverless.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe (SELECT) SQL query to execute with serverless computing in Hologres database

Implementation Reference

  • Specific handler branch in call_tool that extracts and validates the SQL query, ensures it's a SELECT statement, and sets the serverless flag for execution.
    elif name == "execute_hg_select_sql_with_serverless":
        query = arguments.get("query")
        if not query:
            raise ValueError("Query is required")
        if not query.strip().upper().startswith("SELECT"):
            raise ValueError("Query must be a SELECT statement")
        # 修改 serverless computing 设置方式
        serverless = True
  • Input schema definition for the tool, specifying a required 'query' string parameter.
    inputSchema={
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "The (SELECT) SQL query to execute with serverless computing in Hologres database"
            }
        },
        "required": ["query"]
    }
  • Tool registration in the list_tools() function, including name, description, and input schema.
    Tool(
        name="execute_hg_select_sql_with_serverless",
        description="Use Serverless Computing resources to execute SELECT SQL to query data in Hologres database. When the error like \"Total memory used by all existing queries exceeded memory limitation\" occurs during execute_hg_select_sql execution, you can re-execute the SQL with the tool execute_hg_select_sql_with_serverless.",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "The (SELECT) SQL query to execute with serverless computing in Hologres database"
                }
            },
            "required": ["query"]
        }
    ),
  • Core helper function that connects to the database, sets the serverless computing resource if specified, executes the SQL query, and formats the results or errors.
    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)}"
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively explains the tool's purpose (executing SELECT queries with serverless resources) and its specific use case for handling memory limitation errors, which is valuable context. However, it doesn't mention other behavioral aspects like performance characteristics, authentication needs, or error handling beyond the memory issue.

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 highly concise and well-structured in two sentences: the first states the core purpose, and the second provides specific usage guidance. Every word earns its place with no redundancy or fluff, making it easy to parse and understand quickly.

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

Completeness4/5

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

Given the tool's moderate complexity (executing SQL queries with serverless resources), no annotations, and no output schema, the description does a good job covering the essential context: purpose, specific use case, and differentiation from siblings. However, it lacks details on return values, error handling beyond memory limits, or performance implications, leaving some gaps for a tool that interacts with a database.

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%, so the schema already documents the single 'query' parameter thoroughly. The description adds minimal value beyond what's in the schema by mentioning it's for 'SELECT SQL' execution, but doesn't provide additional syntax, format, or constraint details. This meets the baseline for high schema coverage.

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

Purpose5/5

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

The description clearly states the specific action ('execute SELECT SQL to query data') and resource ('Hologres database') using 'Serverless Computing resources'. It explicitly distinguishes from sibling tool 'execute_hg_select_sql' by mentioning it as an alternative for memory limitation errors, making the purpose specific and differentiated.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool versus alternatives: 'When the error like "Total memory used by all existing queries exceeded memory limitation" occurs during execute_hg_select_sql execution, you can re-execute the SQL with this tool.' This clearly defines the specific scenario and names the alternative tool, offering complete usage context.

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