Skip to main content
Glama
aliyun

Alibaba Cloud RDS OpenAPI MCP Server

Official
by aliyun

describe_sql_insight_statistic

Read-only

Query SQL log statistics for Alibaba Cloud RDS instances to analyze execution times, costs, and account usage within specified time periods.

Instructions

Query SQL Log statistics, including SQL cost time, execution times, and account.
Args:
    dbinstance_id (str): The ID of the RDS instance.
    start_time(str): the start time of sql insight statistic. e.g. 2025-06-06 20:00:00
    end_time(str): the end time of sql insight statistic. e.g. 2025-06-06 20:10:00
Returns:
    the sql insight statistic information in csv format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dbinstance_idYes
start_timeYes
end_timeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'describe_sql_insight_statistic' tool. It queries SQL insight statistics from the DAS API (DescribeSqlInsightStatistic), fetching top SQLs by RT rate and count rate within the given time range for the specified RDS instance. It handles pagination and polling for job completion, formatting results as CSV.
    async def describe_sql_insight_statistic(
            dbinstance_id: str,
            start_time: str,
            end_time: str,
    ) -> Dict[str, Any]:
        """
        Query SQL Log statistics, including SQL cost time, execution times, and account.
        Args:
            dbinstance_id (str): The ID of the RDS instance.
            start_time(str): the start time of sql insight statistic. e.g. 2025-06-06 20:00:00
            end_time(str): the end time of sql insight statistic. e.g. 2025-06-06 20:10:00
        Returns:
            the sql insight statistic information in csv format.
        """
    
        def _descirbe(order_by: str):
            try:
                # Initialize client
                client = get_das_client()
                page_no = 1
                page_size = 50
                total = page_no * page_size + 1
                result = []
                while total > page_no * page_size:
                    state = "RUNNING"
                    job_id = ""
                    while state == "RUNNING":
                        body = {
                            "InstanceId": dbinstance_id,
                            "OrderBy": order_by,
                            "Asc": False,
                            "PageNo": 1,
                            "PageSize": 10,
                            "TemplateId": "",
                            "DbName": "",
                            "StartTime": convert_datetime_to_timestamp(start_time),
                            "EndTime": convert_datetime_to_timestamp(end_time),
                            "JobId": job_id
                        }
                        req = open_api_models.OpenApiRequest(
                            query=OpenApiUtilClient.query({}),
                            body=OpenApiUtilClient.parse_to_map(body)
                        )
                        params = open_api_models.Params(
                            action='DescribeSqlInsightStatistic',
                            version='2020-01-16',
                            protocol='HTTPS',
                            pathname='/',
                            method='POST',
                            auth_type='AK',
                            style='RPC',
                            req_body_type='formData',
                            body_type='json'
                        )
                        response = client.call_api(params, req, util_models.RuntimeOptions())
                        response_data = response['body']['Data']
                        state = response_data['State']
                        if state == "RUNNING":
                            job_id = response_data['ResultId']
                            time.sleep(1)
                            continue
                        if state == "SUCCESS":
                            result.extend(response_data['Data']['List'])
                            total = response_data['Data']['Total']
                            page_no = page_no + 1
    
                return json_array_to_csv(result)
            except Exception as e:
                logger.error(f"Error occurred: {str(e)}")
                raise e
    
        rt_rate = _descirbe("rtRate")
        count_rate = _descirbe("countRate")
        return {
            "sql_log_order_by_rt_rate": rt_rate,
            "sql_log_order_by_count_rate": count_rate
        }
Behavior3/5

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

The annotations indicate readOnlyHint=true, which the description aligns with by using 'Query' (a read operation). The description adds value by specifying the return format ('csv format'), which isn't covered by annotations. However, it lacks details on rate limits, authentication needs, or data freshness, leaving behavioral gaps despite the annotation coverage.

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 efficiently structured with a purpose statement, Args section, and Returns section, all in three concise sentences. It's front-loaded with the core functionality. Minor improvements could include bullet points for readability, but it avoids redundancy and wastes no words.

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

Completeness3/5

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

Given the tool's complexity (querying SQL insights with time ranges), the description is adequate but incomplete. It covers parameters and output format, and annotations handle read-only safety. However, it lacks context on data scope (e.g., which databases or accounts), error handling, or how it differs from similar tools, leaving gaps for an AI agent to infer usage.

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

Parameters4/5

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

With 0% schema description coverage, the description compensates well by explaining all three parameters: dbinstance_id, start_time, and end_time. It provides examples for time formats (e.g., '2025-06-06 20:00:00'), adding meaningful context beyond the bare schema. A perfect score is withheld as it doesn't clarify parameter constraints like timezone handling or ID validation.

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 tool's purpose: 'Query SQL Log statistics, including SQL cost time, execution times, and account.' It specifies the verb ('Query') and resource ('SQL Log statistics') with details about what statistics are included. However, it doesn't explicitly differentiate from sibling tools like 'describe_slow_log_records' or 'describe_db_instance_performance', which prevents a perfect score.

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 sibling tools like 'describe_slow_log_records' for slow logs or 'describe_db_instance_performance' for performance metrics, nor does it specify prerequisites or exclusions. The only contextual hint is the time range parameters, but this is insufficient for usage differentiation.

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-rds-openapi-mcp-server'

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