Skip to main content
Glama

get_queries_with_largest_response_sizes

Identify queries returning the largest data volumes from Couchbase's completed_requests catalog to analyze and optimize database performance.

Instructions

Get queries with the largest response sizes from the system:completed_requests catalog.

Args:
    limit: Number of queries to return (default: 10)

Returns:
    List of queries with their average result size in bytes, KB, and MB

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function that implements the tool logic by executing a SQL++ query on system:completed_requests to identify queries with the largest average response sizes, formatting sizes in bytes, KB, and MB, and handling empty results gracefully.
    def get_queries_with_largest_response_sizes(
        ctx: Context, limit: int = 10
    ) -> list[dict[str, Any]]:
        """Get queries with the largest response sizes from the system:completed_requests catalog.
    
        Args:
            limit: Number of queries to return (default: 10)
    
        Returns:
            List of queries with their average result size in bytes, KB, and MB
        """
        query = """
        SELECT statement,
            avgResultSize AS avgResultSizeBytes,
            (avgResultSize / 1000) AS avgResultSizeKB,
            (avgResultSize / 1000000) AS avgResultSizeMB,
            COUNT(1) AS queries
        FROM system:completed_requests
        WHERE UPPER(statement) NOT LIKE 'INFER %'
            AND UPPER(statement) NOT LIKE 'CREATE INDEX%'
            AND UPPER(statement) NOT LIKE 'CREATE PRIMARY INDEX%'
            AND UPPER(statement) NOT LIKE '% SYSTEM:%'
        GROUP BY statement
        LETTING avgResultSize = AVG(resultSize)
        ORDER BY avgResultSize DESC
        LIMIT $limit
        """
    
        return _run_query_tool_with_empty_message(
            ctx,
            query,
            limit=limit,
            empty_message=(
                "No completed queries were available to calculate response sizes."
            ),
        )
  • The tool is registered to the FastMCP server instance by iterating over ALL_TOOLS (which includes this tool) and calling add_tool().
    # Register all tools
    for tool in ALL_TOOLS:
        mcp.add_tool(tool)
  • The tool handler is imported from query.py and explicitly included in the ALL_TOOLS list, which is used by mcp_server.py for registration.
    get_queries_not_using_covering_index,
    get_queries_using_primary_index,
    get_queries_with_large_result_count,
    get_queries_with_largest_response_sizes,
  • Supporting helper utility invoked by the handler to run the cluster query and provide a standardized empty results response.
    def _run_query_tool_with_empty_message(
        ctx: Context,
        query: str,
        *,
        limit: int,
        empty_message: str,
        extra_payload: dict[str, Any] | None = None,
        **query_kwargs: Any,
    ) -> list[dict[str, Any]]:
        """Execute a cluster query with a consistent empty-result response."""
        results = run_cluster_query(ctx, query, limit=limit, **query_kwargs)
    
        if results:
            return results
    
        payload: dict[str, Any] = {"message": empty_message, "results": []}
        if extra_payload:
            payload.update(extra_payload)
        return [payload]
Behavior2/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 states the tool retrieves data from a catalog, implying read-only behavior, but lacks details on permissions, rate limits, or potential side effects. It mentions the return format but does not fully describe behavior beyond basic operation.

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 front-loaded with the core purpose, followed by structured sections for args and returns. It is efficient with minimal waste, though the 'Args' and 'Returns' labels add slight redundancy. Overall, it is appropriately sized and well-organized.

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 moderate complexity (1 parameter, no annotations, but with an output schema), the description is partially complete. It covers the purpose and parameter semantics adequately, but lacks behavioral details and usage guidelines. The output schema existence reduces the need to explain return values, but gaps remain in contextual guidance.

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?

The description adds meaningful context for the single parameter 'limit' by explaining it as 'Number of queries to return' with a default of 10, which clarifies its purpose beyond the schema's basic type and title. Since schema description coverage is 0%, this compensates well, though it could detail constraints like minimum/maximum values.

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 verb 'Get' and the resource 'queries with the largest response sizes', specifying the source 'system:completed_requests catalog'. It distinguishes from siblings like 'get_queries_with_large_result_count' by focusing on response size rather than result count, 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 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 does not mention sibling tools like 'get_longest_running_queries' or 'get_most_frequent_queries', nor does it specify prerequisites or exclusions, leaving usage context unclear.

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/Couchbase-Ecosystem/mcp-server-couchbase'

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